Using serial port in DOS program running under Windows XP

We make a computerized engraver that is driven from a PC through the serial port.  The software in the PC is a DOS based program written and compiled in PowerBasic.  When we run this program under Windows XP everything works OK other than periodically the stream of data being sent out the serial port gets a few bytes screwed up which makes the application useless.  We have monitored the data coming out the port and can see that every now and then a couple bytes are not correct.  XP must be periodically  polling the port or something like that.  Does anybody have any ideas on how to fix this?  (Serial port is com1 or 2, 9600 baud, odd parity, 7 data bits, 2 stop bits, hardwire handshaking)
jimrichmondAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
RanjeetRainConnect With a Mentor Commented:
I do not think you can fix it. Not atleast without porting your DOS app to a 32 bit console based program. Once you do that, you can capture the port and I am sure you will be able to run it painlessly.
0
 
jimrichmondAuthor Commented:
I have no idea how to port a DOS app to a 32 bit console based program. Does this involve rewriting the whole app in a windows base compiler?
0
 
Jaime OlivaresConnect With a Mentor Software ArchitectCommented:
>I have no idea how to port a DOS app to a 32 bit console based program. Does this involve rewriting the whole app in a windows base compiler?
Yes, you have to migrate, and I can ensure you that is your best option.

The problem is that Windows XP (and other) can't warranties you to give you all the process time. Maybe you can increase priority, but is not totaly sure.
Serial communications in Windows works with an interrupt driven method, so you will never loose a character.

0
 
sathisemailConnect With a Mentor Commented:
The problem is that Windows XP won't allow user programs to directly communicate with the I/O ports. All are accomplished through API calls only since user programs under windows XP works in protected mode. So the data sent to serial ports by the user program will be sent through API, whihc will change the data to a pre-described format.

Under Windows XP, there are only two I/O privilege levels used, level 0 & level 3. Usermode programs will run in privilege level 3, while device drivers and the kernel will run in privilege level 0, commonly referred to as ring 0. This allows the trusted operating system and drivers running in kernel mode to access the ports, while preventing less trusted usermode processes from touching the I/O ports and causing conflicts. All usermode programs should talk to a device driver which arbitrates access

To overcome the problem you can use the UserPort freeware from

http://www.embeddedtronics.com/public/Electronics/minidaq/userport/UserPort.zip.

This is a simple kernel mode driver for Windows NT/2000/XP that will give programs access to I/O ports. This makes it possible to access the hardware I/O ports directly under Windows NT/2000/XP just like 95/98/ME. Under XP, you may have to set the compatibility mode for the executable to "Windows 98" mode.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.