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.

write to modbus with bitmask
#3
(09.02.2022, 07:52)admin Wrote: The value that you are writing has both bits 0 and 2 set which the Modbus device might reject. Log the returned write result. It might have an error indication.
Code:
value = 4 -- bit 2 set to 1
res, err = mb:writeregisters(33471, value)
log(res, err)

Also keep in mind that using scripts can lead to random errors if two scripts try to access the same serial port in parallel. It is recommended to use profiles instead.

Hi Admin,

I tried the above and this is the result in de errorlog:
"* arg: 1
  * nil
* arg: 2
  * string: Illegal function"

Do you have tips where to move ahead? 
I also have a modbus profile in place (attached) and this works great for reading values, I didn't yet try to use this for writing values.

Greets,
Jeroen
* arg: 1
  * nil
* arg: 2
  * string: Illegal function
* arg: 1
  * nil
* arg: 2
  * string: Illegal function

Attached Files
.json   Clint_test_modbus.json (Size: 3.51 KB / Downloads: 11)
Reply


Messages In This Thread
RE: write to modbus with bitmask - by admin - 09.02.2022, 07:52
RE: write to modbus with bitmask - by jeroen@stevens.biz - 09.02.2022, 22:09
RE: write to modbus with bitmask - by admin - 10.02.2022, 08:25
RE: write to modbus with bitmask - by admin - 11.02.2022, 08:03

Forum Jump: