/** * Read a page packet from a memory bank and print in hex * * bank PagedMemoryBank to read a page from * portnum port number * SNum The serial number of the device to read. * pg page to read * * @return 'true' if the bank page packet was dumped. */ SMALLINT dumpBankPagePacket(SMALLINT bank, int portnum, uchar SNum[8], int pg) { uchar read_buf[64]; uchar extra_buf[32]; int read_rslt; int i; // read a page packet (use the most verbose method) if(owHasExtraInfo(bank,SNum)) { if(!owReadPagePacketExtra(bank,portnum,&SNum[0],pg,FALSE, &read_buf[0],&read_rslt,&extra_buf[0])) return FALSE; } else if(!owReadPagePacket(bank,portnum,&SNum[0],pg,FALSE,&read_buf[0],&read_rslt)) return FALSE; printf("Packet %d, len %d\n",pg,read_rslt); for(i=0;i<read_rslt;i++) printf("%02X ",read_buf[i]); printf("\n"); if(owHasExtraInfo(bank,SNum)) { printf("Extra: "); for(i=0;i<owGetExtraInfoLength(bank,SNum);i++) printf("%02X ",extra_buf[i]); printf("\n"); } return TRUE; }
//-------------------------------------------------------------------------- // ExtendedRead_Page: // // Read a extended page from the current Eprom Touch Memory. // The record will be placed into a (uchar) memory location // starting at the location pointed to by (buf). This function will // read a page out of normal memory. If the page being read is // redirected then an error is returned // The following return codes will be provided to the caller: // // portnum the port number of the port being used for the // 1-Wire Network. // SNum the serial number for the part that the read is // to be done on. // buff the buffer for the data that was read // pg the page that starts the read // // return TRUE if the read was successful. // SMALLINT ExtendedRead_Page(int portnum, uchar *SNum, uchar *buff, PAGE_TYPE pg) { SMALLINT bank; PAGE_TYPE page; uchar extra[20]; int len,i; bank = getBank(portnum,SNum,pg,REGMEM); page = getPage(portnum,SNum,pg,REGMEM); if(!owIsWriteOnce(bank,portnum,SNum) && ((SNum[0] != 0x18) && (SNum[0] != 0x33) && (SNum[0] != 0xB3)) ) { OWERROR(OWERROR_NOT_WRITE_ONCE); return FALSE; } // check on the program job to see if this page is in it if(isJob(portnum,SNum)) { if(getJobData(portnum,SNum,pg,&buff[1],&len)) { return TRUE; } } if(owIsWriteOnce(bank,portnum,SNum)) { if(!owReadPageExtraCRC(bank,portnum,SNum,page,&buff[0],&extra[0])) return FALSE; } else { if(!owReadPageExtra(bank,portnum,SNum,page,FALSE,&buff[0],&extra[0])) return FALSE; for(i=0;i<owGetExtraInfoLength(bank,SNum);i++) buff[i+32] = extra[i]; extra[0] = 0xFF; } if(extra[0] != 0xFF) { OWERROR(OWERROR_REDIRECTED_PAGE); return FALSE; } return TRUE; }
/** * Read a page from a memory bank and print in hex * * bank MemoryBank to read a page from * portnum port number * SNum The serial number of the device to read. * pg page to read * * @return 'true' if the bank page was dumped. */ SMALLINT dumpBankPage (SMALLINT bank, int portnum, uchar SNum[8], int pg) { uchar read_buf[64]; uchar extra_buf[32]; int i; int result; // read a page (use the most verbose and secure method) if (owHasPageAutoCRC(bank,SNum)) { if(owHasExtraInfo(bank,SNum)) result = owReadPageExtraCRC(bank,portnum,&SNum[0], pg,&read_buf[0],&extra_buf[0]); else result = owReadPageCRC(bank,portnum,&SNum[0],pg,&read_buf[0]); } else { if(owHasExtraInfo(bank,SNum)) result = owReadPageExtra(bank,portnum,&SNum[0], pg,FALSE,&read_buf[0],&extra_buf[0]); else result = owReadPage(bank,portnum,&SNum[0],pg,FALSE,&read_buf[0]); } if(!result) return FALSE; printf("Page %d: ",pg); for(i=0;i<owGetPageLength(bank,SNum);i++) printf("%02X ",read_buf[i]); printf("\n"); if(owHasExtraInfo(bank,SNum)) { printf("Extra: "); for(i=0;i<owGetExtraInfoLength(bank,SNum);i++) printf("%02X ",extra_buf[i]); printf("\n"); } return TRUE; }
/** * Display the information about the current memory back provided. * * portnum port number for the device * SNum serial number for the device */ void displayBankInformation (SMALLINT bank, int portnum, uchar SNum[8]) { printf("\n"); printf("|------------------------------------------------------------------------\n"); printf("| Bank: %s\n",owGetBankDescription(bank,SNum)); printf("| Size: %d starting at physical address %d\n",owGetSize(bank,SNum), owGetStartingAddress(bank,SNum)); printf("| Features: "); if(owIsReadWrite(bank,portnum,SNum)) printf("Read/Write "); if(owIsWriteOnce(bank,portnum,SNum)) printf("Write-once "); if(owIsReadOnly(bank,portnum,SNum)) printf("Read-only "); if(owIsGeneralPurposeMemory(bank,SNum)) printf("general-purpose "); else printf("not-general-purpose "); if(owIsNonVolatile(bank,SNum)) printf("non-volatile\n"); else printf("volatile\n"); if(owNeedsProgramPulse(bank,SNum)) printf("|\tneeds-program-pulse \n"); if(owNeedsPowerDelivery(bank,SNum)) printf("|\tneeds-power-delivery \n"); printf("| Pages: %d pages of length %d bytes ", owGetNumberPages(bank,SNum),owGetPageLength(bank,SNum)); if(owIsGeneralPurposeMemory(bank,SNum)) printf("giving %d bytes Packet data payload",owGetMaxPacketDataLength(bank,SNum)); printf("\n| Page Features: "); if(owHasPageAutoCRC(bank,SNum)) printf("page-device-CRC "); if(owCanRedirectPage(bank,SNum)) printf("pages-redirectable "); if(owCanLockPage(bank,SNum)) printf("pages-lockable \n"); if((owCanLockPage(bank,SNum)) && (owCanLockRedirectPage(bank,SNum))) printf("|\tredirection-lockable\n"); else if(owCanLockRedirectPage(bank,SNum)) printf("redirection-lockable."); if(!owCanLockPage(bank,SNum)) printf("\n"); if(owHasExtraInfo(bank,SNum)) printf("| Extra information for each page: %s length %d\n", owGetExtraInfoDesc(bank,SNum), owGetExtraInfoLength(bank,SNum)); printf("|------------------------------------------------------------------------\n\n"); }