Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using serial port in DOS program running under Windows XP

Posted on 2004-09-22
6
Medium Priority
?
442 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
[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
6 Comments
 
LVL 19

Accepted Solution

by:
RanjeetRain earned 672 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 664 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 664 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Six Sigma Control Plans
Introduction to Processes

636 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