Re: Can't open Serial port



1
a) No, debug or application use of COM1 is mutually exclusive. Your sample NK.bin from the CD is a ship build, with serial debug over COM1 disabled.

b) Check your registry settings; are you actually loading a serial driver for COM1? Write a simple program that uses "FindFirst/NextDevice" and see if COM1 is loaded, or connect the Remote Registry Editor and scan the HKLM\Drivers\Active keys and see if a driver for COM1 is loaded.


2
b) Looks like you didn't include any serial driver in your image. Select the right component and clean sysgen your workspace (be sure to read http://guruce.com/blogpost/whattobuildwhen first).


3.
a) ActiveSync won't work over serial if you don't include any serial drivers.
b) That's strange... Maybe ActiveSync pulls in a driver, but I don't think so... Check your registry settings (do a diff between the reginit of a kernel with and without ActiveSync).

Conclusions:
1. Yep.
2. But only on the kernel shipped with the board by the vendor.
3. Yep.

4: The problem is in your workspace configuration. You forgot to include a driver for serial, or the BSP you have is a different one from the BSP the vendor used to create the sample NK.BIN and the serial driver code/registry settings inside the BSP is/are wrong.


As for the rest of your questions: First follow the advice above, report back, and we'll go from there.


Good luck,

Michel Verhagen, eMVP
Check out my blog: http://GuruCE.com/blog

GuruCE Ltd.
Microsoft Embedded Partner
http://GuruCE.com
Consultancy, training and development services.

John wrote:
Hi guys,

Thank you all very much for the help. After another day of trying here is what I can report:

First something about my setup:

1. I have two computers connected separately to COM1 and COM2 of my development board to monitor their outputs.

2. In build options, I checked “enable eboot space in memory”, “enable ship build”, flush tracked events to release directory”, “Run-time image can be larger than 32MB”, “Use xcopy instead of links to populate release directory”

3. I checked “NET Compact Framework 2.0”. But I did not check “NET Compact Framework 2.0 string resources”.

4. My testing code was written in VB on VS2005. It is very simple: just set up a com port, open it and write “test” string to it.

5. I copy the “NK.bin” and my test program to a bootable CF card and use the CF card to boot.

6. After boot, I find my test program, double click it to run.

Note: I have two NK.bin files involved in this problem, one is a sample "NK.bin" from the board vendor. One is my "NK.bin" built by me.

Here is what I’ve got today:

1. When my test program is set to use COM1:
a) Boot with a sample “NK.bin” which came on the CD with the development board. My program works. When I start and stop my test program, I can see debug messages. And when my program is running, it continuously sends out “test” string (the write is on a timer). It seems the debug feature can co-exist with my program, sharing a COM port.
b) Boot with my “NK.bin” (built by me). When I double click my test program I’ve got the error messages described in my previous post.

2. Change my test program to use COM2.
a) Boot with the sample “NK.bin”. The test program still works. Now the “test” strings show up on the computer connected to COM2.
b) Boot with my own “NK.bin”. I’ve got the same error messages described before.
3. I build an “NK.bin” with ActiveSync catalog item checked.
a) I still can not open COM port in my test program. the same errors.
b) I can connect my development board to the computer connected to COM2 thru ActiveSync.

Some conclusions:
1. The hardware of both COM1 and COM2 works.
2. Both ports can be used by “standard” programs (ie. The built-in debug and ActiveSync)
3. My program works with either port if boot with the sample “NK.bin”.

Is it a driver problem?

1. If it is a driver’s problem, why would debug and ActiveSync work on my “NK.bin” OS? Do they use a different “driver”?
2. Could be the sample NK.bin uses a different driver than my NK.bin dioes? But I’d think whatever the driver used in sample NK.bin should be the same one used in the BSP I used to build my NK.bin because they are from the same vendor.

My puzzle:

1. My NK.bin was not built correctly. But then why the “standard” program works with my NK.bin?
2. Something is wrong in my program. But then why would it work with the sample NK.bin?

I think chance is high that my NK.bin was not built correctly. Can you guys give me more clues to follow?

Many many thanks.


"John" wrote:

Hi,

I am new to platform builder. I am trying to build a Wince 6.0 OS supporting the COM ports. But I can not open the COM port (COM1) when running my application code on the OS I built. It tells me an unexpected error happened

at System.IO.Ports.SerialStream.WinIOError()
at System.IO.Ports.SerialStream.CheckResult()
at System.IO.Ports.SerialStream.SetBufferSoze()
at System.IO.Ports.SerialPort.Open()
at ...
...

But I can receive these error messages from the COM1. So, the hardware is ok. In fact, my code (and COM1) runs ok with a sample "NK.bin" came with my development board. I contacted my board vendor. They think I need download updates from Microsoft. I did have downloaded CF service pack 2 before which solved a problem regarding the breakpoint. What microsoft update I may need to download this time? Any suggestions?

Many thanks.
.



Relevant Pages

  • Re: Cant open Serial port
    ... serial port is opened, then start the debug output again when it closes. ... are you actually loading a serial driver ... After boot, I find my test program, double click it to run. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Serial Port Application
    ... Although the serial com port I use is defined under. ... maybe because of a driver included in one build and not the ... >> I have not modified the registry at all and I always us a debug build. ... >> I have a serial port test program that I am having trouble with. ...
    (microsoft.public.windowsce.app.development)
  • Re: Serial Driver --> Unable to open COM1 Port ( transport and download port)
    ... If this is the case you won't have a driver loaded on COM1 instead it is the ... kernel talking to the HW directly, you need to make sure that the kernel ... transport and download port. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Have USB IrDA device on computer -- now what?
    ... After doing that, HyperTerminal or HPComm can connect using COM4, but trying to use COM1 will give me a "port in use by another application" error. ... by contrast, needs no protocol or data stream conversion, hence it needs no application or driver as "middleman," and the hardware device is indistinguishable to the PC from any other "serial-speaking" device, allowing applications to connect directly to COM1 as usual. ... from Windows 98 thru Windows XP, ...
    (comp.sys.hp48)
  • Re: COM2 Write, but no read
    ... Writes can often be handled by the driver without interrupts, ... I'd like to keep COM1 as the debugging port. ...
    (microsoft.public.windowsce.platbuilder)