void sp_DataReceived(object sender, SerialDataReceivedEventArgs e) { try { int length = sp.BytesToRead; if (length == 0) return;
sp.Read(buffer, 0, length); queue.Enqueue(buffer, 0, length); Interpret();
sp.DiscardInBuffer(); } catch (Exception ex) { Log.Write("sp_DataReceived", ex.ToString()); } }
---
This code a part of my code, and I tried to get whole length of data from submodule sending 16bytes through Uart pin. The sub module is consists of Attiny2313a, and checked it work correctly using logic analyzer.
What I curious is why one of SerialPort instacens named "sp" cannot return BytesToRead property correctly. In my guess, the property should be return 16, but it spilt out numbers fewer than real size or just 1. It makes data collector just get first byte of each packet.
I cannot make sure it is caused by sender or micro framework or characteristics of NP2. I need your clever idea for checking it.
Thanks, Jiwon.