node-red-nodes icon indicating copy to clipboard operation
node-red-nodes copied to clipboard

node-red-node-serialport message duplication

Open mima232 opened this issue 1 year ago • 3 comments

Which node are you reporting an issue on?

node-red-node-serialport serial control node

What are the steps to reproduce?

Just send enable two or more times to control node

What happens?

All serial nodes that have output and are configured for the same port will emit multiple same messages according to number of issued enables

What do you expect to happen?

I expect to emit the unique message only one time

I've tried it with usb serial and with native rs232, both same behaviour.

  • Node-RED version: 3.1.9
  • node.js version: 20.13.1
  • npm version: 10.5.2
  • Platform/OS: Ubuntu 24.04 LTS
  • Browser: Chrome

mima232 avatar May 22 '24 08:05 mima232

Have more or less the same issue with Node-Red 4.05 and node-red-node-serialport 2.0.3 on Windows 11:

If the serial port was disabled using "Serial Control" Node, the next time it is enabled, "Serial in" outputs each message twice or more times. The only way to stop it is to change some configurations in "Serial Port" Configuration node and restart the flow.

syoma755 avatar Oct 16 '24 07:10 syoma755

Could be event handlers not being removed or being (re)added a second, third time upon re-connection.

@syoma755 Would you confirm something please?

  • deploy
  • confirm single messages
  • disconnect / connect via "Serial Control"
  • confirm duplicate messages
  • disconnect / connect via "Serial Control"
  • confirm triplicate messages
  • and so on

That would help us investigate the issue.

Steve-Mcl avatar Oct 16 '24 08:10 Steve-Mcl

Hi Steve

Just tried to reproduce it.

Sequence 1:

  • Started Node-Red from command Line

  • COM Port was connected automatically at flow start - both 'serial in' and 'serial out' show green 'connected' status

  • Sent single message over 'serial out'

  • Single messages received at 'serial in'

  • Sent {"enabled":true} payload to 'serial control'

  • output of 'serial control': {"serialport":"COM11","serialbaud":3000000,"databits":8,"parity":"none","stopbits":1,"dtr":"none","rts":"high","cts":"none","dsr":"none","enabled":true}

  • 'serial control' status stays green

  • 'serial in' became grey - not connected

  • Sent single message over 'serial out'

  • Double messages received at 'serial in'

  • Sent {"enabled":true} payload to 'serial control' once more

  • Output of 'serial control': {"serialport":"COM11","serialbaud":3000000,"databits":8,"parity":"none","stopbits":1,"dtr":"none","rts":"high","cts":"none","dsr":"none","enabled":true}

  • 'serial control' status stays green

  • 'serial in' stays grey - not connected

  • Sent single message over 'serial out'

  • Triple messages received at 'serial in' ...

  • sent few times {"enabled":true} payload to 'serial control'

  • the number of received messages to single requests at 'serial in' increases proportionally. 'serial in' shows grey status.

Sequence 2:

  • Started Node-Red from command Line

  • COM Port was connected automatically at flow start - both 'serial in' and 'serial out' show green 'connected' status

  • Sent single message over 'serial out'

  • Single messages received at 'serial in'

  • Sent {"enabled":false} payload to 'serial control'

  • Output of 'serial control': {"serialport":"COM11","serialbaud":3000000,"databits":8,"parity":"none","stopbits":1,"dtr":"none","rts":"high","cts":"none","dsr":"none","enabled":false}

  • 'serial control' status become gray - stopped

  • Both 'serial in' and 'serial out' become grey - stopped

  • Sent {"enabled":true} payload to 'serial control'

  • Output of 'serial control' {"serialport":"COM11","serialbaud":3000000,"databits":8,"parity":"none","stopbits":1,"dtr":"none","rts":"high","cts":"none","dsr":"none","enabled":true}

  • 'serial control' status become green

  • 'Serial in' shows green -connected status, 'serial out' shows grey - stopped status.

  • Sent single message over 'serial out'

  • Single messages received at 'serial in'

  • Sent {"enabled":true} payload to 'serial control'

  • output of 'serial control': {"serialport":"COM11","serialbaud":3000000,"databits":8,"parity":"none","stopbits":1,"dtr":"none","rts":"high","cts":"none","dsr":"none","enabled":true}

  • 'serial control' status stays green

  • 'Serial in' shows grey - not connected status, 'serial out' shows grey - stopped status.

  • 'serial in' became grey - not connected

  • Sent single message over 'serial out'

  • Double messages received at 'serial in'

  • further behaiviour same as in sequence 1.

Please note that also after disabling and enabling the serial port in Sequence two, I'm sometimes also get duplicated messages, but can not reproduce it reliably. Usually if 'serial in' becomes grey - not connected, after port enabling (even if node-red console shows that COM is connected), I will get duplicated messages. Especially if some other program was using this serial port in between.

Hope it helps to debug the issue.Let me know if

syoma755 avatar Oct 17 '24 06:10 syoma755