This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Read from the logic machine
#1
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.
Reply
#2
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
Reply
#3
Excuse at what point could you see the reading results? Since the logs?
Thanks for your help.
Reply
#4
It will send it back to your PC, if you want to log it, you can add log(char) after port:read(1, 1)
Reply
#5
Thank you, you have been very helpful.
Reply


Forum Jump: