Date: Thu, 30 Oct 1997 21:38:21 +0000 From: coelho@compuland.com.br To: questions@freebsd.org Subject: Help to read parallel port Message-ID: <199710302337.VAA22350@sv.compuland.com.br>
next in thread | raw e-mail | index | archive | help
Hi:
    I need to convert this c++ code, originally made for Linux. It 
reads the parallel port. I want to set up a termometer, using a 
inexpensive sensor. My problem is that <asm/io.h> and the function 
ioperm, to open the lpt port...
Anyone has a tip ? What direction to do the same on a FreeBSD box ?
Thanks a lot!
Regards,
Helio.
#include <stdio.h>
#include <asm/io.h>
#define BASEPORT 0x3bc /* lp0 */
int main()
{
  /* Get access to parallelport */
  if (ioperm(BASEPORT,3,1)) {perror("ioperm");exit(1);}
  long result, numsamples, i;
  double temperature, offset, dutycycle;
  numsamples=1000000; // one million samples
  result=0;  
  for (i=0;i<numsamples;i++)  //count number of high samples on pin 11
  {
    result=((0x40 & inb(BASEPORT+1)) >> 6)+result;
    // bit-and with 0100000 (get level from pin 11 of statusreg.) //
    and shift right 6 steps, then add the number to result.
  }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199710302337.VAA22350>
