Trouble injecting a node

Hi,

I am trying to communicate to a modbus device using node red. The modbus device can only handle one request every 500 ms. My logic is working ok but it has issue initiating communication in the begining. The only way I am able to initiate communication is by using inject node and injecting a timestamp. Once the communication is initiated then everything works ok as per my script. Now I was hoping to use a "connect" button to inject timestamp and initiate comms but its not working. I checked the payload of my "connect" button and its identical to the inject node. So I dont understand why I am having issues.

node-red inject issue - 1

node-red inject issue - 2

Set both debug nodes to Output complete message.

image

Try adding a change node between the button and ā€˜read 45ā€¦ā€™ function node. In the change node delete msg.event and see what happens.

1 Like

Good idea. I just did that, now my message is identical to inject node and still it wont start the communication:

image

it seems the "socketid" format is quite different between the inject node (which is injecting timestamp) and the connect node (which is now connected to change node based on @zenofmud suggestion. I guess socket id would be different but dont know why they have different format of socket id.

Not quite, there is no topic. Not sure if/how this would make a difference but it's worth a try

I deleted both topic and event from the message:

image

Still no change :(.

Sorry I meant that in the output shown in the images above the inject node has a topic but the connect button does not, Try adding a topic to the connect button. As I said I cannot see how this would make a difference but...

Sorry, my bad. Alright I just made that change and still no effect:

image

Guess I am out of options now ...

What happens if you disconnect the button from the function node directly next to it?

1 Like

@Colin That's it. This change did the trick! Thank you!

I basically added one more button. So I use one to set IP address for my modbus connector node and then second one for initiating connection. here is the solution.

image

Do you want to do it like that or do you want it automated? If you have something that has to run on startup then you can use an Inject node set to fire on startup.

Can't you set the IP in the getter node, or is it not always the same?

the device node-red will be talking to can have different IP. So I dont want it automated. Moreover, I am reading from different address location so managing that with a specific interval set within inject node is not ideal. Rest of my logic is working ok. I verified using wireshark!

Thanks again!

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