reading from a parallel port
Gordon Couger
agengcc at unx2.ucc.okstate.edu
Sun Apr 14 04:15:41 AEST 1991
>In article <1991Apr8.182526.17852 at ux1.cso.uiuc.edu> djk at ux1.cso.uiuc.edu (Doug Kelly) writes:
>Hello, Im trying to write a program to interface to my Epson ES-300C color
>scanner. It uses a bi-directional parallel interface, and i cant figure out
>how to 'read' from a parallel port. Im using borland turbo c, any help would
>be appreciated. Thanks
First you find the port number of the printer port. If using a IBM pc
Numerical Recipes in C is a very good source. The bring all the lines
on the printer port high. Then read the port. The device you are reading
must pull the desired pins low.
e.g.
#define PRINTER 0x?? // the port address of the printer port
char read_printer(void)
{
outportb(PRINTER, 0xFF); \\ set all bits high
// I am not sure of the command but is
// the out port byte not integer function
return(inportb(PRINTER); // returns the value
}
This has worked with all IBM PC printer ports I have tried it does not
follow the specs of the card. I have heard that it won't work on early
models. This method assumes open collector gates on the port this is not
guaranteed. If you must have a never fail guaranteed method you have to
use the 4 status lines and work out some way to handle it nibble at a
time. I don't remember these off hand but i can look them up and send
them to you US Snail.
Gordon
agengcc at unx2.ucc.okstate.edu (Gordon Couger)
them to you USnail.
C
}
A
?
>
>
>--
>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>mattl at ritcsh.csh.rit.edu ! Swapping memory to disk is virtually indespensible..
>mal6315 at ultb.rit.edu ! ----------------------------------------------------
>mal6315 at RITVAX ! new book: "#define art of C programming..."
More information about the Comp.lang.c
mailing list