Skip to content

Instantly share code, notes, and snippets.

@knowtheory
Last active March 24, 2024 21:02
Show Gist options
  • Save knowtheory/1fd9e05a48c182177c7ad73e8bfaa4cf to your computer and use it in GitHub Desktop.
Save knowtheory/1fd9e05a48c182177c7ad73e8bfaa4cf to your computer and use it in GitHub Desktop.
A lil example using the UART gem to send and receive messages from a Flipper Zero
require 'uart'
# find your flipper zero device handle: https://docs.flipper.net/development/cli#rnDLl
fname = ARGV.shift # provide the path to your flipper zero
raise "Please specify a device to open" if fname.nil?
raise "Couldn't find #{fname}" unless File.exist?(fname)
# open the flipper and specify the correct baud
UART.open fname, 115200 do |flipper|
# read & print the Flipper Zero terminal art
puts flipper.read
# input command, or "help" if no command is supplied
message = ARGV.join(" ") || "help"
flipper.write "#{message}\r\n" # flipper cli uses \r\n to terminate lines.
# read & print message output
puts flipper.read
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment