Solved

Using serial port in DOS program running under Windows XP

Posted on 2004-09-22
6
400 Views
Last Modified: 2012-05-05
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)
0
Comment
Question by:jimrichmond
6 Comments
 
LVL 19

Accepted Solution

by:
RanjeetRain earned 168 total points
ID: 12122655
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
 

Author Comment

by:jimrichmond
ID: 12123465
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
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 166 total points
ID: 12124861
>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
 
LVL 3

Assisted Solution

by:sathisemail
sathisemail earned 166 total points
ID: 12130910
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

839 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