-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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