?
Solved

Serial Port Programming

Posted on 2000-03-29
3
Medium Priority
?
326 Views
Last Modified: 2013-12-27
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.
.....
.....
TCHAR comport;
HANDLE h;
comport =TEXT("COM1:");
// open port for I/O
h = CreateFile(comport,
                     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
0
Comment
Question by:nthota
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Accepted Solution

by:
CharlesDHManning earned 30 total points
ID: 2667343
I think you want
TCHAR *comport instead of TCHAR comport.
0
 

Author Comment

by:nthota
ID: 2669575
There is a little correction I need to make in the code I posted, I defined comport as LPCSTR and not TCHAR. that is the reason I wrote it as
 comport = TEXT("COM1:")
I redefined it as TCHAR *comport, but  that didnt work either. I also tried writing it directly as
h = CreateFile(TEXT("COM1:")                                      GENERIC_READ|GENERIC_WRITE,
                                       0,NULL,
                                       OPEN_EXISTING,0,NULL);
but of no use. Do you have any other suggestions?
Thanks
Neelima
0
 

Author Comment

by:nthota
ID: 2669603
There is a little correction I need to make in the code I posted, I defined comport as LPCTSTR and not TCHAR. that is the reason I wrote it as
 comport = TEXT("COM1:") I redefined it as TCHAR *comport, but  that didnt work either. I also tried writing it directly as
h = CreateFile(TEXT("COM1:"),GENERIC_READ|GENERIC_WRITE, 0,NULL,  OPEN_EXISTING,0,NULL);
but of no use. Do you have any other suggestions?
 Thanks
 Neelima
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are anything like me, you install many apps on your phone and have your life on it, sometimes literally.  When I bought my current phone, a Samsung Galaxy S5 from Verizon, they were only selling the versions with 16 GB internal.  I didn't rea…
You should read OS supplied guidelines before developing. I can't stress that enough. The guidelines will help you understand the reasons mobile app developers do what they do.  Apple is very particular when they review appstore submissions.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month13 days, 7 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question