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.

RS485 repetative string
#3
(01.07.2022, 14:50)admin Wrote: Do you have any other scripts accessing the same port? Only a single script can access the port at any time.
Also the reading part does not seem correct. Usually the data should be read one byte at a time, at least to the point where a message starting point is found. But this all depends on how the protocol is designed. Do you have a protocol description for this device?

Hi admin!

Thank you for your help !

I made sure that this is the only script accessing this port...and read the blind specification...

And finally realized that the cause was in my code.... the valiable "value" in str2hex() keep storing all results and this made the message looks repetative. I wrote this in the resident script  Cry

So there is nothing wrong with the blind and its specification Rolleyes

I can fix this now.... thank you so much for your help always ! 

Code:
function str2hex(str)
    raw_len = string.len(str)
    i = 1
  while i <= raw_len do
    current_hexvalue = '0x' .. string.format("%02x", string.byte(str, i))
    if value then     -- this "value" keep storing all results
      value = value .. ', ' .. current_hexvalue
    else
        value = current_hexvalue
    end
    i = i + 1
  end
  return value
end
Reply


Messages In This Thread
RS485 repetative string - by Hadeel - 01.07.2022, 12:05
RE: RS485 repetative string - by admin - 01.07.2022, 14:50
RE: RS485 repetative string - by Hadeel - 02.07.2022, 19:05

Forum Jump: