I need help resolving the following exception when using both the SerialCameraL2 and WiFiRS21 module together in the same program. The following code the will generate the Exception using Visual Studio 2012, NETMF 4.3 and a Spider Motherboard. If you comment out the following lines of code for one of the two modules the modules work great independently. As soon as you include both “this.serialCameraL2.StartStreaming();” and “netif.NetworkInterface.Join(“SSID”, “PASSWORD”);” an exception is thrown.
I have also tried putting both SerialCameraL2 and WiFi in to their own separate threads but I still get the same exception and switching up the different ports on the spider the modules are plugged into.
I welcome any ideas you may have.
Exception System.InvalidOperationException - 0x00000000 (6)
Message: Failed to read all of the bytes from the port.
Gadgeteer.Modules.GHIElectronics.SerialCameraL2::ReadBytes [IP: 002f]
Gadgeteer.Modules.GHIElectronics.SerialCameraL2::ReadFrameBuffer [IP: 0076]
Gadgeteer.Modules.GHIElectronics.SerialCameraL2::UpdateStreaming [IP: 003d]
A first chance exception of type ‘System.InvalidOperationException’ occurred in GTM.GHIElectronics.SerialCameraL2.dll
using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using GHI.Networking;
using Microsoft.SPOT.Net.NetworkInformation;
using Microsoft.SPOT.Hardware;
namespace Clean.Camera
{
public partial class Program
{
private GT.Timer timerCamera;
void ProgramStarted()
{
this.serialCameraL2.StartStreaming();
this.timerCamera = new GT.Timer(100);
this.timerCamera.Tick += this.timer_Tick;
this.timerCamera.Start();
//The camera is now taking pictures.
netif.NetworkInterface.Join("SSID", "PASSWORD");
while (netif.NetworkInterface.IPAddress == "0.0.0.0")
{
Debug.Print("Waiting for DHCP");
Thread.Sleep(250);
}
Debug.Print("IP: " + netif.NetworkInterface.IPAddress);
Debug.Print("Mask: " + netif.NetworkInterface.SubnetMask);
Debug.Print("Gateway: " + netif.NetworkInterface.GatewayAddress);
//The network is now ready to use.
}
private void timer_Tick(GT.Timer timer)
{
if (this.serialCameraL2.NewImageReady)
{
var image = this.serialCameraL2.GetImage();
Debug.Print("Image Size " +image.Height + "x" + image.Width);
image.Dispose();
}
}
}
}
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18444
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Clean.Camera {
using Gadgeteer;
using GTM = Gadgeteer.Modules;
public partial class Program : Gadgeteer.Program {
/// <summary>The USB Client DP module using socket 1 of the mainboard.</summary>
private Gadgeteer.Modules.GHIElectronics.USBClientDP usbClientDP;
/// <summary>The Serial Camera L2 module using socket 9 of the mainboard.</summary>
private Gadgeteer.Modules.GHIElectronics.SerialCameraL2 serialCameraL2;
/// <summary>The WiFi RS21 module using socket 6 of the mainboard.</summary>
private Gadgeteer.Modules.GHIElectronics.WiFiRS21 netif;
/// <summary>This property provides access to the Mainboard API. This is normally not necessary for an end user program.</summary>
protected new static GHIElectronics.Gadgeteer.FEZSpider Mainboard {
get {
return ((GHIElectronics.Gadgeteer.FEZSpider)(Gadgeteer.Program.Mainboard));
}
set {
Gadgeteer.Program.Mainboard = value;
}
}
/// <summary>This method runs automatically when the device is powered, and calls ProgramStarted.</summary>
public static void Main() {
// Important to initialize the Mainboard first
Program.Mainboard = new GHIElectronics.Gadgeteer.FEZSpider();
Program p = new Program();
p.InitializeModules();
p.ProgramStarted();
// Starts Dispatcher
p.Run();
}
private void InitializeModules() {
this.usbClientDP = new GTM.GHIElectronics.USBClientDP(1);
this.serialCameraL2 = new GTM.GHIElectronics.SerialCameraL2(9);
this.netif = new GTM.GHIElectronics.WiFiRS21(6);
}
}
}