المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Reading from serial port



C# Programming
10-25-2013, 01:23 AM
I am trying to make a serial port terminal and i have succesfully made it except for some problems that i am facing.

i have a button pressing which the terminal starts and the data from the serial port start to get displayed on the textbox.
when i press the button again the serial port closes.

Also i have put the code to read from the serial port in a timer with a time of 1 millisecond. So it automatically works like a loop and the data can be displayed continuously.

Case 1. when i try reading from the serial port using

_SerialPort.ReadLine ()
what happens is that the data is getting displayed perfectly, but i am not able to press the button again to close the serial port, also i cant even close the application. I would have to use the task manager to kill the process.

Case 2. when i try reading from the serial port using

_SerialPort.ReadExisting ()

what happens is that the earlier issue is resolved, but the data that is received is not continuous, that is some values are not recieved.