Using MFDeploy I’ve been able to see that the reason for the apparent freeze when not launched via VS2010 is due to an out of memory exception after receiving loads of DataReceived events for a serial port that isn’t even physically connected, and again this only happens when the program isn’t launched via VS2010.
To recap the program sits in a loop reading from COM1 (not using serial events), reads a couple of analog inputs and then transmits a packet out 3 other COM ports and writes the packet to the SD card all at about 20Hz.
As a placeholder I have set up DataReceived event handlers for 2 of the COM ports, however nothing is currently physically connected to them yet.
_rockwellComPort = new SerialPort("COM1", 115200, System.IO.Ports.Parity.None, 8, StopBits.One);
_bluetoothComPort = new SerialPort("COM2", 115200, System.IO.Ports.Parity.None, 8, StopBits.One);
_pcComPort = new SerialPort("COM3", 115200, System.IO.Ports.Parity.None, 8, StopBits.One);
_telemetryComPort = new SerialPort("COM4", 115200, System.IO.Ports.Parity.None, 8, StopBits.One);
_bluetoothComPort.Handshake = Handshake.RequestToSend;
_bluetoothComPort.DataReceived += new SerialDataReceivedEventHandler(_bluetoothComPort_DataReceived);
_pcComPort.DataReceived += new SerialDataReceivedEventHandler(_pcComPort_DataReceived);
DataReceived event handlers are empty placeholders at the moment.
void _pcComPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
Debug.Print("PC Com Port DataReceived");
void _bluetoothComPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
Debug.Print("Bluetooth Com Port DataReceived");
When the FEZ Rhino is reset and only connected to MFDeploy to view the debug messages there are hundreds of calls to _pcComPort_DataReceived event handler, lots of garbage collections (not invoked directly by my code) and then an out of memory exception.
If the same program even in release mode is launched via VS2010 however there are no calls to the DataReceived event handler at all and the unit logs data without issue for hours.
So what could be causing the DataReceived events when not launched via VS2010 and it’s not clear what is actually causing the out of memory exception even in this case.
The BINARY_BLOB_HEAD type seems to grow and eventually lead to an out of memory exception.
I’m fairly certain I didn’t see this issue, although I didn’t do as much testing without using VS2010 to launch the app with an earlier SDK.
As mentioned earlier I’m using the latest SDK after having updated the firmware etc.