Skip to content

Commit b6dfa0f

Browse files
committed
Enc28J60Network::writePacket - don't write zero length
1 parent b40a04c commit b6dfa0f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/utility/Enc28J60Network.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,16 @@ Enc28J60Network::writePacket(memhandle handle, memaddress position, uint8_t* buf
302302
memblock *packet = &blocks[handle];
303303
uint16_t start = packet->begin + position;
304304

305+
if (len > packet->size - position)
306+
len = packet->size - position;
307+
308+
if (len == 0)
309+
return 0;
310+
305311
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
306312

307313
writeRegPair(EWRPTL, start);
308314

309-
if (len > packet->size - position)
310-
len = packet->size - position;
311315
writeBuffer(len, buffer);
312316

313317
SPI.endTransaction();

0 commit comments

Comments
 (0)