Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i Used
port.Write(txtMsg.Text.ToLower());

for write data on com port but when i send a large message it will hang my program any help.............
Posted

Change the value of your SerialPort.WriteBufferSize Property[^] - it defaults to 2048, and when it fills the buffer, it will pause your task until it has space. Since COM ports tend to be rather slow devices (the baud rate you set when you configured it is in bits per second, so 9600 baud works out to around 1000 characters per second) it may need to wait some time to complete the output if the message is a significant size.
 
Share this answer
 
Comments
Member 8806421 22-Jan-15 5:49am    
I have change size but not works for me
Apparently, it depends not only on your code (there is nothing wrong with it), but also on what happen on the other end of your RS-232 cable. All communication parameters should match, baud rate, stop bits, all of that, but, most importantly, something on the other end should read this data; until it's done, your side's code will be blocked. How else?

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900