So I nailed it down why my N2 does not work since I got it last year. Now I upgraded again and still did not work.
The problem is that the same code below runs on the N1 and N1+ without any problem, but on N2 and N2+ nothing works.
When starting MFDeploy after deploying the code to the N2(+), the console shows an endless list of "Buffer overflw" messages. Again on N1(+) it's running for hours without any problem.
Please advice what's wrong here...because it's still an issue in 4.3.1
There is just an Adafruit Ultimate GPS sensor v3 connected to the N2 nothing else
public class Program { public static void Main() { //Required, otherwise redeploy not possible due to Buffer overflow Thread.Sleep(8000); GpsConnector _gpsConnector = new GpsConnector(); Thread.Sleep(Timeout.Infinite); } } public class GpsConnector { SerialPort _serialPort; private char[] splitBy = new Char[] {'\r', '\n'}; private bool _isStarted; //'objectified' main public GpsConnector() { _serialPort = new SerialPort("COM2", 115200, Parity.None, 8, StopBits.One); _serialPort.Handshake = Handshake.None; _serialPort.Open(); if (_serialPort.IsOpen) { _isStarted = true; DoProcessing(); } } private void DoProcessing() { if (!_serialPort.IsOpen) { _serialPort.Open(); } while (_isStarted) { int bytesToRead = _serialPort.BytesToRead; // get the waiting data byte[] buffer = new byte[bytesToRead]; _serialPort.Read(buffer, 0, buffer.Length); _serialPort.Flush(); //only accept a statement starting with $ if (buffer[0] != 36) continue; //copy the byte array to a readable string String str = new String(System.Text.Encoding.UTF8.GetChars(buffer)); //break up string into statements string[] statements = null; statements = str.Split(splitBy); for (int i = 0; i < statements.Length; i++) { //only accept statements with a checksum String currStatement = statements[i]; if (currStatement.Length > 0 && currStatement.IndexOf("*") >= 0) { Debug.Print(currStatement); } } } } }