I see a there is a SerialPort category, which I can access from REPL:
Code: Select all
-- Serial Port --
openSerialPort
closeSerialPort
readSerialPort
writeSerialPort
Thanks!
Moderator: MSandro
Code: Select all
-- Serial Port --
openSerialPort
closeSerialPort
readSerialPort
writeSerialPort
Code: Select all
gp> help openSerialPort
Open a serial port. Return the portID or nil on failure. Arguments: portName, baudRate
Code: Select all
to testPort cmd {
if (isNil cmd) { cmd = '' }
p = (openSerialPort '/dev/tty.usbmodem1412' 115200)
sleep 1000
writeSerialPort p (join cmd (string 13))
sleep 1000
print (readSerialPort p)
closeSerialPort p
}
Code: Select all
gp> testPort 'help'
help
Shell commands:
help - shell help
lua - start a Lua session
ls - lists files and directories
dir - lists files and directories
cat - list the contents of a file
type - list the contents of a file
recv - receive files via XMODEM
cp - copy files
ver - show version information
mkdir - create directories
exit - exit the shell
For more information use 'help <command>'.
eLua#
nil
gp>
Code: Select all
f = io.open('autorun.lua')
f:write('pio.pin.sethigh(pio.PB_3)')
f:close()