Problems with USB PL2303 usb to serial adapter
While evolutioning to .NET, I had had problems in my old Visual C++ MFC software with a specific USB to serial adapter. The software used to work more or less with all the USB adapters, but was not able to work with this one. We use the adapter to connect to a GSM modem at a speed of 9600 bps.
The driver was the last version and also it was correctly installed (I was able to sends commands to the modem from the Hyperterminal software). What was happening? A problem with the setup of the serial port. If I put the option "use 2 stop bits" while I open the port, the adapter doesn´t work correctly.
/* Fill in the DCB: baud=9600, 8 data bits, no parity, 1 stop bit. */
dcb.BaudRate = Speed;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = TWOSTOPBITS;
fSuccess = SetCommState(hCom, &dcb);
I have changed this option to ONESTOPBIT, and it starts working without problems.
The driver was the last version and also it was correctly installed (I was able to sends commands to the modem from the Hyperterminal software). What was happening? A problem with the setup of the serial port. If I put the option "use 2 stop bits" while I open the port, the adapter doesn´t work correctly.
/* Fill in the DCB: baud=9600, 8 data bits, no parity, 1 stop bit. */
dcb.BaudRate = Speed;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = TWOSTOPBITS;
fSuccess = SetCommState(hCom, &dcb);
I have changed this option to ONESTOPBIT, and it starts working without problems.

0 Comments:
Post a Comment
<< Home