Problem z serialPort.ReadLine

  • 0 Odpowiedzi
  • 2258 Wyświetleń

0 użytkowników i 1 Gość przegląda ten wątek.

Problem z serialPort.ReadLine
« dnia: Sierpień 22, 2010, 16:23:08 »
Witam mam dziwny problem z  readLine.
Pisze program na windows mobile 6 standard  framework 3.5. Podaje kawałek kodu który nasłuchuje odbiór danych przez bluetooth

 this.serialPort1.Open();
.
.
.
 this.serialPort1.NewLine = "/n";
 string odpowiedz = this.serialPort1.ReadLine();
 textBox1.Text = odpowiedz;

Program kompiluje się normalnie, na emulatorze też wszystko działa.

Ale gdy włączam nasłuchiwanie na telefonie, to wyskakuje mi błąd zgłaszany na linii -  string odpowiedz = this.serialPort1.ReadLine();

TimeOutException was unhandled.
An error message is available for this exception but cannot be displayed because these messages are optional and are not currently installed on this device. Please install ‘NETCFv35.Messages.EN.wm.cab’ for Windows Mobile 5.0 and above or  ‘NETCFv35.Messages.EN.cab’ for other platforms. Restart the application to see the message.

Instalowałem o co proszą aby zobaczyć o co chodzi ale cały czas pojawia się ten komunikat.

I dodam że serialPort.ReadExisting(); dziala normalnie


Proszę o pomoc. Pozdrawiam

Połączone: Sierpień 22, 2010, 19:55:39
Ok. Poradziłem sobie.

Problem leżał w tym że wywoływałem serialPort.readLine gdy bufor był pusty.

Funkcja działa wtedy gdy wysłałam wcześniej informację do bufora i dopiero  wtedy odczytuje.

Pozdrawiam
« Ostatnia zmiana: Sierpień 22, 2010, 19:55:39 wysłana przez Pakula »