Created
September 8, 2016 17:43
-
-
Save jeremywrnr/3bf4da8353c3702de23df5842a5fb0d7 to your computer and use it in GitHub Desktop.
Pipe serial monitor output to OSX keyboard
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
# using the SerialPort gem, rout serial input to OSX keyboard | |
require 'serialport' | |
require 'accessibility/keyboard' | |
include Accessibility::Keyboard | |
# params for serial port, may be different for you | |
port = '/dev/cu.usbmodem1421' | |
SerialPort.open(port) do |sp| | |
# configure port | |
sp.baud = 9600 | |
sp.data_bits = 8 | |
sp.stop_bits = 1 | |
sp.parity = SerialPort::NONE | |
sp.read_timeout = 200 | |
# rout data to keyboard | |
while true do | |
inbyte = sp.gets | |
next if inbyte.nil? | |
keyboard_events_for(inbyte.chomp).each {|e| KeyCoder.post_event(e) } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment