Search code examples
serial-portcustom-protocol

Serial Port device protocol safe practice: Identification, polling


I'm creating a simple device that sends data to a Windows PC over serial COM ports.

I'd like the software to be able to scan the available COM ports until it recognizes the device. The problem is, if the PC tries to initiate the handshake with a device other than mine, it may interpret the commands [wrongly, of course].

The only solution I see is for my device to periodically broadcast some sort of identifier, perhaps 5 times per second or so, so the application only needs to listen for that identifier rather than risk corrupting another device also connected to a COM port. When the application loads, it listens on each available COM port until the device is recognised. Does this sound reasonable?

Thanks


Solution

  • IMO whatever the direction on which you initiate the handshake, the problem will be the same. If you send your handshake from your device and another application on your PC is listening to the corresponding serial port, it also has risks to badly interpret the data you are sending.

    So I would say that software on both side should be protected against incoherent data they receive from the outside.