Project problem - linux printer port

Project problem - linux printer port

Post by smit » Mon, 12 Jul 1999 04:00:00



Project problem - linux printer port

I am trying to wire a simple video switch to the parallel port of a PC and
have Linux
it.

So far I have made a connector that fools linux into beleiving that it has a
printer
connected, and have sent data to it.

However I dont seem to be able to get the results I expect.

Im using "echo -ne '\361' >/dev/lp0" to output the byte.

I would expect results like this :

28    64    32    16    8    4    2    1     dec        oct

1       1      1      1                         1 = 1 (241)   361
1       1      1      1                  1        = 2 (242)   362
1       1      1      1             1             = 3 (244)   346
1       1      1      1      1                    = 4 (248)   370

What i'm getting is very confusing.........

Does anyone know if    a) the LP device is trying to do CRLF expansion ?
  or b) a simple working utility to output a byte to the data latch on
      parallel port ???

I'm using RedHat 6 on a Pentium.

Any help apreciated, please email me  - thanks


 
 
 

Project problem - linux printer port

Post by David B Anders » Wed, 14 Jul 1999 04:00:00




>Project problem - linux printer port

>I am trying to wire a simple video switch to the parallel port of a PC and
>have Linux
>it.

>So far I have made a connector that fools linux into beleiving that it has a
>printer
>connected, and have sent data to it.

You might find  the book
  Linux Device Drivers
  by Alessandro Rubini
  Pub by O'Reilly
useful.  It seems surprisingly easy to
work with the parallel port
(and to test the parallel port),  not that I've done
anything like it...



 
 
 

Project problem - linux printer port

Post by Peter Alle » Wed, 14 Jul 1999 04:00:00





> >Project problem - linux printer port

> >I am trying to wire a simple video switch to the parallel port of a PC and
> >have Linux
> >it.

> >So far I have made a connector that fools linux into beleiving that it has a
> >printer
> >connected, and have sent data to it.

> You might find  the book
>   Writing Linux Device Drivers
>   by Alessandro Rubini
>   Pub by O'Reilly
> useful.  It seems surprisingly easy to
> work with the parallel port
> (and to test the parallel port),  not that I've done
> anything like it...



This leads on to my problem brilliantly.  Thanks David :-)
First I think the original posters problem is that /dev/lp0 is
designed to run printers.  If you read the source (drivers/char/lp*.c)
then it has got things like excepting interupts on the
rising pulse rather than on the top.  /dev/parport* looked
good, except they didn't work for me, so I used the code
from WLDD ^^^^^.  (It is available from
ftp://ftp.oreilly.com/published/oreilly/linux/drivers/

I tried to compile it using gcc 2.7.3, which seems
to have tightened up its type checking, as I got lots
of warnings about incompatible pointer types.
Then the killer error,
cc -D__KERNEL__ -DMODULE -Wall -O2 -I/usr/include   -c short.c -o
short.o
short.c:177: warning: initialization from incompatible pointer type
short.c:178: warning: initialization from incompatible pointer type
short.c:184: warning: initialization from incompatible pointer type
short.c: In function `short_i_read':
short.c:199: wrong type argument to bit-complement
short.c: At top level:
short.c:231: warning: initialization from incompatible pointer type
short.c:232: warning: initialization from incompatible pointer type
short.c:238: warning: initialization from incompatible pointer type
short.c: In function `short_bh_interrupt':
short.c:345: warning: passing arg 1 of `do_gettimeofday' discards
`volatile' from pointer target type
make: *** [short.o] Error 1

The errors is on line 199
The code looks like
read_write_t is int.

read_write_t short_i_read (struct inode *inode, struct file *filp,
                char *buf, count_t count)
{
    int count0;

    while (short_head == short_tail) {
        interruptible_sleep_on(&short_queue);
        if (current->signal & ~current->blocked) /* a signal arrived */
// The error is here ^^^^^^^^^^^^^^^^^^^^^^^^
          return -ERESTARTSYS; /* tell the fs layer to handle it */
        /* else, loop */
    }
    /* count0 is the number of readable data bytes */
    count0 = short_head - short_tail;
    if (count0 < 0) /* wrapped */
        count0 = short_buffer + PAGE_SIZE - short_tail;
    if (count0 < count) count = count0;

    copy_to_user(buf, (char *)short_tail, count);
    short_tail += count;
    if (short_tail == short_buffer + PAGE_SIZE)
        short_tail = short_buffer;
    return count;

Quote:}

and I cannot find where the struct 'current' is defined.
If I could then I could work out what he is trying to do,
but as it is I cannot.

Thanks for any help,

                Peter Allen

 
 
 

Project problem - linux printer port

Post by David B Anders » Wed, 14 Jul 1999 04:00:00







>> >Project problem - linux printer port
[ ]
>> You might find  the book
>>   Writing Linux Device Drivers
>>   by Alessandro Rubini
>>   Pub by O'Reilly
>> useful.  It seems surprisingly easy to
[ ]
>This leads on to my problem brilliantly.  Thanks David :-)
>First I think the original posters problem is that /dev/lp0 is
>designed to run printers.  If you read the source (drivers/char/lp*.c)
>then it has got things like excepting interupts on the
>rising pulse rather than on the top.  /dev/parport* looked
>good, except they didn't work for me, so I used the code
>from WLDD ^^^^^.  (It is available from
>ftp://ftp.oreilly.com/published/oreilly/linux/drivers/

>I tried to compile it using gcc 2.7.3, which seems
>to have tightened up its type checking, as I got lots
>of warnings about incompatible pointer types.
>Then the killer error,
>cc -D__KERNEL__ -DMODULE -Wall -O2 -I/usr/include   -c short.c -o
>short.o
>short.c:177: warning: initialization from incompatible pointer type
>short.c:178: warning: initialization from incompatible pointer type
>short.c:184: warning: initialization from incompatible pointer type
>short.c: In function `short_i_read':
>short.c:199: wrong type argument to bit-complement
>short.c: At top level:
[ ]
>        interruptible_sleep_on(&short_queue);
>        if (current->signal & ~current->blocked) /* a signal arrived */
>// The error is here ^^^^^^^^^^^^^^^^^^^^^^^^
>          return -ERESTARTSYS; /* tell the fs layer to handle it */

Your friend here is -E
cc -E -D__KERNEL__ -DMODULE -Wall -O2 -I/usr/include   -c short.c  >junk

In junk, you will find blocked is a sigset_t, which *used* to be
a long according to comments,
but is now a struct containing longs
(~ of a struct won't work!).
So the code must just be fixed a bit.

The short.c:177: warning: initialization from incompatible pointer type
worries me as the signature of the short_read function does not
match the foperation read pointer
(say for the read member and the short_read
function, line 177) type. However, if the call
used does the right things...
but I did not follow up on that, so no guarantees from me!


 
 
 

Project problem - linux printer port

Post by Peter Alle » Fri, 16 Jul 1999 04:00:00








> >> >Project problem - linux printer port
> [ ]
> >> You might find  the book
> >>   Writing Linux Device Drivers
> >>   by Alessandro Rubini
> >>   Pub by O'Reilly
> >> useful.  It seems surprisingly easy to
> [ ]
> >This leads on to my problem brilliantly.  Thanks David :-)
> >First I think the original posters problem is that /dev/lp0 is
> >designed to run printers.  If you read the source (drivers/char/lp*.c)
> >then it has got things like excepting interupts on the
> >rising pulse rather than on the top.  /dev/parport* looked
> >good, except they didn't work for me, so I used the code
> >from WLDD ^^^^^.  (It is available from
> >ftp://ftp.oreilly.com/published/oreilly/linux/drivers/

> >I tried to compile it using gcc 2.7.3, which seems
> >to have tightened up its type checking, as I got lots
> >of warnings about incompatible pointer types.
> >Then the killer error,
> >cc -D__KERNEL__ -DMODULE -Wall -O2 -I/usr/include   -c short.c -o
> >short.o
> >short.c:177: warning: initialization from incompatible pointer type
> >short.c:178: warning: initialization from incompatible pointer type
> >short.c:184: warning: initialization from incompatible pointer type
> >short.c: In function `short_i_read':
> >short.c:199: wrong type argument to bit-complement
> >short.c: At top level:
> [ ]
> >        interruptible_sleep_on(&short_queue);
> >        if (current->signal & ~current->blocked) /* a signal arrived */
> >// The error is here ^^^^^^^^^^^^^^^^^^^^^^^^
> >          return -ERESTARTSYS; /* tell the fs layer to handle it */

> Your friend here is -E
> cc -E -D__KERNEL__ -DMODULE -Wall -O2 -I/usr/include   -c short.c  >junk

> In junk, you will find blocked is a sigset_t, which *used* to be
> a long according to comments,
> but is now a struct containing longs
> (~ of a struct won't work!).
> So the code must just be fixed a bit.

> The short.c:177: warning: initialization from incompatible pointer type
> worries me as the signature of the short_read function does not
> match the foperation read pointer
> (say for the read member and the short_read
> function, line 177) type. However, if the call
> used does the right things...
> but I did not follow up on that, so no guarantees from me!



Thanks David, that is _brilliant_.  Problem sorted.  If anyone wants the
modified short.c it is here.
http://www.pallen.dabsol.co.uk/short3.c
I will be loading up more modules as I port them to 2.2 (Eventually
with links from the index page so you don't have to explicitly type the
name :-))  When I have ported the lot I will try and persuade Alessandro
to put the new versions on his ftp site.

                        Peter Allen

 
 
 

Project problem - linux printer port

Post by hongjung.. » Sat, 24 Jul 1999 04:00:00


on 2.2.9-19 the current file is at

/usr/include/asm/current.h

watch out for the fact that current->signal.sig[0] and
current->signal.sig[1] BOTH have to be considered ...

The underlying type changed from an unsigned long for
signal and blocked to an array of two ...

But there are other "got cha's " since my changes still
dont work.

if you have any success, please let me know, for I am
also working on a parall (printer port) driver.

Thanks in advance.






> > >Project problem - linux printer port

> > >I am trying to wire a simple video switch to the parallel port of a
PC and
> > >have Linux
> > >it.

> > >So far I have made a connector that fools linux into beleiving that
it has a
> > >printer
> > >connected, and have sent data to it.

> > You might find  the book
> >   Writing Linux Device Drivers
> >   by Alessandro Rubini
> >   Pub by O'Reilly
> > useful.  It seems surprisingly easy to
> > work with the parallel port
> > (and to test the parallel port),  not that I've done
> > anything like it...


> This leads on to my problem brilliantly.  Thanks David :-)
> First I think the original posters problem is that /dev/lp0 is
> designed to run printers.  If you read the source (drivers/char/lp*.c)
> then it has got things like excepting interupts on the
> rising pulse rather than on the top.  /dev/parport* looked
> good, except they didn't work for me, so I used the code
> from WLDD ^^^^^.  (It is available from
> ftp://ftp.oreilly.com/published/oreilly/linux/drivers/

> I tried to compile it using gcc 2.7.3, which seems
> to have tightened up its type checking, as I got lots
> of warnings about incompatible pointer types.
> Then the killer error,
> cc -D__KERNEL__ -DMODULE -Wall -O2 -I/usr/include   -c short.c -o
> short.o
> short.c:177: warning: initialization from incompatible pointer type
> short.c:178: warning: initialization from incompatible pointer type
> short.c:184: warning: initialization from incompatible pointer type
> short.c: In function `short_i_read':
> short.c:199: wrong type argument to bit-complement
> short.c: At top level:
> short.c:231: warning: initialization from incompatible pointer type
> short.c:232: warning: initialization from incompatible pointer type
> short.c:238: warning: initialization from incompatible pointer type
> short.c: In function `short_bh_interrupt':
> short.c:345: warning: passing arg 1 of `do_gettimeofday' discards
> `volatile' from pointer target type
> make: *** [short.o] Error 1

> The errors is on line 199
> The code looks like
> read_write_t is int.

> read_write_t short_i_read (struct inode *inode, struct file *filp,
>                 char *buf, count_t count)
> {
>     int count0;

>     while (short_head == short_tail) {
>         interruptible_sleep_on(&short_queue);
>         if (current->signal & ~current->blocked) /* a signal arrived
*/
> // The error is here ^^^^^^^^^^^^^^^^^^^^^^^^
>           return -ERESTARTSYS; /* tell the fs layer to handle it */
>         /* else, loop */
>     }
>     /* count0 is the number of readable data bytes */
>     count0 = short_head - short_tail;
>     if (count0 < 0) /* wrapped */
>         count0 = short_buffer + PAGE_SIZE - short_tail;
>     if (count0 < count) count = count0;

>     copy_to_user(buf, (char *)short_tail, count);
>     short_tail += count;
>     if (short_tail == short_buffer + PAGE_SIZE)
>         short_tail = short_buffer;
>     return count;
> }

> and I cannot find where the struct 'current' is defined.
> If I could then I could work out what he is trying to do,
> but as it is I cannot.

> Thanks for any help,

>            Peter Allen

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
 
 
 

1. Project problem - linux printer portProject problem - linux printer port

Project problem - linux printer port

I am trying to wire a simple video switch to the parallel port of a PC and
have Linux
it.

So far I have made a connector that fools linux into beleiving that it has a
printer
connected, and have sent data to it.

However I dont seem to be able to get the results I expect.

Im using "echo -ne '\361' >/dev/lp0" to output the byte.

I would expect results like this :

28    64    32    16    8    4    2    1     dec        oct

1       1      1      1                         1 = 1 (241)   361
1       1      1      1                  1        = 2 (242)   362
1       1      1      1             1             = 3 (244)   346
1       1      1      1      1                    = 4 (248)   370

What i'm getting is very confusing.........

Does anyone know if    a) the LP device is trying to do CRLF expansion ?
  or b) a simple working utility to output a byte to the data latch on
      parallel port ???

I'm using RedHat 6 on a Pentium.

Any help apreciated, please email me  - thanks


2. DHCPD Refuses to Start? Help req'd

3. Printer prints from ttyS0 (modem port), but how from ttyS1 (printer port)?

4. good SCO sys admin faq, I've seen it, where?

5. About Printers and Printer Driver Projects....

6. Steve Ballmer FUD

7. Windows Printer/GDI Linux driver project.

8. Need an Ada compiler for Motorola VME 1131 (Unix System V)

9. Secure Linux Project/ Exokernel Project???

10. Project LIMP - The Linux Image Montage Project

11. Submit Your Projects Logo to LIMP - The Linux Image Montage Project

12. Project Manager for Linux: Mr Project

13. Announcing Project LIMP - The Linux Image Montage Project