Codec Freedom -- Specifications -- RS-232 bit-shifting protocol
Given that bits can be sent, a translation is needed to byte sending. A protocol based on RS-232 will do this. It includes a RESET signal for byte-level processing, based on RS-232 break..
General RS-232 paramaters
We use RS-232 as follows:
- 8 bits of data
- No parity
- A minimum of 1 stop bit
- Bitrate is determined by the underlying bitmode protocol
- Line break translates to a RESET signal for upper layers
Processing incoming bits
When an incoming symbol from a bitmode protocol holds serial bits, they
are considered as incoming bits on a serial line. When multiple bits
are available in the incoming symbol, they are considered to have arrived
in the order from the most significant bit position to the least significant
bit position of the symbol that arrived. So, a symbol 254 whose lowest
two values represent bits will trigger a got "1"
event followed by a
got "0"
event.
The incoming side of the bitmode protocols provide bits, usually one
at a time, and map to got X
events in the following state diagram.
The start state for this diagram is Reset
and it has no final state:
At some point, the line will have got "1"
which it considers a stop bit;
the state moves to Stopped
and any further got "1"
events are consumed as
superfluous stop bits; apparently, no data is offered in the available
bandwidth. Once a got "0"
event is triggered, the state becomes Started
and the next got X
events encode 8 bits of data, starting at the least
significant bit.
After all 8 bits have been received, the final judgement is passed by the
next bit event; if it is got "1"
then this is a stop bit then the byte
is passed up and the state returns to Stopped
. If it is got "0"
then
the other side appears to be sending a break, and the local state will
send a RESET
signal up, and change the state to Reset
to catch any
further got "0"
bits before returning to the submission of stop bits.
The upper layer must not respond to a RESET
signal by sending one
itself, that would lead to an endless loop. The RS-232 level protocol
provides a facility for passing the RESET
signal from a party that
has decided to reset to a party that needs to follow this change.
Producing outgoing bits
When outgoing symbols in a bitmode protocol can hold a bit of data,
the value to be sent is determined by the downward serial protocol.
When an outgoing symbol can contain multiple bits, then the most
significant bit position is filled from the first send X
action,
and the least significant bit position is filled last.
The outgoing side of the bitmode protocols accepts to-be-sent bytes from
an upper layer, and produces a series of send X
actions, as depicted
in the following state diagram. The start state for this diagram is
Initiation
and it has no final state:
The line does send "1"
to produce stop bits, until the upper layer
provides a byte for the got B7-B0
event. It then starts off with
a send "0"
action to cause a start bit, and then sends out the bits
of the byte, least significant bit first. Note how the order is the
opposite of the bit-insertion mode.
Before and after sending the byte, the protocol checks if RESET
was provided by the upper layer. If so, the current byte is not
finished, and a first send "0"
initiates the line break condition
of RS-232. This condition executes at least 10 send "0"
actions
before it returns to the normal Stopped
state. Note how a
confirmation to they upper layer confirms whether a byte was sent
or not; this may aid in the handling of an otherwide asynchronous
RESET
signal.
The upper layer must only send a RESET
signal if it has locally
discovered an error condition that requires it to return to a known
stable state. The RS-232 level protocol instructs the other side
to also return to this state, but the other side will not confirm
this by returning a RESET
signal. Note how the detection of a
RESET
before the proper finish of a byte send ensures that a
byte that is in transit will not be completed properly, and so it
will not pop out at the other side. The upward signal RESDONE
confirms that a reset has been completed; before this event is
sent to the upper layer protocol, bytes received must not be
processed as though they were received after the RESET
signal.
Bit-modes are 8-bit clean
The service level that this RS-232 protocol provides to the upper layer data and codec layers is the following:
-
No intervention with the constant pace at which the bit-inserted codec passes through the underlying bit-insertion protocol.
-
An 8-bit clean protocol, so binary data can be carried. In practice, this means that transfer-encoding such as base64 is needed when carrying binary data over the byte-level protocol.
-
A data resynchronisation facility through
RESET
signaling to the other side. -
Data transmission at an unpredictable rate, but one that will usually continue reasonably consistently. Average transmission rates depend on the actual bitmode protocol into which the bits are inserted.
The same facilities will be provided by the packet mode protocols, so the upper layer protocols can rely on these properties without knowing if the underlying transport is a bit-insertion or packet mode.