Non-Standard baudrates opening COM ports

  • Thread starter Thread starter minimega
  • Start date Start date
M

minimega

Hello all NG,
I'm triyng to open CE com port using OpenNETCF Port library with
non-standard baudrates (ex.: 200bps, 360bps, 10400bps). Anyone know if
it can be done?

If it insn't possible in managed code (C#) is possible in eVC++ 4,0?
Anyone has a piece of code, please?

Thanks,
Massimo
 
That's up to the driver for the port. You can put whatever number you want
in the structure...

Paul T.
 
Hi Paul, thanks for the reply.

1) Can you explain me why in this simple code the
OpenNETCF.IO.Ports.SerialPort class raises a 53-Create file error and
OpenNETCF.IO.Serial.Port class is able to open and close COM2?

// CLASS OpenNETCF.IO.Ports.SerialPort
OpenNETCF.IO.Ports.SerialPort serialPort = new
OpenNETCF.IO.Ports.SerialPort("COM2", 19200,
OpenNETCF.IO.Ports.Parity.None, 8, OpenNETCF.IO.Ports.StopBits.One);

serialPort.Open();
serialPort.Close();

// CLASS OpenNETCF.IO.Serial.Port
OpenNETCF.IO.Serial.BasicPortSettings settings = new
OpenNETCF.IO.Serial.BasicPortSettings();
settings.BaudRate = OpenNETCF.IO.Serial.BaudRates.CBR_19200;
settings.ByteSize = 1;
settings.Parity = OpenNETCF.IO.Serial.Parity.none;
settings.StopBits = OpenNETCF.IO.Serial.StopBits.one;

OpenNETCF.IO.Serial.Port port = new
OpenNETCF.IO.Serial.Port("COM2", settings);
port.Open();
if (port.IsOpen)
port.Close();

2) The OpenNETCF.IO.Serial.BAUD.BAUD_USER enumarator can be used to set
non-standard baudrates? How can be used? With wich class must I use it:
OpenNETCF.IO.Serial.Port or OpenNETCF.IO.Ports.SerialPort?

thanks,
Massimo
 
Shouldn't there be a colon at the end of "COM2"?

I haven't had occasion to use the serial classes much, but my guess is that
you'd use things in the .Serial namespace with other things in the .Serial
namespace, so OpenNETCF.IO.Serial.BAUD.BAUD_USER would logically go with
OpenNETCF.IO.Serial.Port.

Again, if you really want to know if the driver support random baud rates,
write a simple C++ program to open and configure the port and see if you get
an error. If not, then it's possible. If so, then any screwing around with
managed code is irrelevant.

Paul T.
 
Hi Paul, thanks for the support.

My collegue, more expert in C++, has been able to make it works,
modifying the source code of WinCE serial driver. He said me he added
new new (fixed) non-standard baudrates to the vector in the .c source
and recompiled CE image. Now, when via C++ he call the SetCommState API
it return success and can exchange data.

Massimo
 
There you go. Callers from any language should be able to use that.

Paul T.
 
Back
Top