Hi there,
I'm using an OS for the NXT called nxtOSEK, which depends on leJOS drivers (rather antiquated ones) for its I2C interface. I've recently encountered an odd behaviour using a microcontroller to transmit data to the NXT. If I set all the data on the microcontroller to have constant values of 127, they are transmitted without a hitch to the NXT and then to the PC. The status flag counters in the interrupt service routine on the microcontroller corroborates the successful data transfer. If one of the bytes has a value greater than 127, that byte and all others that follow will not be transmitted. The only exception is when it's the first byte that exceeds a value of 127. In this case, data transmission proceeds as normal.
Here a sample output from my AVR microcontroller. The first byte is a constant value of 128 while the remaining seven contain identical values of 127. The NXT requests for eight bytes at a go, and transmits the received data to the PC via USB. As can be seen here, the transmission goes smoothly.
Data: 128 127 127 127 127 127 127 127
Data: 128 127 127 127 127 127 127 127
Data: 128 127 127 127 127 127 127 127
Data: 128 127 127 127 127 127 127 127
Data: 128 127 127 127 127 127 127 127
Now, if another other byte (fifth in this case) were assigned a value of 128 or larger, and all other bytes are set to 127 or smaller, that particular byte and all others that follow will fail to be transmitted nearly all the time. The status flag counters in the microcontroller's interrupt service routine confirms the large number of bytes dropped in transmission. I've tried sending just two bytes, and the results are the same. At first glance, the numbers involved suggest a type problem. But it doesn't affect the first byte and occasionally all data will get through.
Data: 127 127 127 127 255 255 255 255
Data: 127 127 127 127 255 255 255 255
Data: 127 127 127 127 255 255 255 255
Data: 127 127 127 127 255 255 255 255
Data: 127 127 127 127 255 255 255 255
Data: 127 127 127 127 255 255 255 255
Data: 127 127 127 127 255 255 255 255
Data: 127 127 127 127 128 127 127 127 // Note!
Data: 127 127 127 127 255 255 255 255
Data: 127 127 127 127 255 255 255 255
Data: 127 127 127 127 255 255 255 255
Data: 127 127 127 127 255 255 255 255
Data: 127 127 127 127 255 255 255 255
Data: 127 127 127 127 255 255 255 255
Data: 127 127 127 127 255 255 255 255
Data: 127 127 127 127 128 127 127 127 // Note!
Data: 127 127 127 127 255 255 255 255
Data: 127 127 127 127 255 255 255 255
Data: 127 127 127 127 255 255 255 255
Data: 127 127 127 127 255 255 255 255
Data: 127 127 127 127 255 255 255 255
Since the I2C driver dates from 2008, I'm sure it contains some bugs. However, I can't find any mention of this particular issue at the Sourceforge repository. I was wondering whether anyone else here has experienced or has any recollection of this problem. Unfortunately, I can't simply update the leJOS drivers because of how nxtOSEK is structured. And I have given up emailing queries to the nxtOSEK developer because he barely ever responds. Since the I2C driver is directly borrowed form leJOS, I thought this would be the best place to pose this question. Thanks.
Cheers
Hippie
