void memReadProcess() { uint8_t memId = p.data[0]; uint8_t readLen = p.data[5]; uint32_t memAddr; uint8_t status = 0; memcpy(&memAddr, &p.data[1], 4); MEM_DEBUG("Packet is MEM READ\n"); p.header = CRTP_HEADER(CRTP_PORT_MEM, READ_CH); // Dont' touch the first 5 bytes, they will be the same. if (memId == EEPROM_ID) { if (memAddr + readLen <= EEPROM_SIZE && eepromReadBuffer(&p.data[6], memAddr, readLen)) status = 0; else status = EIO; } else if (memId == LEDMEM_ID) { if (memAddr + readLen <= sizeof(ledringmem) && memcpy(&p.data[6], &(ledringmem[memAddr]), readLen)) status = 0; else status = EIO; } else { memId = memId - NBR_STATIC_MEM; if (memAddr + readLen <= OW_MAX_SIZE && owRead(memId, memAddr, readLen, &p.data[6])) status = 0; else status = EIO; } #if 0 { int i; for (i = 0; i < readLen; i++) consolePrintf("%X ", p.data[i+6]); consolePrintf("\nStatus %i\n", status); } #endif p.data[5] = status; if (status == 0) p.size = 6 + readLen; else p.size = 6; crtpSendPacket(&p); }
void chb_eeprom_read(uint16_t addr, uint8_t *buf, uint16_t size) { // Read the contents at address eepromReadBuffer(addr, buf, size); }