Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 Mar 2000 15:30:49 -0500
From:      Edward Gold <edgold@mindspring.com>
To:        "hackers@FreeBSD.ORG" <hackers@FreeBSD.ORG>
Subject:   I am having serious problems with ppi0, can anybody help?
Message-ID:  <38E50AF8.B9B279DF@mindspring.com>

next in thread | raw e-mail | index | archive | help

--------------4C38CF90EFAA1418230E361F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit



I seem to be crashing my system every time I attempt to open /dev/ppi0!
I get a kernel panic, and it usually explains that nexus_setup_intr is
unhappy.  I traced this all down to  /usr/src/sys/i386/i386/nexus.c
where it claims that somebody tried to setup an irq that failed to
allocate.  I suspected that I might have a kernel slightly out of sync
with my libraries, so I did the complete cvsup, buildworld, and
installworld last night.  Everything seems to be operating correctly,
with the exception of the ppi driver.

The piece of code I was running looks like this:

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/fcntl.h>

#define PPIGDATA        _IOR('P', 10, u_int8_t)
#define PPIGSTATUS      _IOR('P', 11, u_int8_t)
#define PPIGCTRL        _IOR('P', 12, u_int8_t)
#define PPIGEPPD        _IOR('P', 13, u_int8_t)
#define PPIGECR         _IOR('P', 14, u_int8_t)
#define PPIGFIFO        _IOR('P', 15, u_int8_t)

#define PPISDATA        _IOW('P', 16, u_int8_t)
#define PPISSTATUS      _IOW('P', 17, u_int8_t)
#define PPISCTRL        _IOW('P', 18, u_int8_t)
#define PPISEPPD        _IOW('P', 19, u_int8_t)
#define PPISECR         _IOW('P', 20, u_int8_t)
#define PPISFIFO        _IOW('P', 21, u_int8_t)

#define PPIGEPPA        _IOR('P', 22, u_int8_t)
#define PPISEPPA        _IOR('P', 23, u_int8_t)
#define n(flags) (~(flags) & (flags))

/*
 * Parallel Port Chipset control bits.
 */
#define STROBE          0x01
#define AUTOFEED        0x02
#define nINIT           0x04
#define SELECTIN        0x08
#define IRQENABLE       0x10
#define PCD             0x20

#define nSTROBE         n(STROBE)
#define nAUTOFEED       n(AUTOFEED)
#define INIT            n(nINIT)
#define nSELECTIN       n(SELECTIN)
#define nPCD            n(PCD)


int pport_fd;

main()
{
  unsigned char data, status, ctrl;
  int pattern = 'A';

  pport_fd = open( "/dev/ppi0", O_RDONLY );
  if( pport_fd < 0 )
  {
    fprintf( stderr, "\nFailed to open printer port! 0x%x\n", pport_fd
);
    exit( 1 );
  }
  else
  {
    printf( "\nopened port\n" ); fflush( stdout );
  }

  while( 1 )
  {
    ioctl( pport_fd, PPIGDATA,   &data );
    ioctl( pport_fd, PPIGSTATUS, &status );
    ioctl( pport_fd, PPIGCTRL,   &ctrl );

    printf("Status: 0x%.2x, Ctrl: 0x%.2x, Data: 0x%.2x\n", status, ctrl,
data);
    sleep( 1 );
  }
}


It explodes when it hits the open() statement.  The only other clue I
have is that I always find a lpd.core lying around in /, but the date is
way off.  Does anyone have a clue whats going on?

Also, what I am really trying to do here is read a signal pin into
FreeBSD somehow.  Its either 0 or +5V and it doesn't have to be
real-time or fast or anything but accurate.  I just basically want to
sample and detect whether or not a button on a custom panel is being
pressed or not.  We would even be willing to get the signal in through
the PE, -ACK, or whatever pins.

I have tried going through the /dev/joy0 interface and it doesn't seem
to sense anything ( though the hardware is  PC-104 stuff, so I didn't
put much faith in this ).  The joy device driver does detect the port
and it seems to read something, but its always the same value.   I don't
actually have a joystick to test this, so this could actually be working
but I might not be pulling the pins to ground or +5 or whatever they are
supposed to be pulled to.

One thing that makes me very proud of FreeBSD is that its device drivers
actually did work with the sound card DSP whereas the manufacturer's
drivers did not!  Also, this sysem uses the M-systems Disk On Chip2000,
and FreeBSD already had the support right there in the LINT file, while
Linux would have required kernel and LILO patches.




--------------4C38CF90EFAA1418230E361F
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
&nbsp;
<p>I seem to be crashing my system every time I attempt to open /dev/ppi0!&nbsp;
I get a kernel panic, and it usually explains that nexus_setup_intr is
unhappy. &nbsp;I traced this all down to&nbsp; /usr/src/sys/i386/i386/nexus.c&nbsp;
where it claims that somebody tried to setup an irq that failed to allocate.&nbsp;
I suspected that I might have a kernel slightly out of sync with my libraries,
so I did the complete cvsup, buildworld, and installworld last night.&nbsp;
Everything seems to be operating correctly, with the exception of the ppi
driver.
<p>The piece of code I was running looks like this:
<p><tt>#include &lt;unistd.h></tt>
<br><tt>#include &lt;stdio.h></tt>
<br><tt>#include &lt;stdlib.h></tt>
<br><tt>#include &lt;sys/ioctl.h></tt>
<br><tt>#include &lt;sys/fcntl.h></tt><tt></tt>
<p><tt>#define PPIGDATA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _IOR('P',
10, u_int8_t)</tt>
<br><tt>#define PPIGSTATUS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _IOR('P', 11,
u_int8_t)</tt>
<br><tt>#define PPIGCTRL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _IOR('P',
12, u_int8_t)</tt>
<br><tt>#define PPIGEPPD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _IOR('P',
13, u_int8_t)</tt>
<br><tt>#define PPIGECR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
_IOR('P', 14, u_int8_t)</tt>
<br><tt>#define PPIGFIFO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _IOR('P',
15, u_int8_t)</tt><tt></tt>
<p><tt>#define PPISDATA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _IOW('P',
16, u_int8_t)</tt>
<br><tt>#define PPISSTATUS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _IOW('P', 17,
u_int8_t)</tt>
<br><tt>#define PPISCTRL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _IOW('P',
18, u_int8_t)</tt>
<br><tt>#define PPISEPPD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _IOW('P',
19, u_int8_t)</tt>
<br><tt>#define PPISECR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
_IOW('P', 20, u_int8_t)</tt>
<br><tt>#define PPISFIFO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _IOW('P',
21, u_int8_t)</tt><tt></tt>
<p><tt>#define PPIGEPPA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _IOR('P',
22, u_int8_t)</tt>
<br><tt>#define PPISEPPA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _IOR('P',
23, u_int8_t)</tt>
<br><tt>#define n(flags) (~(flags) &amp; (flags))</tt><tt></tt>
<p><tt>/*</tt>
<br><tt>&nbsp;* Parallel Port Chipset control bits.</tt>
<br><tt>&nbsp;*/</tt>
<br><tt>#define STROBE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
0x01</tt>
<br><tt>#define AUTOFEED&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x02</tt>
<br><tt>#define nINIT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
0x04</tt>
<br><tt>#define SELECTIN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x08</tt>
<br><tt>#define IRQENABLE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x10</tt>
<br><tt>#define PCD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
0x20</tt><tt></tt>
<p><tt>#define nSTROBE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
n(STROBE)</tt>
<br><tt>#define nAUTOFEED&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n(AUTOFEED)</tt>
<br><tt>#define INIT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
n(nINIT)</tt>
<br><tt>#define nSELECTIN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n(SELECTIN)</tt>
<br><tt>#define nPCD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
n(PCD)</tt>
<br><tt></tt>&nbsp;<tt></tt>
<p><tt>int pport_fd;</tt><tt></tt>
<p><tt>main()</tt>
<br><tt>{</tt>
<br><tt>&nbsp; unsigned char data, status, ctrl;</tt>
<br><tt>&nbsp; int pattern = 'A';</tt><tt></tt>
<p><tt>&nbsp; pport_fd = open( "/dev/ppi0", O_RDONLY );</tt>
<br><tt>&nbsp; if( pport_fd &lt; 0 )</tt>
<br><tt>&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp; fprintf( stderr, "\nFailed to open printer port!
0x%x\n", pport_fd );</tt>
<br><tt>&nbsp;&nbsp;&nbsp; exit( 1 );</tt>
<br><tt>&nbsp; }</tt>
<br><tt>&nbsp; else</tt>
<br><tt>&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp; printf( "\nopened port\n" ); fflush( stdout
);</tt>
<br><tt>&nbsp; }</tt><tt></tt>
<p><tt>&nbsp; while( 1 )</tt>
<br><tt>&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp; ioctl( pport_fd, PPIGDATA,&nbsp;&nbsp; &amp;data
);</tt>
<br><tt>&nbsp;&nbsp;&nbsp; ioctl( pport_fd, PPIGSTATUS, &amp;status );</tt>
<br><tt>&nbsp;&nbsp;&nbsp; ioctl( pport_fd, PPIGCTRL,&nbsp;&nbsp; &amp;ctrl
);</tt><tt></tt>
<p><tt>&nbsp;&nbsp;&nbsp; printf("Status: 0x%.2x, Ctrl: 0x%.2x, Data: 0x%.2x\n",
status, ctrl, data);</tt>
<br><tt>&nbsp;&nbsp;&nbsp; sleep( 1 );</tt>
<br><tt>&nbsp; }</tt>
<br><tt>}</tt>
<br><tt></tt>&nbsp;
<p>It explodes when it hits the open() statement.&nbsp; The only other
clue I have is that I always find a lpd.core lying around in /, but the
date is way off.&nbsp; Does anyone have a clue whats going on?
<p>Also, what I am really trying to do here is read a signal pin into FreeBSD
somehow.&nbsp; Its either 0 or +5V and it doesn't have to be real-time
or fast or anything but accurate. &nbsp;I&nbsp;just basically want to sample
and detect whether or not a button on a custom panel is being pressed or
not. &nbsp;We would even be willing to get the signal in through the PE,
-ACK, or whatever pins. 
<p>I have tried going through the /dev/joy0 interface and it doesn't seem
to sense anything&nbsp;( though the hardware is&nbsp; PC-104 stuff, so
I didn't put much faith in this ). &nbsp;The joy device driver does detect
the port and it seems to read something, but its always the same value.&nbsp;&nbsp;
I don't actually have a joystick to test this, so this could actually be
working but I&nbsp;might not be pulling the pins to ground or +5 or whatever
they are supposed to be pulled to.
<p>One thing that makes me very proud of&nbsp;FreeBSD is that its device
drivers actually did work with the sound card DSP whereas the manufacturer's
drivers did not!&nbsp; Also, this sysem uses the M-systems Disk On Chip2000,
and FreeBSD already had the support right there in the LINT file, while
Linux would have required kernel and LILO patches.
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;</html>

--------------4C38CF90EFAA1418230E361F--



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?38E50AF8.B9B279DF>