i was happy to find this project, cause serial port communication under Windows is very complicated.
I try to transmit a buffer of 30.000 bytes, but i can only receive 19.248 with a terminal programm.
The port is configuered as follows:
StreamSerPort = new SerialPort("Com1");
StreamSerPort.BaudRate = 38400;
StreamSerPort.Handshake = Handshake.RequestToSend;
StreamSerPort.ReceivedEvent += new SerialReceivedEventHandler(OnRecv);
string text = GetFileContent("1000.txt");
byte buf = new byte[text.Length];
buf = Encoding.ASCII.GetBytes(text);
There is a bug where by the baud rate doesn't change on the fly. If all else fails try closing and reopening the port after setting the baud rate.
I haven't used the handshaking stuff, so can't say what thats like.
I'm curious as to how you know that your receiving
.248 of a byte however.
Since a byte can only at best be divided into 8 bits :-)
I guess you could measure the high and low voltages... but thats over my head.
Thanks for your answer.
The baud rate must be correct cause the characters of the string are correctly transmitted.
The point '.' is not a decimal point, it stands for thousand.
Ah that makes more sense!
I think it's the norm to use the comma symbol
Don't think I can offer that much more help really.
I never send that much data through it, my data tends to be up to about 200 bytes long tops.
I'm sending it in exactly the same way you are.
Does the text file definitley contain ascii data? If it's raw binary that will upset it.
I presume you've assertained that buf definitly contains 30,000 bytes before sending.
Sadly the author of this project seems to have disappeared off the face of the planet, so you might be on your own from here on.
Sorry I can't be of more help!
Just out of curiosity
Have you tried splitting the message in to two halfs and seeing if that works?
Ive not tried out this, i think it could work but its very tricky and doesnt eleminate the real cause.
There must be a bug in the code. Ive tried out a serial class from CodeProject that works fine. But its not so universal cause it uses the abort function for multithreading and so it cant work with compact framework.
Intriguing. I may have a go at it some time and
see if i can work it out.
It may help in the mean time if you could leave a link to the CodeProject class that you've found, for anyone else that runs into similar problems.
I've tried several other classes, and alot of them have a bug on the receiving end, characters going missing etc.
Serial Communications: The .NET Way
Log in to post a comment.