This blog is the continuation of the previous blog Windows
IoT on Galileo – Connecting Adafruit 10DOF IMU Breakout Part-1 and explain
you on the changes required on the source code to support with new OS update (
A common OS version for both Galileo Gen 1 and Gen2) and SDK update released on
Dec 2014. Updated project is available on the following link in the codeplex. It
can support for the older version of OS image for Gen 1 using Galileo SDK and
lightning version of OS update for both Gen1 and Gen2 with Microsoft IoT C++
SDK. https://adafruit10dofgalileo.codeplex.com/
Development Environment
·
Supported for both Intel Galileo Gen1 and Gen2
·
OS updated released on 21-Nov-2014 (common .wim
for Gen1 and Gen2) for lightning (improved performance on I2C, SPI, and UART
etc..)
·
Visual studio 2013 with Windows IoT SDK (Visit: windowsondevices.com for more
details) and Microsoft IoT C++ SDK and its dependent NuGet Package is required.
Make it work
I have got a new Gen 2 board And at the same time I saw the
new release on Microsoft connect for both Gen1 and Gen 2 with lighting support.
Eagerly attempt the same work explained in the earlier blog with a faster failure
result which is unexpected which create more wondering on it. Let me explain
the issues I have faced and how I resolved it.
Issue 1: Sketch Aborted! A fatal error has occurred: An error occurred queueing an I2C write of 0 bytes.
It is related to Adafruit source code for the 3 sensors
(L3GD20H + LSM303 + BMP180) which I have downloaded from the links shown earlier
blog. It is due to unnecessary wire.endTransmission() call after wire.read() in
all the 3 sensors read16() or read8() functions. Wire.endTransmission()
- Ends a transmission to a slave device that was begun by beginTransmission())
and transmits the bytes that were queued by write(). I don’t why it is
called after wire.read() in this code.
This endTransmission API calls the
I2cTransactionClass::queueWrite() internally which check the bufferBytes == 0
and return error as ERROR_INVALID_PARAMETER and finally This EndTransmission
API thrown the exception and causes "Sketch Aborted! A fatal error has
occurred: An error occurred queueing an I2C write of 0 bytes. Error:
0x00000057" .
After comment the wire.endTransmission() from the read16()
and read8() resolved this issue.
endTransmission() in Older Galileo SDK simply perform I2Cwrite and simpy return NACK and not throwing any exception and also the return value for the endTransmission is not handled in Adafruit code. so it is working in older Galileo SDK.
endTransmission() in Older Galileo SDK simply perform I2Cwrite and simpy return NACK and not throwing any exception and also the return value for the endTransmission is not handled in Adafruit code. so it is working in older Galileo SDK.
Issue 2: Sketch
Aborted! A fatal error has occurred: Error encountered setting I2C address:
0x77
It is related to Microsoft IoT C++ SDK. One of sensor BMP180
in the board has BMP180 the slave address of 0x77. According to the I2C spec it
is valid address. The I2C specification has reserved two sets of eight
addresses, 1111XXX (0x78 and above) and 0000XXX (less than 0x8 ). These
addresses are used for special purposes. traced the code flow and found that
wire.beginTransmission() calls _setSlaveAddress() which in turn calls
I2cTransactionClass::setAddress(ULONG slaveAdr) in I2cController.cpp. This
function has the bug as shown in the below figure.
The conditional statement for slave address checking
includes 0x77 as a special purpose which creates this issue. After changes this
code, it worked as expected. Pull request has made to MS-IoTGithub and changes will be updated in next release of Microsoft IoT C++
SDK.
No comments:
Post a Comment