congratulation to the creation of the wonderful Netduino board. After the announcement of the first processor which had enough memory to host the .NET Micro Framework I was eager to get the first board.
But yesterday I encountered an issue with I2C bus on my Netduino and Netduino Plus after I upgraded to firmware 4.1.1.0 Alpha7. If I have started my application with disconnected I2C bus the Netduino was unresponsive after the I2C read command and could only brougth back to life by pressing the reset button. Even Visual Studio of MFDeploy couldn't connect to the device without reseting it first.
To cut a long story short: If the I2C bus has no external pullups neither an exceptions will be thrown nor data (like an empty byte array) will be received. The board waits to get an high level on SCL and without pull-ups it waits forever. The timeout value of the ReadTransaction will be completly ignored.
I'm not sure if the behaviour was diffrent in the release firmware of Netduino but i would appreciate some error handling like exceptions or empty results.
public class Program { private static I2CDevice _I2CDevice; private static Timer _Timer; private static OutputPort _OnboardLed; public static void Main() { _Timer = new Timer(TimerElapsed, null, new TimeSpan(0, 0, 8), new TimeSpan(0, 0, 1)); //Initialize the I2CDevice with a dummy configuration _I2CDevice = new I2CDevice(new I2CDevice.Configuration(20, 100)); _OnboardLed = new OutputPort(Pins.ONBOARD_LED, false); Thread.Sleep(Timeout.Infinite); } private static void TimerElapsed(object state) { var bytesToRead = new byte[2]; var configuration = new I2CDevice.Configuration(0x48, 100); _I2CDevice.Config = configuration; var transactions = new[] { I2CDevice.CreateReadTransaction(bytesToRead) }; _OnboardLed.Write(true); Thread.Sleep(50); _OnboardLed.Write(false); // Execute the read or write transaction, check if byte was successfully transfered int bytesTransfered = _I2CDevice.Execute(transactions, 200); Debug.Print("Bytes transferred '" + bytesTransfered + "' at " + DateTime.Now); } }
Are there any workarounds for this issue? Are there any issues in my (example) code? Any help would be appreciated...