What's SerialPort can not fire DataReceived event.

K

Kun-Yi

Hi everybody,

I have a C# program can to test serial port communication.
but it working on WM5 very well but on Windows CE 5.0 + NETCFV2Sp1/Sp2
is failed.
it is same hardware device and serial port driver(source code), and
using API is
Never fire "DataReceived" event on WinCE 5.0 platform.
I don't understand why? and what's root cause.

May you can give a hand?
 
D

Dick Grier

Hi,

I have a WinCE 5 Industrial PPC (Psion) that exhibits this problem. Quite a
bit of testing makes me think that it is a driver/OS image issue, related to
power-down. If I do a hard reset, and reload all of my software (usually),
the DataReceived event in generated. However, often when the PPC is
subsequently powered down and then powered back up, data no longer is
receive (polling does not work, either). I "think" that the serial driver,
or something related, enters some (bug) state that causes this.

BTW, the earlier version, WinCE 4.2 did not show this problem. Although the
vendor has tried to help, nothing has been resolved, so far.

The same issue shows itself with my CFSerialIO dll (see my homepage) and
with the Serial class from OpenNETCF -- so, I think it is outside my
control.

BTW, it is possible that there is an issue with your code (as Chris
mentioned). For example, you should make sure that both DTREnable and
RTSEnable = True.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
K

Kun-Yi

Dear Dick,
Thank you for your infomation. but my platform has serial
driver code and using API to operation it is fine.
and Using WM5 OS is OK. and when my device is clean boot still cannot
generation a "DataReceived" event.
I guess the event implement method is to create a thread to monitor RX
buffer and to compare "ReceivedByteThreshold" condition. When I to use
ReadExisting() can get Rx date, so I cannot accept the problem due to
serial driver has bugs.


BTW if your device just after suspend/resume has the issues. I guess
serial drivers reconfiguration UART GPIO when Power_Down but Power_Up
not to correct restore original setting.

BTW again thank you reply the mail.
Best regards,
KunYi
 
K

Kun-Yi

Dear All,
I check my code can get a serialport.BytesToRead property.
But it still not fire DataReceived Event

// my initial setting
serialPort.PortName = "COM1";
serialPort.ReceivedBytesThreshold = 1;
serialPort.DtrEnable = true;
serialPort.RtsEnable = true;
serialPort.Handshake = Handshake.None;
serialPort.BaudRate = 115200;
serialPort.DataBits = 8;
serialPort.Parity = Parity.None;
serialPort.StopBits = StopBits.One;
serialPort.DataReceived = new
SerialDataReceivedEventHandler(RxDataEvent);
serialPort.Open();
 
K

Kun-Yi

Dear All,
currently I confuse due to I using a USB to COM dongle(use FDTI
chip & driver) on the platform is OK,
Have anyone know NetCFV2 how to implement the event launch?
may be I can to check serial driver to meet the requirements.

best regards,
KunYI
 
D

Dick Grier

Hi,

If you poll (you can use a Timer, you don't need a thread), and test the
BytesToRead method, is there data available? If so, just read it there.
You actually do not need the DataReceived event if the Timer event (polling)
works.

BTW, you mention a USB adapter... I have absolutely no experience using USB
serial adapters on WinCE devices. I'd suspect a driver problem, but...

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
K

Kun-Yi

Hi Dick,
Thank you, about BytesToRead is OK and can get RX data.
But my customer want use DataReceived Event.
using Native API is OK. I guess NetCFv2 on my platform has a bug about
DataReceiverd Event.
I porting WM5 all serial driver part to WinCE 5 for testing. it's
still failed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top