How do I dynamically enable or disable config nodes?

I have edited this message.

So this is my flow

[{"id":"ce085873429da727","type":"serial out","z":"5166dd2a7e38940b","name":"","serial":"bbc414bb7e1feaec","x":430,"y":340,"wires":[]},{"id":"ee4d246d01114515","type":"inject","z":"5166dd2a7e38940b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":290,"y":80,"wires":[["d079711f78c1baa8"]]},{"id":"d079711f78c1baa8","type":"function","z":"5166dd2a7e38940b","name":"","func":"msg.payload={ 'fc': 3, \n              'unitid': 3, \n              'address': 0 , \n              'quantity': 3 };   \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":140,"wires":[["5db00c229ce0e15c"]]},{"id":"5db00c229ce0e15c","type":"modbus-flex-getter","z":"5166dd2a7e38940b","name":"","showStatusActivities":true,"showErrors":true,"logIOActivities":false,"server":"64e234ec8ad4b896","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":290,"y":180,"wires":[["4efbfd818ce4af96"],[]]},{"id":"4efbfd818ce4af96","type":"debug","z":"5166dd2a7e38940b","name":"sensor 3 raw data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":290,"y":240,"wires":[]},{"id":"add795f329a38cb4","type":"inject","z":"5166dd2a7e38940b","name":"\"string\", \" 0x3d\", \" 0x10\", 17","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\"0x68\", \" 0x03\", \" 0x01\", \" 0x00\", \" 0x22\", \" 0xab\", \" 0x04\", \" 0x9b\", \" 0x04\", \" 0x4b\", \" 0xc1\", \" 0x01\", \" 0x48\", \" 0x3d\", \" 0x4b\", \" 0xc1\", \" 0x01\", \" 0x48\", \" 0x3e\", \" 0x4a\", \" 0x3a\", \" 0x4b\", \" 0x3a\", \" 0x4b\", \" 0x3a\", \" 0x4a\", \" 0xc1\", \" 0x01\", \" 0x4b\", \" 0xc0\", \" 0x01\", \" 0x47\", \" 0x3e\", \" 0x48\", \" 0x3d\", \" 0x4b\", \" 0xc1\", \" 0x01\", \" 0x4b\", \" 0xc1\", \" 0x01\", \" 0x4a\", \" 0x3b\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x4a\", \" 0x3b\", \" 0x4a\", \" 0xc1\", \" 0x01\", \" 0x47\", \" 0x3e\", \" 0x4a\", \" 0x3b\", \" 0x4a\", \" 0x3b\", \" 0x4a\", \" 0x3b\", \" 0x4a\", \" 0x3b\", \" 0x4d\", \" 0x38\", \" 0x4a\", \" 0xc1\", \" 0x01\", \" 0x4a\", \" 0xc2\", \" 0x01\", \" 0x47\", \" 0xc4\", \" 0x01\", \" 0x4a\", \" 0xc1\", \" 0x01\", \" 0x47\", \" 0xc5\", \" 0x01\", \" 0x4a\", \" 0xc2\", \" 0x01\", \" 0x47\", \" 0xc5\", \" 0x01\", \" 0x4a\", \" 0xc2\", \" 0x01\", \" 0x46\", \" 0xc5\", \" 0x01\", \" 0x46\", \" 0xc5\", \" 0x01\", \" 0x46\", \" 0xc5\", \" 0x01\", \" 0x46\", \" 0xc5\", \" 0x01\", \" 0x49\", \" 0xc2\", \" 0x01\", \" 0x46\", \" 0xc5\", \" 0x01\", \" 0x46\", \" 0xc5\", \" 0x01\", \" 0x46\", \" 0xc5\", \" 0x01\", \" 0x46\", \" 0x3f\", \" 0x49\", \" 0xc2\", \" 0x01\", \" 0x46\", \" 0x3f\", \" 0x46\", \" 0x3f\", \" 0x4a\", \" 0x3b\", \" 0x46\", \" 0xc5\", \" 0x01\", \" 0x46\", \" 0xc5\", \" 0x01\", \" 0x46\", \" 0x3f\", \" 0x46\", \" 0x86\", \" 0x05\", \" 0xa7\", \" 0x04\", \" 0xa0\", \" 0x04\", \" 0x46\", \" 0x3f\", \" 0x46\", \" 0xc6\", \" 0x01\", \" 0x46\", \" 0x40\", \" 0x45\", \" 0xc6\", \" 0x01\", \" 0x45\", \" 0xc6\", \" 0x01\", \" 0x45\", \" 0xc6\", \" 0x01\", \" 0x45\", \" 0xc6\", \" 0x01\", \" 0x45\", \" 0x40\", \" 0x45\", \" 0x40\", \" 0x45\", \" 0xc6\", \" 0x01\", \" 0x45\", \" 0xc6\", \" 0x01\", \" 0x45\", \" 0x40\", \" 0x45\", \" 0x40\", \" 0x45\", \" 0xc6\", \" 0x01\", \" 0x44\", \" 0xc7\", \" 0x01\", \" 0x42\", \" 0xca\", \" 0x01\", \" 0x42\", \" 0xca\", \" 0x01\", \" 0x42\", \" 0x44\", \" 0x41\", \" 0xca\", \" 0x01\", \" 0x41\", \" 0xca\", \" 0x01\", \" 0x41\", \" 0xca\", \" 0x01\", \" 0x41\", \" 0xca\", \" 0x01\", \" 0x41\", \" 0xca\", \" 0x01\", \" 0x41\", \" 0xcd\", \" 0x01\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x48\", \" 0x3d\", \" 0x48\", \" 0x3d\", \" 0x48\", \" 0x3d\", \" 0x48\", \" 0x3d\", \" 0x48\", \" 0x3d\", \" 0xce\", \" 0x01\", \" 0x3d\", \" 0x48\", \" 0x3d\", \" 0xce\", \" 0x01\", \" 0x3d\", \" 0xce\", \" 0x01\", \" 0x3d\", \" 0xce\", \" 0x01\", \" 0x3d\", \" 0x48\", \" 0x3d\", \" 0x48\", \" 0x3d\", \" 0xcf\", \" 0x01\", \" 0x3d\", \" 0x10\", \" 0x16\"]","payloadType":"bin","x":220,"y":320,"wires":[["ce085873429da727","d6572391d59bb2cb"]]},{"id":"d6572391d59bb2cb","type":"debug","z":"5166dd2a7e38940b","name":"17 [\"0x68\", \"0x03\" ,]","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":450,"y":300,"wires":[]},{"id":"bbc414bb7e1feaec","type":"serial-port","serialport":"/dev/ttyUSB0","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","waitfor":" ,","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"1","bin":"bin","out":"time","addchar":"","responsetimeout":"10000"},{"id":"64e234ec8ad4b896","type":"modbus-client","name":"RS485-1","clienttype":"simpleser","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB0","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"0x3A","unit_id":1,"commandDelay":200,"clientTimeout":1000,"reconnectOnTimeout":true,"reconnectTimeout":2000,"parallelUnitIdsAllowed":true}]

I want to have only one RS485 to usb connecter to control both serial and modbus device right now because 1 converter can have 255 devices connected to it and I only have less then 10 devices that is needed to connected to the RS485.

I need to dynamically connect and disable the config nodes of modbus and serial

As when I connect one the other onedon't work/can't connect as the port is being used by the other config node. I use serial to write and modbus to read.

An example of the error I see when I try to to enable my serial node it shows connected but gives me this error as its config node can't work as it says the port is being used when modbus config node is connected thus it can read my sensors data.
image
image

Also when serial can write data as it config node is connected. Modbus config node can't connect .
image

i am not sure, may be you could enable or disable dynamically both! for example, only when you are writing, disable modbus node, if you are not writing, so enable modbus node, and disable serial node...

Great idea I will try disable and enable the config node so the port will be "free" for my other connection.

I will change the title to that

It may not be posible for me to dynamiclly enable/disable nodes

1 Like

I think you are overcomplicating things by trying to enable/disable nodes .. it is much easier to put a logical true/false switch in front of the node in question and you are done

Thanks I will try that.

But the issue above is that I only have one usb port and thus only one config node can connect to it at any given time both my serial and modbus need their config node to be connected to the usb port for the node to work.

I do know a easy fix is to have 2 usb to rs485 converter so I have 2 usb port that both config node can be connected to but the whole point of RS485 is that I can have 1 port to control 255 devices over some distant using wires. I am using less than 255 devices so if I have more than 1 usb to rs485 converter it seems strange.

Understood... but enable/disable is just a workaround.

As your issue is with rs485/modbus multi-device management/communication ..you may have to re-post towards RS485/Modbus topic :wink: I'm sure there will be some experts to help you with the root cause

e.g. here or here or here

It looks like others have solved the multi-device issues

ok I have reposted this qn on modbus topic How do I have diffrent nodes modbus and serial node use the same usb port?

I look through the links you have sent thanks. I now know how to solve some problems I have before.

But all links you have shown only use modbus node https://flows.nodered.org/node/node-red-contrib-modbus.
Which doesn't solve my problem as I am trying to use https://flows.nodered.org/node/node-red-node-serialport which as I say again both config node is trying to fight for the same port

Sorry, I only worked on rs485/Modbus on industrial solutions. Usually, having several devices on rs485 you have to use he same protocoll to adress em. why would you need to send a raw serial packet onto rs485 .. you should do that with Modbus only.

if my memory is correct, there was a modbus-serial cmd which enabled you to send a serial package via modbus

Hello!
This caught my attention, too. I'm working with Siemens S7 PLCs (with node-red-contrib-s7) and I'm trying the following: if the S7 doesn't give any signal (i.e. using the Trigger node), go ahead and deactivate the config node for that PLC. We have so many PLC nodes and config nodes that we don't want to overflow the page with connection/production errors.
I'm trying to write some code and I will upload it as soon as it makes some sense.

Hope you can help.

1 Like

Which page?

I see why that can be confusing. For the sake of simplicity I would encourage you to ignore the part you are refering to. I simply want to:

if the S7 doesn't give any signal (i.e. using the Trigger node), go ahead and deactivate the config node for that PLC.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.