Example #1
0
void iPodSerial::sendCommand(
    byte mode,
    byte cmdByte1,
    byte cmdByte2)
{
    sendHeader();
    sendLength(1 + 1 + 1);
    sendByte(mode);
    sendByte(cmdByte1);
    sendByte(cmdByte2);
    sendChecksum();
}
Example #2
0
void iPodSerial::sendCommandWithOneNumberParam(
    byte mode,
    byte cmdByte1,
    byte cmdByte2,
    unsigned long numberParam)
{
    sendHeader();
    sendLength(1 + 1 + 1 + 4);
    sendByte(mode);
    sendByte(cmdByte1);
    sendByte(cmdByte2);
    sendNumber(numberParam);
    sendChecksum();
}
Example #3
0
void iPodSerial::sendCommandWithOneByteParam(
    byte mode,
    byte cmdByte1,
    byte cmdByte2,
    byte byteParam)
{
    sendHeader();
    sendLength(1 + 1 + 1 + 1);
    sendByte(mode);
    sendByte(cmdByte1);
    sendByte(cmdByte2);
    sendByte(byteParam);
    sendChecksum();
}
Example #4
0
void iPodSerial::sendCommandWithOneByteAndOneNumberParam(
    byte mode,
    byte cmdByte1,
    byte cmdByte2,
    byte byteParam1,
    unsigned long numberParam2)
{
    sendHeader();
    sendLength(1 + 1 + 1 + 1 + (1 * 4));
    sendByte(mode);
    sendByte(cmdByte1);
    sendByte(cmdByte2);
    sendByte(byteParam1);
    sendNumber(numberParam2);
    sendChecksum();
}
Example #5
0
void iPodSerial::sendCommandWithLength(
    size_t length,
    const byte *pData)
{
#if defined(IPOD_SERIAL_DEBUG)
    if (pDebugPrint)
    {
        pDebugPrint->print("Sending command of length: ");
        pDebugPrint->println(length, DEC);
    }
#endif

    sendHeader();
    sendLength(length);
    sendBytes(length, pData);
    sendChecksum();
}
Example #6
0
int readMemory(int fd, unsigned addr, void *ptr, int len)
{
	unsigned char *data = ptr;
	while (len > 0) {
		int xfer = (len > 256) ? 256 : len;
		fprintf(stderr,"read %04x at %08x -> %p\n", xfer, addr, data);
		if (sendCommand(fd, 0x11))
			return -1;
		if (sendAddress(fd, addr))
			return -1;
		if (sendLength(fd, xfer))
			return -1;
		if (readData(fd, data, xfer))
			return -1;
		data += xfer;
		len -= xfer;
		addr += xfer;
	}
	return 0;
}