Click here to Skip to main content
15,920,632 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I met a problem with the call

lLastError = serial.Open(_T("COM4"),0,0,false); 


in the examples. The error is:

Unable to open COM-port (error code 5).

I must report that I’m using a USB dongle, but the Hyperterminal is OK for COM4. What to do now?

Thanks
Senmeis
Posted

I think you can try mscomm control
 
Share this answer
 
Make sure that you closed Hyperterminal: you cannot open the port twice from different applications.
BTW, I have no clue which library or class you are using to open the port. What does the error code 5 means exactly ?
 
Share this answer
 
It can also depend on the device/driver I've run into several usb/serial(dev boards) that require the device to be plugged into the same usb port whenever it is used because of how the driver registers the com port.

Have you tried using the standard windows api for serial devices? The DCB struct isn't nearly as scary as it looks and I've always had much better luck using the windows API than trying to use someone elses wrapper.

Also did you double check the baudrate for the port? Most serial issues are related to a settings problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900