.net - Serial Data Not Transmitted in C# Application -


I have a C # application in which serial (COM1) data is not transmitted sometimes following a simplified code of my code The snippet is (the text that the text box has been deleted):

  initialize company () {// // serialPort1 // this.serialPort1.BaudRate = 115200; This.serialPort1.DiscardNull = True; SerialPort1.ReadTimeout = 500; This serialPort1. Recyclable Handhold = 2; SerialPort1.WriteTimeout = 500; This serialPort1.DataReceived + = New system.IO.Ports.SerialDataReceivedEventHandler (this. SerialPort1_DataReceived); } If (radioButtonUart9600.Checked) {serialPort1.BaudRate = 9600; Try SerialPort1.Open (); } Hold (SystemException pre) {/ * ... * /}} Try {serialPort1.Write ("D"); SerialPort1.Write (msg, 0, 512); SerialPort1.Write ("D"); SerialPort1.Write (pCsum, 0, 2); What is strange is that this code works fine when the port is configured for 115.2 kbps. However, 9600 BPS data does not seem to be transmitted by this code while running on data. I have confirmed it by monitoring the receiving flag on a remote device. No exception is thrown from within the try statement. Is there anything else (flush, etc.) What should I do to ensure that the data is transmitted? Your thoughts or suggestions will be appreciated. I am using the Microsoft Visual C # 2008 Express Edition Thank you. 

Hold / Pause these attempts will give you an opportunity to see timeout expansions because you have written the WriteTimeout value Very few sets have been sent 516 bytes to 9600 baud 538 milliseconds.

There are also dishes for your other settings trouble, ReceivedBytesThreshold get rid of and defect.


Comments