I am trying to read a file and send it via the serial port. I can send a few bytes, but not a lot.
It seems to send really quickly (about a second) compared to using a terminal program (about a minute). and the device at the other end does not receive it properly.
I have connected a Tx Rx loopback adapter to the port, and it does loop back a small text file (so it does basically work), but for a large one only a line of bytes get through. I am worried that the send data is overflowing the port buffer, and that some data is getting lost.
There is no hardware or software protocol being used as flow control (in hyperterminal I would select none for flow control).
FileStream inStream = new FileStream(filename, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(inStream);
int nBytesToRead = (int)inStream.Length;
sp.Write(br.ReadBytes(nBytesToRead), 0, nBytesToRead);
textBox.AppendText("\n[ Sending " + nBytesToRead.ToString() + " bytes. ]\n");
should I be sending smaller numbers of bytes at a time? if so how would I do that? or do I need to clear the buffer or something?