Project

General

Profile

Statistics
| Revision:

root / proj / doc / protocol2.md

History | View | Annotate | Download (2.69 KB)

1 252 up20180642
# Non-critical serial port protocol
2
3
Transmission/reception is processed at 38400 bps, with chars of 8 bits and even parity.
4
5
OK = 0xFF
6
7
FAIL = 0x00
8
9
## Transmission
10
11
Transmission is performed on request by the program. It is done in a synchronous fashion. When starting a transmission, reception interrupt notifications are suspended. On ending, reception interrupt notifications are re-activated.
12
13
### Transmission of a char
14
15
1. 1 polls the readiness of THR in intervals of 10 microseconds, one at the beginning and up to 2 retries (up to 3 polling operations, and 20 microseconds). If after all the retries 1 has not yet sent the char, transmission is aborted.
16
17
2. If the char is transmitted, 1 expects 2 to answer with OK. 1 polls the fullness of RBR in intervals of 10 microseconds, one at the beginning and up to 2 retries. If after all the retries 1 has not yet received the answer, transmission is aborted.
18
19
3. If 1 gets the answer, it counts the number of 1s. If #1 > 4, it is considered that it was accepted. Otherwise, it attempts to resend another 2 times.
20
21
### Transmission of a string
22
23
If the string has more than 1024 chars, transmission is not even started.
24
25
1. For each char in the string, transmit them, plus a start symbol 0x80 and an end symbol 0xEF. If transmission fails for a given char, transmission of the string is aborted, and none of the following chars in the same transmission request are transmitted. The transmitter waits at least
26
27
2. If all symbols are transmitted correctly, transmission is successfully terminated.
28
29
## Reception
30
31
Reception is made through interrupts. On a reception interrupt, 2 must handle the interrupt. On a reception interrupt, reception interrupt notifications are suspended, and on ending a reception notifications are re-activated.
32
33
### Reception of a char
34
35
1. Upon getting a reception interrupt, 2 grabs the char, and then polls the readiness of the THR in intervals of 10 microseconds, one at the beginning and up to 2 retries. If after 2 retries 2 has not sent the char, transmission is aborted.
36
37
2. If transmission is successful, 2 expects 1 to answer the OK symbol 0xFF, using only step 1. to get the OK. If the received symbol has less or equal to 4 bits set to 1, transmission is aborted.
38
39
3. If the received OK has at least 4 bits set to 1 then it is accepted.
40
41
### Reception of a string
42
43
1. 2 expects the first char to be the start char. If it is not, transmission is aborted.
44
45
2. If the first char is correct, all chars are received. If one of the char receptions fails (timeout), reception fails. If after receiving 1024 chars the end symbol is not received, transmission is aborted.
46
47
3. If all receptions are successful and the end symbol is received, transmission is successful.