Skip to content

Commit c847e4c

Browse files
committed
Fix: Now able to receive packets of max size 256
1 parent 298448e commit c847e4c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/ArduinoSerialToTCPBridgeClient.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ size_t ArduinoSerialToTCPBridgeClient::write(const uint8_t *buf, size_t size) {
135135
if (!writePacket(lastTx_cmd, lastTx_buf, lastTx_size)) {
136136
return 0;
137137
}
138-
138+
139139
ackOutstanding = true;
140140
startAckTimer();
141141

@@ -219,7 +219,7 @@ boolean ArduinoSerialToTCPBridgeClient::writePacket(uint8_t command, uint8_t* pa
219219
}
220220

221221
void ArduinoSerialToTCPBridgeClient::rxCallback(uint8_t c) {
222-
static uint8_t packetCount = 0;
222+
static uint16_t packetCount = 0;
223223
static uint8_t rxState = RX_PACKET_IDLE;
224224

225225
rxBuffer[packetCount++] = c;
@@ -237,8 +237,9 @@ void ArduinoSerialToTCPBridgeClient::rxCallback(uint8_t c) {
237237
case RX_PACKET_GOTCOMMAND:
238238
uint8_t packetLength = rxBuffer[0];
239239

240-
if (packetCount == packetLength + 1) {
240+
if (packetCount == (uint16_t)packetLength + 1) {
241241
packetCount = 0;
242+
rxState = RX_PACKET_IDLE;
242243

243244
// Integrity checking.
244245
uint32_t crcRx = (uint32_t) rxBuffer[packetLength - 3] | ((uint32_t) rxBuffer[packetLength - 2] << 8)
@@ -282,7 +283,6 @@ void ArduinoSerialToTCPBridgeClient::rxCallback(uint8_t c) {
282283
break;
283284
}
284285
}
285-
rxState = RX_PACKET_IDLE;
286286
}
287287
break;
288288
}

0 commit comments

Comments
 (0)