void edpDisplayReply(uint8_t response, EdpReply* edpReply) { uint8_t i; uint8_t checksum; // display response rprintf("EDP Response: 0x%x '%c'\r\n",response,response); // if data was received if(response==EDP_RESP_DATA_REPLY) { // do checksum on reply checksum = edpReply->Length; for(i=0; i<(edpReply->Length-1); i++) { checksum += edpReply->Data[i]; } checksum = ~checksum; // print message rprintf("EDP Reply: "); // show data received rprintf("Length: 0x%x ",edpReply->Length); rprintf("RxChksum=0x%x MyChksum=0x%x",edpReply->Data[edpReply->Length-1], checksum); rprintfCRLF(); rprintf("Data:\r\n"); debugPrintHexTable((edpReply->Length-1), edpReply->Data); rprintfCRLF(); } }
void erpDisplayPacket(ErpPacket* erpPacket, u08 pktLength) { u08 i; u08 flag; // show ERP packet header erpDisplayHeader(erpPacket); // dump complete raw packet data if(pktLength) { // check if all characters are printable flag = TRUE; for(i=0; i<pktLength; i++) { if( ((u08*)erpPacket)[i] < 0x20 ) flag = FALSE; } // print packet data rprintf("Data:\r\n"); if(flag) { // print as string rprintfStrLen(((u08*)erpPacket), 0, pktLength); } else { // print as hex debugPrintHexTable(pktLength, ((u08*)erpPacket)); } rprintfCRLF(); } }
void mmcTest(void) { uint32_t sector=0; uint8_t buffer[0x200]; int c; // initialize MMC interface mmcInit(); // print new prompt rprintf("\r\ncmd>"); // testing loop while(1) { // check for keypress if((c=uartGetByte()) != -1) { switch(c) { case 'i': // initialize card rprintf("\r\nResetting MMC/SD Card\r\n"); mmcReset(); break; case 'r': // read current sector into buffer rprintf("\r\nRead Sector %d\r\n", sector); mmcRead(sector, buffer); // print buffer contents debugPrintHexTable(0x200, buffer); break; case 'w': // write current sector with data from buffer rprintf("\r\nWrite Sector %d\r\n", sector); mmcWrite(sector, buffer); break; // move to new sector case '+': sector++; rprintf("\r\nSector = %d", sector); break; case '-': sector--; rprintf("\r\nSector = %d", sector); break; case '*': sector+=512; rprintf("\r\nSector = %d", sector); break; case '/': sector-=512; rprintf("\r\nSector = %d", sector); break; case '\r': default: break; } // print new prompt rprintf("\r\ncmd>"); } } }
void edpDisplayCommand(uint8_t length, EdpCommand* edpCommand) { // print source and command char rprintf("EDP SrcAddr: 0x%x Cmd: 0x%x '%c'\r\n", edpCommand->SrcAddr, edpCommand->Command, edpCommand->Command); if(length-2) { // print data rprintf("Data:\r\n"); debugPrintHexTable(length-2, edpCommand->Data); } }
int netstackService(void) { int len; struct netEthHeader* ethPacket; // look for a packet len = nicPoll(NETSTACK_BUFFERSIZE, NetBuffer); if(len) { ethPacket = (struct netEthHeader*)&NetBuffer[0]; #if NET_DEBUG >= 5 rprintf("Received packet len: %d, type:", len); rprintfu16(htons(ethPacket->type)); rprintfCRLF(); rprintf("Packet Contents\r\n"); debugPrintHexTable(len, NetBuffer); #endif if(ethPacket->type == htons(ETHTYPE_IP)) { // process an IP packet #ifdef NETSTACK_DEBUG rprintfProgStrM("NET Rx: IP packet\r\n"); #endif // add the source to the ARP cache // also correctly set the ethernet packet length before processing? arpIpIn((struct netEthIpHeader*)&NetBuffer[0]); //arpPrintTable(); netstackIPProcess( len-ETH_HEADER_LEN, (ip_hdr*)&NetBuffer[ETH_HEADER_LEN] ); } else if(ethPacket->type == htons(ETHTYPE_ARP)) { // process an ARP packet #ifdef NETSTACK_DEBUG rprintfProgStrM("NET Rx: ARP packet\r\n"); #endif arpArpIn(len, ((struct netEthArpHeader*)&NetBuffer[0]) ); #ifdef NETSTACK_DEBUG //arpPrintTable(); #endif } } return len; }