[comp.lang.c] reading from a parallel port

djk@ux1.cso.uiuc.edu (Doug Kelly) (04/09/91)

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

Doug
djk@ux1.cso.uiuc.edu

dave@cs.arizona.edu (Dave Schaumann) (04/09/91)

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 must acculate the flattle scanner, making sure the ooger-binaryies
are properly aligned to the rotational vector of the Hozel unit.  Then, just
framulate the scanner port, and all will be well.
-- 
Dave Schaumann | dave@cs.arizona.edu | Short .sig's rule!

slootman@dri.nl (Paul Slootman) (04/09/91)

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

Assuming you're on some IBM PC-compatible,
simply do a inportb() (reads a byte from hardware port) from the data latch
corresponding to the parallel interface. For example, to get the byte on a
printer port at 0x378, do

	x=inb(0x378);

This is not, in fact, a C question; I've redirected followups to
comp.os.msdos.programmer.

Paul.
-- 
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
: slootman@dri.nl            :          Don't hit the keys so hard, :
: ...!hp4nl!dri500!slootman  :                             it hurts :
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

jap@convex.cl.msu.edu (Joe Porkka) (04/10/91)

dave@cs.arizona.edu (Dave Schaumann) writes:

>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

How has this ANYTHING at all to do with C???

This is a *VERY* *MACHINE* *SPECIFIC* question.
Why don't you try asking this in an appropriate group?

mattl@ritcsh.csh.rit.edu (FaceMan) (04/10/91)

In article <1991Apr9.205714.14917@msuinfo.cl.msu.edu> jap@convex.cl.msu.edu (Joe Porkka) writes:
>dave@cs.arizona.edu (Dave Schaumann) writes:
>
>>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
>
>How has this ANYTHING at all to do with C???
   It's written in C. Would comp.lang.pascal been better?
>
>This is a *VERY* *MACHINE* *SPECIFIC* question.
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   It is? Hmmm, coulda sworn parellel ports were pretty standard.....

>Why don't you try asking this in an appropriate group?
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   Which is?


-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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..."

wolfram@cip-s08.informatik.rwth-aachen.de (Wolfram Roesler) (04/11/91)

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

This is not a C question since C has no standard mechanism to read from
interfaces. The answer to your question is dependant upon the OS you are
using. In Unix for example all ports can be accessed via files in the /dev
directory. There is no OS-independant solution.
Sorry
Okami-san

wolfram@cip-s08.informatik.rwth-aachen.de (Wolfram Roesler) (04/12/91)

jap@convex.cl.msu.edu (Joe Porkka) writes:

>dave@cs.arizona.edu (Dave Schaumann) writes:

>>>how to 'read' from a parallel port.  Im using borland turbo c, any help would
>>>be appreciated.  Thanks
>How has this ANYTHING at all to do with C???
>This is a *VERY* *MACHINE* *SPECIFIC* question.
>Why don't you try asking this in an appropriate group?

Ok, perhaps he didnt know that C has no solution for this. I'm sure he didnt,
since if he had he would have said for what machine. No reason to shout about.
Have you never been a beginner?

agengcc@unx2.ucc.okstate.edu (Gordon Couger) (04/14/91)

>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..."