Link to home
Start Free TrialLog in
Avatar of nthota
nthota

asked on

Reopening: Serial Port Programming

For one of my application I need to access the serial port of the PPC(I have a Compaq Aero 2180 having win CE 2.11) .I tried opening the port using the CreateFile statement, but it gave me an error saying
INVALID_HANDLE_VALUE. I tried running the program on the device as well as in emulation . It failed on both. In emulation I did kill  the NT serial drivers and started the CE ones(i.e NET STOP SERIAL and then NET START WCEEMULD), but that didnt help either. I used GetLastError() and the value it returned was 2(i.e The system cannot find the file specified).the code goes something like this.
                  .....
                  .....
                  LPCTSTR comport;
                  HANDLE h;
                  comport =TEXT("COM1:");
                  // open port for I/O
                  h = CreateFile(comport,
                                       GENERIC_READ|GENERIC_WRITE,
                                       0,NULL,
                                       OPEN_EXISTING,0,NULL);
Also tried writng it as
 h = CreateFile(TEXT("COM1:"),
                                       GENERIC_READ|GENERIC_WRITE,
                                       0,NULL,
                                       OPEN_EXISTING,0,NULL);
 After this, the h is simply "INVALID_HANDLE_VALUE", which means it failed to open the port. Can anyone suggest where I am doing it  wrong. Do I need to make any changes in the registry settings? Any help will be greatly appreciated .
Thanks
ASKER CERTIFIED SOLUTION
Avatar of alesp
alesp

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nthota
nthota

ASKER

Thanks for the suggestion.I guess there was some problem with my device then. I used the same code that I posted  and it worked well

regrads
Neelima