Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!olivea!apple!uokmax!d.cs.okstate.edu!unx2.ucc.okstate.edu!agengcc From: agengcc@unx2.ucc.okstate.edu (Gordon Couger) Newsgroups: comp.lang.c Subject: Re: reading from a parallel port Message-ID: <1991Apr13.181541.24811@unx2.ucc.okstate.edu> Date: 13 Apr 91 18:15:41 GMT References: <1358@caslon.cs.arizona.edu> <1991Apr9.205714.14917@msuinfo.cl.msu.edu> <1991Apr10.161210.13518@ritcsh.csh.rit.edu> Organization: Oklahoma State University Computer Center Lines: 57 >In article <1991Apr8.182526.17852@ux1.cso.uiuc.edu> djk@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@unx2.ucc.okstate.edu (Gordon Couger) them to you USnail. C } A ? > > >-- >=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= >mattl@ritcsh.csh.rit.edu ! Swapping memory to disk is virtually indespensible.. >mal6315@ultb.rit.edu ! ---------------------------------------------------- >mal6315@RITVAX ! new book: "#define art of C programming..."