Hello I'm trying to interface the ESP8266 WiFi with AT commands.
Also any one intresting in WiFi for the Netduino,
( better just buy the new Netduino 3 with out of the box Wifi !!! )
At the moment i'm using the module, with this firmware (0018000902-AI03).
At 9600 bit ps.
most functions are working now.
my problem is the ESP 8266 only have 256 byte buffer. so to read the 256 byte buffer ( 2048 bit. ).
after about 200 ms you start to loose data.
At the moment i spend quite some time to get me familiar to the .net micro framework serial port.
The serial port is read with an interupt.
This interupt is started in a new thread. so this is triggered after some data is recieved.
somtimes 2 bytes somtimes 10 or more.
serialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceived_Interrupt);
serialPort.ErrorReceived += new SerialErrorReceivedEventHandler(ErrorReceived_Interrupt);
Also at first i did not have an Error Revieved interrupt, and was unable to find the problems i had with this module.
turns out it's an buffer input overflow. ( 256 bytes max ).
I changed the handling of the recieved data, and turns out, my approach is to slowy ( or the neduino ? ). For this module.
I'm using some string functions that i suspect are to slowly ?
static System.String sRecieveData = "";
static SerialPort serialPort;
//* Data reception interrupt handler */
internal void DataReceived_Interrupt(object com, SerialDataReceivedEventArgs arg)
{
byte[] bytes = new byte[serialPort.BytesToRead];
// read the bytes
serialPort.Read(bytes, 0, bytes.Length);
// convert the bytes into a string
String strLine = new String(System.Text.Encoding.UTF8.GetChars(bytes, 0, bytes.Length));
sRecieveData += strLine;
}
/* Data reception interrupt handler */
internal void DataReceived_Interrupt(object com, SerialDataReceivedEventArgs arg)
{
byte[] buf = new byte[1];
System.String sRecievePart = "";
while (serialPort.BytesToRead > 0)
{
serialPort.Read(buf, 0, 1);
sRecievePart += (char)buf[0];
}
sRecieveData += sRecievePart;
}
So my question is what is the best way to handle the recieved serial data ? so i not get the buffer overflow error.
Thanks