Logic Machine Forum
Read from the logic machine - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Read from the logic machine (/showthread.php?tid=677)



Read from the logic machine - Rodriguez - 16.03.2017

Hello, so far I'm starting to work with logic machine, I've been connecting the logic machine to a pc through the rs232 port, I've succeeded and I could write from the logic machine to a pc terminal, but I do not know how to read To the pc from the logic Is this possible?
Sorry for the translation, I do not speak English.
Thank you.


RE: Read from the logic machine - admin - 16.03.2017

Here's the documentation on serial library:
http://openrb.com/docs/serial.htm

Here's a small example that will send back everything that LM reads from RS232 (default serial settings are 115200 8N1):
Code:
-- open port on first call
if not port then
  require('serial')
  port = serial.open('/dev/RS232')
  port:flush()
end

-- port ready
if port then
  -- read one byte
  char = port:read(1, 1)
  -- send back if read succeeded
  if char then
    port:write(char)
  end
end



RE: Read from the logic machine - Rodriguez - 16.03.2017

Excuse at what point could you see the reading results? Since the logs?
Thanks for your help.


RE: Read from the logic machine - admin - 16.03.2017

It will send it back to your PC, if you want to log it, you can add log(char) after port:read(1, 1)


RE: Read from the logic machine - Rodriguez - 16.03.2017

Thank you, you have been very helpful.