SerialPort recieved data  
Author Message
Lolka





PostPosted: .NET Base Class Library, SerialPort recieved data Top

Hello, EveryBody.

I write the app for NORTEL ATS, wich connected to PC by COM. This ATS sending data to COM about every 30 mins. i recieve strange chars... 1006, 288, 992, 1312... some garbage, and then app crashed, with exception on readchar(). may be something with encoding i chosed UTF8.

for reading data i use DataReceived Event handler

and then:

char ch;

if (SerialData.Chars == e.EventType){

while (serialPort1.BytesToRead>0){

try

{

ch = Convert.ToChar(serialPort1.ReadChar());

}



.NET Development19  
 
 
nobugz





PostPosted: .NET Base Class Library, SerialPort recieved data Top

Knowing what exception ReadChar() throws would be quite helpful. Encoding doesn't sound like the problem, the codes you see don't readily translate to something recognizable. Check your baudrate setting. And use the Windows HyperTerminal applet to check basic communication settings.