Has anyone successfully managed to get more than one I2C device communicating on the same bus with VB?
I thought i could just attach them in parallel and they would just work, however it appears that I2Cdevice actually means I2CBus and you can instantiate only once or you get an exception.
I found some C# code here on the forums (http://forums.netdui..._4156#entry4156) and translated it to VB, but am being frustrated by a couple of errors I can't seem to work out.
Part of the code requires a SyncLock
Public Class I2CBus Implements IDisposable Private Shared _instance As I2CBus = Nothing Private Shared ReadOnly LockObject As Object Public Shared Function GetInstance() As I2CBus SyncLock LockObject If _instance Is Nothing Then _instance = New I2CBus() End If Return _instance End SyncLock End Function
However, I get an error, though I can't see anything wrong with the code;
"Error 1 Requested operation is not available because the runtime library function 'Microsoft.VisualBasic.CompilerServices.ObjectFlowControl.CheckForSyncLockOnValueType' is not defined."
So I created a Dummy class called 'Object1' and used that for the lock object and the error goes away, but then when I try and compile I get;
An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.SPOT.Hardware.dll
At the point where the new I2C device instance is created...
Public Sub New() Me._slaveDevice = New I2CDevice(New I2CDevice.Configuration(0, 0)) End Sub
I think it may be my workaround of creating a dummy class as an object but i'm not sure
Any Help will be graciously received.