What does "timeouts are used to physically disconnected by the device" in serial (RS232) communications?

52 Views Asked by At

I'm implementing serial protocol that states that after sending a particular byte, the emitter must wait X seconds to receive a response and if no response is received within the specified time, communication must timeout.

In the doc, it states: "Time-outs are used to physically disconnect the line."

But what does "physically disconnect the line" mean in pratical terms?

I see two possibilities.

  • clear my reception stream and revert to initial state in communication
  • or "Closing the port / reopening it" but I don't see any particular need in this operation since If i close my COM Port, the device in other end of the line wont know that the port com was closed on my side. Or am I wrong?
1

There are 1 best solutions below

0
Lothre1 On

So, I would like to provide some precisions from what I could conclude after having completed the implementation.

The citation is in my opinion totally inaccurate which can lead to confusion.

The communication is composed by different states when starting a communication session as master, same goes for slave.

Here are the states from master perspective:

  • initial state (not receiving and not sending) - Nothing is going on... At this phase we can become master or slaves at any time

Becoming a master:

  1. send byte to ask if we can init communication (wait x ms then reset if nothing is received)
  2. waiting_for_ack: wait x ms then reset if nothing is received
  3. if ack was received send data command and enter wait_for_data_ack for X ms. If no response, reset.

By reset I mean revert to initial state. And if you desire retry a few seconds later to init the communication.