ok, the demo runs fine, so everything works, but not my code, even if it was very similar for the two modules.
I added some code to try to enumerate the go bus, and it seems that alone crashes everything?
this class:
public class GoEnumerate : GoBus.GoModule { public void EnumerateGoPorts() { var lll = GetUniqueIdsFromUnboundSockets(); foreach (var guid in lll) { Debug.Print(guid.ToString()); } } }
and this code in main:
var l = new GoEnumerate();l.EnumerateGoPorts();
Why would that make everything stop working?, or, is there an better way to discover which modules are connected?
This is my full code:
using System;
using System.Threading;
using Microsoft.SPOT;
using SecretLabs.NETMF.Hardware.NetduinoGo;
using Nwazet.Go.DAQ;
using System.Text;
using Taos;
using Komodex.NETMF;
namespace NetduinoGoApplication1 {
public class GoEnumerate : GoBus.GoModule {
public void EnumerateGoPorts() {
var lll = GetUniqueIdsFromUnboundSockets();
foreach (var guid in lll) {
Debug.Print(guid.ToString());
}
}
}
public class Program {
public static SevenSegmentDisplay seg;
public static NwazetDAQ daq;
public static void Main() {
var l = new GoEnumerate();
l.EnumerateGoPorts();
seg = new SevenSegmentDisplay(GoSockets.Socket4);
daq = new NwazetDAQ();
daq.Initialize(GoSockets.Socket5, 10000);
var state = daq.GetClockState();
if (state == NwazetDAQ.ClockState.Invalid) {
Debug.Print("setting clock");
daq.SetDateTime(new DateTime(2012, 10, 05, 20, 39, 00));
}
//var usartConfig = new UsartConfig();
//usartConfig.BaudRate = UsartBaudRate.Baud57600;
//daq.UsartPort.SetConfig(usartConfig);
seg.SetBrightness(0.1f);
seg.SetValue(1201);
Log("Initialize()");
daq.Interrupts += new InterruptEventEventHandler(InterruptHandler);
using (var daqConfig = new DaqConfig(daq)) {
if (daqConfig.IsOptionEnabled(DaqSetting.DiagnosticsToSerial) == false) {
daqConfig.SetOption(DaqSetting.DiagnosticsToSerial, true);
daqConfig.Commit(daq);
daq.Reboot();
}
}
try {
I2cTSL2561Test();
}
catch (Exception e) {
Log(">>>UNCAUGHT EXCEPTION: " + e.Message);
}
daq.Reboot();
}
public static void Log(string line) {
Debug.Print("debug: " + line);
daq.UsartPort.Write(Encoding.UTF8.GetBytes("DAQ: " + line + "rn"));
}
public static void I2cTSL2561Test() {
Log("I2cTSL2561Test begin");
try {
var lightSensor = new TaosTSL256x(daq.I2cPort, TaosTSL256x.Address.AddressPinFloat);
Log("Light sensor ID: " + lightSensor.GetSensorId());
Log("--------------------------------------------");
var count = 3;
while (count-- != 0) {
Log("Raw Luminosity: " + lightSensor.Read());
Log("Full spectrum luminosity: " + lightSensor.FullSpectrum);
Log("Infrared spectrum luminosity: " + lightSensor.InfraredSpectrum);
Log("Visible spectrum luminosity: " + lightSensor.VisibleSpectrum);
Log("Lux: " + lightSensor.Lux);
Log("--------------------------------------------");
Thread.Sleep(500);
}
}
catch (I2cException e) {
Log("I2C transaction failed: " + e.Message);
}
Log("I2cTSL2561Test end");
}
public static void InterruptHandler(InterruptEvent intEvent) {
Log("Interrupt on Gpio:" + intEvent.Id + ", Count: " + intEvent.Count + ", Rollover: " + intEvent.RollOverCount);
}
}
}
If I remove the two first lines in the Main method everything works, but with then it crashes with this error:
A first chance exception of type 'System.ApplicationException' occurred in Nwazet.Go.Core.dll
An unhandled exception of type 'System.ApplicationException' occurred in Nwazet.Go.Core.dll
Additional information: _headerVersion
and stacktrace:
Nwazet.Go.Core.dll!Nwazet.Go.Helpers.BasicTypeDeSerializerContext.ReadHeader(int BufferStartOffset) Line 64 + 0x37 bytes C#
Nwazet.Go.Core.dll!Nwazet.Go.Helpers.BasicTypeDeSerializerContext.Bind(byte[] buffer, int BufferStartOffset) Line 51 + 0x34 bytes C#
Nwazet.Go.DAQ.dll!Nwazet.Go.DAQ.NwazetDAQ.Receive() Line 145 + 0x2d bytes C#
Nwazet.Go.DAQ.dll!Nwazet.Go.DAQ.NwazetDAQ.GetClockState() Line 226 + 0x22 bytes C#
NetduinoGoApplication1.exe!NetduinoGoApplication1.Program.Main() Line 32 + 0x43 bytes C#