BiancoRoyal / node-red-contrib-modbus

maintained by PLUS for Node-RED - https://plus4nodered.com
https://www.npmjs.com/package/node-red-contrib-modbus
BSD 3-Clause "New" or "Revised" License
278 stars 107 forks source link

Support for sending raw modbus messages #350

Closed brolaugh closed 1 year ago

brolaugh commented 1 year ago

Describe the requested feature

I'm currently trying to use a relay in NodeRED using this lib but it appears that the relay that I'm using isn't 100% modbus compatible. However by sending the raw bytes on the modbus TTY (in a python script) I'm able to flip the relay and get CRC validated responses. Here's an example of the of "modbus commands" that I send to close and open relay channel one.

0b 05 00 01 00 00

0b 05 00 01 FF 00

For me personally the alternative would be to entirely drop this lib start utilizing the exec nodes to control my relay which I'd rather not do.

Motivation

It appears that going outside of the modbus spec as been requested before and I guess this would be going a bit further than the previously mentioned feature request.

biancode commented 1 year ago

Hi @brolaugh or in your case you could give node-modbus-serial (modbus-serial npm) a try how it works with a simple script with that lib. If it works well and needs some special code, then you could give that lib as global lib into node-red via the settings file and use the function node of node-red to use your working code fragment inside node-red. Please, let me know if or how it works for you with that hint! Happy coding!

biancode commented 1 year ago

DEBUG=*modbus* node-red -v can show you what we send to the TTY and what you get back

biancode commented 1 year ago

You could also set the NODE_DEBUG env variable to include the regex of modbus see this article

brolaugh commented 1 year ago

Playing around a little with node-modbus-serial made me realize that I can just set each induvidual relay channel(coil) with separate commands and that way get around the modbus incompatible parts. Was unsuccessful in setting all the relay channels (coils) at once thought since that was incompatible with modbus.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 60 days with no activity. It will be closed in 30 days, but can be saved by removing the stale label or commenting.