node-serialport icon indicating copy to clipboard operation
node-serialport copied to clipboard

Feature request: Add an option to disable buffering writes to a closed port

Open maxwellhadley opened this issue 7 years ago • 3 comments

  • SerialPort Version: 6.2.0

  • NodeJS Version: N/A

  • Operating System and Hardware Platform: N/A

  • Have you checked the right version of the api docs?: N/A

  • Are you having trouble installing and you checked the Installation Special Cases docs? N/A

  • Are you using Electron and have you checked the Electron Docs?: N/A

I have a device which is only intermittently connected, and requires a specific handshake sequence each time it is connected. The user may disconnect it without warning. Although I now test the isOpen property before every write, there is a race condition where a device disconnect occurs between the property access and the write, which results in the write being buffered. The next time the device is connected, the handshake sequence is not correct, because of the buffered write.

This could be avoided by adding a Serialport constructor option to disable buffering of writes to a closed port.

maxwellhadley avatar Jul 05 '18 08:07 maxwellhadley

Seems reasonable

On Thu, Jul 5, 2018, 4:08 AM Max Hadley [email protected] wrote:

SerialPort Version: 6.2.0

NodeJS Version: N/A

Operating System and Hardware Platform: N/A

Have you checked the right version of the api docs?: N/A

Are you having trouble installing and you checked the Installation Special Cases docs? N/A

Are you using Electron and have you checked the Electron Docs?: N/A

I have a device which is only intermittently connected, and requires a specific handshake sequence each time it is connected. The user may disconnect it without warning. Although I now test the isOpen property before every write, there is a race condition where a device disconnect occurs between the property access and the write, which results in the write being buffered. The next time the device is connected, the handshake sequence is not correct, because of the buffered write.

This could be avoided by adding a Serialport constructor option to disable buffering of writes to a closed port.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/node-serialport/node-serialport/issues/1593, or mute the thread https://github.com/notifications/unsubscribe-auth/AABlbgXV3_kROs4dcMYCKo_bCsy0J_HXks5uDcmKgaJpZM4VDbYy .

reconbot avatar Jul 05 '18 14:07 reconbot

I have the similar question that my server read data from serialport every 30s,but about 100 times after,the data will be wrong because of the buffer data. so if there are a option to clear bufffer every time will be good, i think

zoedepsi avatar Jul 06 '18 02:07 zoedepsi

Any chance of looking at this now, after the great re-organisation?

maxwellhadley avatar Jul 08 '20 08:07 maxwellhadley