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.

Sauna RS485 connection with LM
#6
Evrithing is good its working code:

Code:
require('serial')
port = serial.open('/dev/RS485-1', { baudrate = 57600, parity = 'none', duplex = 'half', databits = 8, stopbits = 1 })
port:flush()


function readack()
 local line = {}

 while true do
   local char, err = port:read(1, 5)

   if char == nil then
     return nil, err
   elseif char == ';' then
     break
   else
     line[ #line + 1 ] = char
   end
 end

 return table.concat(line)
end

port:write('get sauna\r')
res, err = readack()
log(res, err)

port:close()
Reply


Messages In This Thread
RE: Sauna RS485 connection with LM - by admin - 09.11.2018, 08:32
RE: Sauna RS485 connection with LM - by admin - 09.11.2018, 09:46
RE: Sauna RS485 connection with LM - by Thinklight - 09.11.2018, 12:31
RE: Sauna RS485 connection with LM - by admin - 06.10.2023, 12:43
RE: Sauna RS485 connection with LM - by admin - 13.12.2023, 08:31
RE: Sauna RS485 connection with LM - by admin - 13.12.2023, 08:39
RE: Sauna RS485 connection with LM - by admin - 13.12.2023, 11:19

Forum Jump: