Skip to content

Commit

Permalink
Enc28J60Network: fix hang of enc28j60 when sending empty (handle == N…
Browse files Browse the repository at this point in the history
…OBLOCK) packet
  • Loading branch information
ntruchsess committed Oct 9, 2014
1 parent 38c5e7e commit c37970b
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions utility/Enc28J60Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,20 @@ Enc28J60Network::receivePacket()
// read the receive status (see datasheet page 43)
rxstat = readOp(ENC28J60_READ_BUF_MEM, 0);
//rxstat |= readOp(ENC28J60_READ_BUF_MEM, 0) << 8;
#ifdef ENC28J60DEBUG
Serial.print("receivePacket [");
Serial.print(readPtr,HEX);
Serial.print("-");
Serial.print((readPtr+len) % (RXSTOP_INIT+1),HEX);
Serial.print("], next: ");
Serial.print(nextPacketPtr,HEX);
Serial.print(", stat: ");
Serial.print(rxstat,HEX);
Serial.print(", count: ");
Serial.print(readReg(EPKTCNT));
Serial.print(" -> ");
Serial.println((rxstat & 0x80)!=0 ? "OK" : "failed");
#endif
// decrement the packet counter indicate we are done with this packet
writeOp(ENC28J60_BIT_FIELD_SET, ECON2, ECON2_PKTDEC);
// check CRC and symbol errors (see datasheet page 44, table 7-3):
Expand Down Expand Up @@ -201,6 +215,8 @@ Enc28J60Network::blockSize(memhandle handle)
void
Enc28J60Network::sendPacket(memhandle handle)
{
if (handle == NOBLOCK)
return;
memblock *packet = &blocks[handle];
uint16_t start = packet->begin-1;
uint16_t end = start + packet->size;
Expand All @@ -215,10 +231,10 @@ Enc28J60Network::sendPacket(memhandle handle)
Serial.print("sendPacket(");
Serial.print(handle);
Serial.print(") [");
Serial.print(start);
Serial.print(start,HEX);
Serial.print("-");
Serial.print(end);
Serial.println("]:");
Serial.print(end,HEX);
Serial.print("]: ");
for (uint16_t i=start; i<=end; i++)
{
Serial.print(readByte(i),HEX);
Expand Down

1 comment on commit c37970b

@ntruchsess
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixes #93 #92 #90 #88 #75 #71 #63

Please sign in to comment.