I keep getting an System.InvalidOperationException when trying to SerialPort.Open() on a FEZ Cerberus (non-Bee). I have the same code (almost) working fine on a FEZ Cerberus Bee.
Code on the FEZ Cerberus Bee:
_wifi = new WiFlyGSX();
Code on the FEZ Cerberus:
xBeeAdapter.Configure(9600, GT.SocketInterfaces.SerialParity.None, GT.SocketInterfaces.SerialStopBits.One, 8, GT.SocketInterfaces.HardwareFlowControl.Required);
xBeeAdapter.DebugPrintEnabled = true;
string port = xBeeAdapter.Port.PortName;
Debug.Print("xBeeAdapter on Port: " + port);
_wifi = new WiFlyGSX(port, 9600, "$", false);
The Exception occurs inside the WiFlyGSX (a .netmftoolbox class) constructor where it try to open the serial port.
// Configures this client
this._CommandMode_InitString = CommandChar + CommandChar + CommandChar;
this.DebugMode = DebugMode;
this._Mode = Modes.Idle;
// Configures and opens the port
this._SerialPort = new SerialPort(PortName, BaudRate, Parity.None, 8, StopBits.One);
this._SerialPort.DataReceived += new SerialDataReceivedEventHandler(_SerialPort_DataReceived);
this._SerialPort.Open();
I have tried various flowcontrol configurations, and nothing seems to make a difference. The xBeee adapter is showing up on COM2.
---- Output -----
Using mainboard GHI Electronics FEZ Cerberus version 1.3
Initializing WiFi
xBeeAdapter on Port: COM2
A first chance exception of type ‘System.InvalidOperationException’ occurred in Microsoft.SPOT.Hardware.dll
Anyone have any thoughts?