MCPcopy Create free account
hub / github.com/PowerBroker2/SerialTransfer / available

Method available

src/SerialTransfer.cpp:87–122  ·  view source on GitHub ↗

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 */

Source from the content-addressed store, hash-verified

85 * uint8_t bytesRead - Num bytes in RX buffer
86*/
87uint8_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/*

Callers 2

processDataMethod · 0.80
resetMethod · 0.80

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected