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.

serial library
#1
I need to open an rs232 port in 2 different baud rates at different times,  how do i achieve this while still receiving data from the rs232 port once the port is open again.
where is the best location to handle the opening/closing of the port and where is the best location to receive the read data?

if i put some looping code in a library 

if port do
port:read(1,1)
end

other functions are not able to run while the loop is running what is the right method to receive data into a library, i need to keep the port open/recieved data coming in as i don't know when some string might be sent from the rs232 end point. 

i have looked at the serial library doc  http://openrb.com/docs/serial.htm

and can get the code below to work and have connectivity to rs232 device
any help is much appreciated.

if not port then
  require('serial')
  port = serial.open('/dev/RS232', { baudrate = 9600, parity = 'none', duplex = 'full' })
  port:flush()
end

-- port ready
if port then
  char = port:read(1, 1)
  if char then
    alert(char)
  end
end
Reply


Messages In This Thread
serial library - by benanderson_475 - 03.01.2018, 21:12
RE: serial library - by admin - 04.01.2018, 08:02
RE: serial library - by benanderson_475 - 04.01.2018, 19:59
RE: serial library - by admin - 05.01.2018, 08:24
RE: serial library - by benanderson_475 - 08.01.2018, 10:30
RE: serial library - by admin - 09.01.2018, 13:50

Forum Jump: