LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-21-2006, 02:57 PM   #1
ell
LQ Newbie
 
Registered: Jan 2006
Posts: 6

Rep: Reputation: 0
lpt bash command


Hello everyome!

I want to develop a littel program to control lpt port (project in electronic).

Someone know command (or site with command) to do this?

Sorry for very bad English..
Thanks, ell!
 
Old 01-21-2006, 03:18 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Assuming you're programming in C/C++, the easiest approach is something like this:

Code:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

...
  int fd = open ("/dev/lp0", O_RDWR|O_DIRECT, 0);
  if (fd < 0)
    perror ("Unable to open lp port!\n");

  ... construct some data to send to the printer port ...
  int iret = write (fd, buff, ct);
  if (iret < ct)
    perror ("I/O failure during write!\n");

  ... read some data back from the printer port ...
  iret = read (fd, buff, ct);
  if (iret < 0)
    perror ("I/O failure during read!\n");

  ... Done processing ...
  close (fd);
  ...
Although the standard "open/read/write" APIs are probably the best place to start, there are lots and lots of other alternatives available to you, depending on what your requirements are and/or what language(s) you're programming in.

For example, the O'Reilly "Linux Device Drivers" book has a whole chapter (Chap 9) on interfacing a custom kernel driver to your parallel port:

http://lwn.net/Kernel/LDD3/

'Hope that helps .. PSM

Last edited by paulsm4; 01-21-2006 at 03:23 PM.
 
Old 01-21-2006, 03:44 PM   #3
ell
LQ Newbie
 
Registered: Jan 2006
Posts: 6

Original Poster
Rep: Reputation: 0
bash=c?!

I'm new in linux..

Thanks, ell!
 
Old 01-21-2006, 08:04 PM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Sorry - I didn't notice your title line, I just read your text:
Quote:
I want to develop a littel program to control lpt port
If you simply want to print stuff, "lp" is the command; "cups" is generally the subsystem.

But, AFAIK, if you "want to control the LPT port" (separate and distinct from simply spooling stuff to the printer), you're probably going to have to use some programming language other than "bash".

These links might be of some use:
http://www.torque.net/linux-pp.html
http://www.epanorama.net/circuits/parallel_output.html
http://www.lvr.com/jansfaq.htm

Sorry I can't be of more help .. PSM

Last edited by paulsm4; 01-21-2006 at 08:13 PM.
 
Old 01-22-2006, 02:28 PM   #5
ell
LQ Newbie
 
Registered: Jan 2006
Posts: 6

Original Poster
Rep: Reputation: 0
First, Thank you for the help!

If I understand you good, there is no option to control in circuits like this:
www
.epanorama.net/circuits/lptleds.gif
in Bash?

Thank you for your help!
ell
 
Old 01-22-2006, 02:43 PM   #6
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

There's ALWAYS a way - depending on how tricky and clever you want to get.

But no, as far as I know, this is probably a job for 'C' (or a similar systems-level language).

Sorry I can't be of more help ... and I'm 100% prepared to be wrong ;-)

Your .. PSM
 
Old 01-22-2006, 03:43 PM   #7
ell
LQ Newbie
 
Registered: Jan 2006
Posts: 6

Original Poster
Rep: Reputation: 0
O.K.
Thank you for the information!
Have a nice day!
ell
 
  


Reply


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
bash: <command name> command not found smash Programming 5 03-13-2006 08:48 AM
Programming through lpt Fcm Linux - Software 0 05-13-2005 06:50 PM
Samba LPT printer cb9fl Linux - Networking 1 03-16-2005 12:03 PM
No LPT port for printer!! akudewan Linux - Hardware 2 08-20-2004 12:23 AM
Wine Probs and LPT hesnotright Linux - Software 0 01-30-2003 11:36 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:10 PM.

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