//-------------------------------------------------------------------------- // Write_Page: // // Write a page to a Touch Memory at a provided location (pg). // // 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 location of the write data // pg page number to write the packet // len the length of the packet // SMALLINT Write_Page(int portnum, uchar *SNum, uchar *buff, PAGE_TYPE pg, int len) { SMALLINT bank; PAGE_TYPE page; uchar addpg; // check for length too long for a page if (len > 29) { OWERROR(OWERROR_INVALID_PACKET_LENGTH); return FALSE; } // Are program jobs possible // is there a job that has been opened if(isJob(portnum,SNum)) { if(setJobData(portnum,SNum,pg,buff,len)) return TRUE; } bank = getBank(portnum,SNum,pg,REGMEM); page = getPage(portnum,SNum,pg,REGMEM); if(!owWritePagePacket(bank,portnum,SNum,page,buff,len)) return FALSE; else { addpg = AddPage(portnum,SNum,pg,buff,len); } return TRUE; }
/** * Write a UDP packet to the specified page in the * provided PagedMemoryBank. * * bank PagedMemoryBank to write packet to * portnum port number for the device * SNum serial number for the device * pg page number to write packet to * data data to write in a byte array * length length of the data to be written * * @return 'true' if the packet was written. */ SMALLINT bankWritePacket(SMALLINT bank, int portnum, uchar SNum[8], int pg, uchar *data, int length) { if(!owWritePagePacket(bank,portnum,SNum,pg,data,length)) return FALSE; printf("\n"); printf("wrote packet length %d on page %d\n",length,pg); return TRUE; }