OpenNETCF Serial not working in my WinCE 5.0 device


G

Guest

Hi all,I am running the OpenNETCF.Serial.IO library under WinCE 5.0 device. I
am able to connect to my embedded modem (COM4) successfully via Hyperterminal
and successfully issue AT command in hyperterminal.
However, when I try to run on the sample app built by me , which is using
the mentioned library, whenever I try to issue an AT command, I will receive
Framing error. Anybody can help me solve this?
Here is the port settings:

Port Name: COM4:
BaudRate: 115200
Byte Size: 8
Parity: None
StopBits: One

The application works fine in another WinCE device(WinCE 4.2) which have the
following configuration:

Port Name: COM3:
BaudRate: 9600
Byte Size: 8
Parity: None
StopBits: One

I also downloaded the sample app from
http://msdn.microsoft.com/mobility/default.aspx?pull=/library/en-us/dnnetcomp/html/PISAPICF.asp
and try to run it on Win5.0 device, also fail (but pass on WinCE 4.2
device).Any Clue?
 
Ad

Advertisements

P

Paul G. Tobey [eMVP]

A framing error indicates that the parity or the byte size is wrong,
generally. You might set a breakpoint at the point where you're about to
send the data and check the current settings for the port you're sending it
on and make sure they match the external device. It sounds to me like
you've set the parameters, or one of them, to the wrong instance of the
RS232 class or something like that (copy/paste error, maybe).

Paul T.
 
G

Guest

Hi,
can I know how can I get the port settings at the point before sending out
the data as the port is an IntPtr type? I checked the settings I sent out
when I open the device:

bool bReturn = CommAPI.SetupComm(hPort, rxBufferSize, txBufferSize);

// transfer the port settings to a DCB structure
dcb.BaudRate = (uint)portSettings.BasicSettings.BaudRate;
dcb.ByteSize = portSettings.BasicSettings.ByteSize;
dcb.EofChar = (sbyte)portSettings.EOFChar;
dcb.ErrorChar = (sbyte)portSettings.ErrorChar;
dcb.EvtChar = (sbyte)portSettings.EVTChar;
dcb.fAbortOnError = portSettings.AbortOnError;
dcb.fBinary = true;
dcb.fDsrSensitivity = portSettings.DSRSensitive;
dcb.fDtrControl = (DCB.DtrControlFlags)portSettings.DTRControl;
dcb.fErrorChar = portSettings.ReplaceErrorChar;
dcb.fInX = portSettings.InX;
dcb.fNull = portSettings.DiscardNulls;
dcb.fOutX = portSettings.OutX;
dcb.fOutxCtsFlow = portSettings.OutCTS;
dcb.fOutxDsrFlow = portSettings.OutDSR;
dcb.fParity = (portSettings.BasicSettings.Parity == Parity.none) ? false
: true;
dcb.fRtsControl = (DCB.RtsControlFlags)portSettings.RTSControl;
dcb.fTXContinueOnXoff = portSettings.TxContinueOnXOff;
dcb.Parity = (byte)portSettings.BasicSettings.Parity;
dcb.StopBits = (byte)portSettings.BasicSettings.StopBits;
dcb.XoffChar = (sbyte)portSettings.XoffChar;
dcb.XonChar = (sbyte)portSettings.XonChar;

dcb.XonLim = dcb.XoffLim = (ushort)(rxBufferSize / 10);

CommAPI.SetCommState(hPort, dcb);

and I am sure the settings is correct because when I tested on HyperTerminal
using the same setting, it works.
Any idea?
 
Ad

Advertisements

P

Paul G. Tobey [eMVP]

Hyperterminal isn't a very good test. It's *extremely* tolerant of
incorrect settings. I can't think of anything, other than your code just
being wrong, that would explain the error, except for a real mismatch of
parity or character size. I can tell you what I'd do, write the code in C
and verify whether it happens or not there. That would remove any potential
bugs in the OpenNETCF code (you might verify from the vault that you have
the latest source). If it does happen, I believe that it's a real mismatch
in the settings...

Paul T.
 

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