wxSerialPort can't work with a USB CDC serial port

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Raul
In need of some credit
In need of some credit
Posts: 3
Joined: Thu Jul 22, 2010 7:17 am
Location: Spain
Contact:

wxSerialPort can't work with a USB CDC serial port

Post by Raul »

Hello guys, this is the first time I write in this forum and this is my question:

I have a device that can be connected to the PC using a serial interface or a USB interface.

In the other hand, I've an application (programmed using wxDevCpp) that opens a COM port.

The communication is fine while attaching the device via a normal COM wire. I must use the USB, so I programmed the CDC protocol and the communication is fine using the hyperterminal.

In my PC I see a "USB to UART" device connected and I get the COM21 port. This communication has been tested using hyperterminal and a Java programmed application, but when using the DevCPP application it doesn't works.

I use the wxSerialPort class to access the COM port, and it fails while opening my "USB to UART" COM port.

Have everybody experienced this problem???

Thank you very much¡
ngpaton
Knows some wx things
Knows some wx things
Posts: 25
Joined: Tue May 20, 2008 8:23 am

Post by ngpaton »

Hi Raul,

I'm not familiar with wxSerialPort. But one thing that can often catch people out when programming serial ports on windows is the naming of any com port above com9. See http://support.microsoft.com/kb/115831 for info.

Cheers

Nigel
Raul
In need of some credit
In need of some credit
Posts: 3
Joined: Thu Jul 22, 2010 7:17 am
Location: Spain
Contact:

Post by Raul »

Thank you Nigel.

I've solved one of my problems with your post. In my case, my device (using the USB CDC protocol) gives me a COM21 port. I detected the problem of using high numeration so, I changed it manually (I asigned the COM2 that was unnused...)

Using the wxSerialPort class in this way:

wxString PortName = "\\\\.\\COM21";
strcpy(devname, PortName.ToAscii());

if(com.OpenDevice(devname,&dcs) < 0) return(false);

Opens the port and sends correct data to the device but the response isn't received yet.

Thanks...

Raul.
Raul
In need of some credit
In need of some credit
Posts: 3
Joined: Thu Jul 22, 2010 7:17 am
Location: Spain
Contact:

Post by Raul »

Taking a look at the serport.h I've seen this:


#define wxCOM1 "com1"
#define wxCOM2 "com2"
#define wxCOM3 "com3"
#define wxCOM4 "com4"
#define wxCOM5 "com5"
#define wxCOM6 "com6"
#define wxCOM7 "com7"
#define wxCOM8 "com8"
#define wxCOM9 "com9"
#define wxCOM10 "\\\\.\\com10"
#define wxCOM11 "\\\\.\\com11"
#define wxCOM12 "\\\\.\\com12"
#define wxCOM13 "\\\\.\\com13"
#define wxCOM14 "\\\\.\\com14"
#define wxCOM15 "\\\\.\\com15"
#define wxCOM16 "\\\\.\\com16"
#define wxCOM17 "\\\\.\\com17"
#define wxCOM18 "\\\\.\\com18"
#define wxCOM19 "\\\\.\\com19"
#define wxCOM20 "\\\\.\\com20"
#define wxCOM21 "\\\\.\\com21"

so, I can use this defines.... :oops:
Post Reply