uint8_t SerialTransfer::available() Description: ------------ * Parses incoming serial data, analyzes packet contents, and reports errors/successful packet reception Inputs: ------- * void Return: ------- * uint8_t bytesRead - Num bytes in RX buffer */
| 85 | * uint8_t bytesRead - Num bytes in RX buffer |
| 86 | */ |
| 87 | uint8_t SerialTransfer::available() |
| 88 | { |
| 89 | bool valid = false; |
| 90 | uint8_t recChar = 0xFF; |
| 91 | |
| 92 | if (port->available()) |
| 93 | { |
| 94 | valid = true; |
| 95 | |
| 96 | while (port->available()) |
| 97 | { |
| 98 | recChar = port->read(); |
| 99 | |
| 100 | bytesRead = packet.parse(recChar, valid); |
| 101 | status = packet.status; |
| 102 | |
| 103 | if (status != CONTINUE) |
| 104 | { |
| 105 | if (status <= 0) |
| 106 | reset(); |
| 107 | |
| 108 | break; |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | else |
| 113 | { |
| 114 | bytesRead = packet.parse(recChar, valid); |
| 115 | status = packet.status; |
| 116 | |
| 117 | if (status <= 0) |
| 118 | reset(); |
| 119 | } |
| 120 | |
| 121 | return bytesRead; |
| 122 | } |
| 123 | |
| 124 | |
| 125 | /* |
no test coverage detected