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
#4
If you want to query status periodically then things get more complicated. You need to have a single resident script which will handle both reading and writing because you cannot have multiple scripts accessing serial port at the same time.

You also need to parse the response because the reply will contain some additional characters.
This should log raw response of temperature value.
Code:
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 val\r')
res, err = readack()
log(res, err)
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 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: