@@ -168,6 +168,20 @@ Enc28J60Network::receivePacket()
168168 // read the receive status (see datasheet page 43)
169169 rxstat = readOp (ENC28J60_READ_BUF_MEM, 0 );
170170 // rxstat |= readOp(ENC28J60_READ_BUF_MEM, 0) << 8;
171+ #ifdef ENC28J60DEBUG
172+ Serial.print (" receivePacket [" );
173+ Serial.print (readPtr,HEX);
174+ Serial.print (" -" );
175+ Serial.print ((readPtr+len) % (RXSTOP_INIT+1 ),HEX);
176+ Serial.print (" ], next: " );
177+ Serial.print (nextPacketPtr,HEX);
178+ Serial.print (" , stat: " );
179+ Serial.print (rxstat,HEX);
180+ Serial.print (" , count: " );
181+ Serial.print (readReg (EPKTCNT));
182+ Serial.print (" -> " );
183+ Serial.println ((rxstat & 0x80 )!=0 ? " OK" : " failed" );
184+ #endif
171185 // decrement the packet counter indicate we are done with this packet
172186 writeOp (ENC28J60_BIT_FIELD_SET, ECON2, ECON2_PKTDEC);
173187 // check CRC and symbol errors (see datasheet page 44, table 7-3):
@@ -201,6 +215,8 @@ Enc28J60Network::blockSize(memhandle handle)
201215void
202216Enc28J60Network::sendPacket (memhandle handle)
203217{
218+ if (handle == NOBLOCK)
219+ return ;
204220 memblock *packet = &blocks[handle];
205221 uint16_t start = packet->begin -1 ;
206222 uint16_t end = start + packet->size ;
@@ -215,10 +231,10 @@ Enc28J60Network::sendPacket(memhandle handle)
215231 Serial.print (" sendPacket(" );
216232 Serial.print (handle);
217233 Serial.print (" ) [" );
218- Serial.print (start);
234+ Serial.print (start,HEX );
219235 Serial.print (" -" );
220- Serial.print (end);
221- Serial.println (" ]:" );
236+ Serial.print (end,HEX );
237+ Serial.print (" ]: " );
222238 for (uint16_t i=start; i<=end; i++)
223239 {
224240 Serial.print (readByte (i),HEX);
0 commit comments