Program LPT and COM ports easily under windows NT-2000-XP
If you are working with embedded projects usually you have concerned about how directly control computer ports like LPT or COM. Basically no one wants to mess up with driver writing or reading tons of documentations in order to send some bytes via IO port to your target board.
Earlier when DOS, win95 and win98 operating systems were popular accessing I/O ports was easy as there weren’t any protections – simple code could do the job. Under NT/2000/XP situation is different. These operating systems has strict control of I/O ports. Read more about this here: www.beyondlogic.org.
If you will try to access ports directly under windows XP, then you will get error mesage:

How to solve this problem without writing your own driver and without rewriting old DOS or win98 programs. Well there is a solution that allow you to run programs under windows 2000/XP and talk to ports directly. Download PortTalk program from www.beyondlogic.org.
Now you have two ways of running programs – but don’t forget to read porttalk.pdf which is included in package.
- Solution No.1
Download portalk22.zip and unzip it in separate folder somewhere. Then copy allowio.exe directly to the directory where is you program which you want to run. Then create shortcut of your compiled program for instance demo.exe. Then open files properties and in line target do following changes:
Instead of:
D:/project/demo.exe
change to
D:/project/allowio.exe D:/project/demo.exe /a
This is it. Just remember that you must have administrator rights on this computer. Other wise you should run your program with administrator user rights. Dirty trick but it works.
- Solution No.2
Download same program packet portalk22.zip. In the packet besides the driver there is header files for working with ports directly under Windows NT/2000/XP.
Set up your compiler like DEV-CPP. It is free IDE and C/C++ compiler. Or you can use any commercial compiler package like Microsoft Visual C++ or even C++ builder.
Before you start compiling your program copy portalk.sys file to WINDOWS/System32/Drivers and copy pt_ioctl.c and PortTalk_IOCTL.h files to your project directory. Now you can start developing.
- Few words about Linux OS
For parallel port program uses ppdev interface of kernel. This is why with command lsmod you should make sure if this module is loaded:
root@xxx# /sbin/lsmod Module Size Used by Not tainted ppdev 5580 0 (unused) parport_pc 14724 0 parport 23264 0 [ppdev parport_pc]
Otherwise you have to load this module with command modprobe which is in the root:
root@xxx# /sbin/modprobe parport root@xxx# /sbin/modprobe parport_pc root@xxx# /sbin/modprobe ppdev
It is good practice if this command is performed during startup of operating system. These commands cam be added to script file rc.
For RedHat would be /etc/rc.d/rc.local or write to file /etc/modules.conf
For Slackware add them to file /etc/rc.d/rc.modules
#### PC parallel port support ### /sbin/modprobe parport_pc /sbin/modprobe ppdev /sbin/modprobe parport
Iy you want to work as other user without root rights you have to chmod ppdev interface by using comand (has to be performed under root rights):
# chmod 666 /dev/parport0
Before running your program make sure if there is no other programs running that serve for LPT printer. Otherwise you have to stop it before running your application.
Source: www.sapunoff.ru
Blogsphere: TechnoratiFeedsterBloglines
Bookmark: Del.icio.usSpurlFurlSimpyBlinkDigg
RSS feed for comments on this post | TrackBack URI for this post
New on WinAVR Tutorial
Running TX433 and RX433 RF modules with AVR microcontrollers,Sometimes in embedded design you may want to go wireless. Might be you will want to log various readi …Programming AVR ADC module with WinAVR,Most of AVR microcontrollers have Analog to Digital Converter (ADC) integrated in to chip. Such solut … |
New on WinARM Tutorial
What are differences between WinARM and WinAVR,Everyone who is working with AVR microcontrollers knows this powerful tool – WinAVR (http://win …LPC2000 watchdog timer,As in all microcontrollers watchdog timers purpose isto reset microcontroller after reasonable amount … |
