On Jun 2, 2008, at 1:18 PM, Christopher Leung wrote: > This is just a heads-up about the I2CPacket.read(i2c_flags_t flags, > uint16_t addr, uint8_t length, uint8_t* data) function in the > Atm128I2CMasterC component. > > To read n bytes from a slave, the parameter length must be set to (n > +1). In the returned function, async event void readDone(error_t > error, uint16_t addr, uint8_t length, uint8_t* data), the first > bytes read will be in data[1]; second byte in data[2] and so on. The > byte in data[0] will contain the slave address and the R/notW bit. > > I don't know if that was done on purpose as I couldn't find any of > that mentionned in the comments. > > If someone does want to fix this, the source of the problem is in > the Atm128I2CMasterPacketP component (I have version 1.7 2007/11/01 > 18:10:36 fredjiang Exp). More specifically, in the > I2C.commandComplete() function. The problem is that the index value > is incremented before the first byte is read from the slave. > Therefore, at line 260 when the contents of the Two-Wire-Interface > buffer is read and stored, the function is actually storing the byte > it last sent. That is, it is reading the address and the R/notW bit > it just wrote onto the I2C bus.
Can you send a patch to the list? Phil _______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
