Solved

Using serial port in DOS program running under Windows XP

Posted on 2004-09-22
6
389 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
Comment Utility
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
Comment Utility
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
Comment Utility
>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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now