Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-01-2009, 11:53 AM   #1
LQ Newbie
Registered: Jul 2008
Posts: 2

Rep: Reputation: 0
Writing to the parallel port


I want to write C code to be able to write string to my printer via the parallel port.

The printer that I used is a Zebra.

I know that I need to use "ioperm (BASEPORT, 1, 1)" where BASEPORT is 0x378.

I know that I need to use "outb(value, BASEPORT)" function. I assume that "value" needs to be a byte. Please, let me know if I am wrong.

If it is the case, how can I send a "string" to my parallel port? In Windows, I used "fputs". Is there any equivalent?

Should I stick with "outb" and do something like a loop through my string and send byte by byte that string? If so, how do you suggest to do it?

Big thanks!
Old 10-01-2009, 06:42 PM   #2
Registered: Mar 2009
Distribution: CentOS - Ubuntu - Debian
Posts: 83

Rep: Reputation: 27

Actually, Linux defines the parallel port like /dev/parport0 or /dev/lp0 in some
cases, so your program need to open the port like a file (you will need write permissions)
and the use something like fputs or fprintf to send data.

Another approach should be to configure the printer in your Linux system,
have your program output data to a file and then use the commands
lp or lpr to print that file, that way you don't have to mess around with
the permissions or access directly the parallel port.

Best regards,


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing own parallel port driver mathimca05 Linux - Kernel 1 10-08-2008 07:03 AM
Parallel Port & Serial Port device identification helpmeforlinux Linux - Hardware 3 01-02-2007 02:15 AM
illegal seek when writing to parallel port pzydak Programming 1 12-08-2006 08:06 AM
Writing to parallel port 0x37a works, 0x378 don't Pier Linux - Hardware 3 06-27-2006 05:51 PM
Cannot use parallel port under 2.6.4 jimbob1234 Slackware 2 03-14-2004 09:34 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:42 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration