in reply to Accessing parallel ports

Device::ParallelPort::drv::linux is broken and won't make. I slimmed it down a little and tried this:
#!/usr/bin/perl use strict; use warnings; use Device::ParallelPort; use Device::ParallelPort::drv::parport; my $parport = Device::ParallelPort->new; $parport->set_bit(3, 1); print $parport->get_bit(3), "\n", ord($parport->get_byte(0)), "\n", ord($parport->get_byte(1)), "\n", ord($parport->get_byte(2)), "\n";

Replies are listed 'Best First'.
Re^2: Accessing parallel ports
by tumoheat (Initiate) on Jan 07, 2011 at 06:02 UTC
    Thanks Khen1950fx,

    I actually got it to work using the code below. I changed auto:0 to auto:1 and that did it.

    require "subparseform.lib"; &Parse_Form; print "Set-cookie: cart_id=1234; user_id=123;\n"; print "Content-type: text/html\n\n"; use strict; use CGI; use Device::ParallelPort; # use Device::ParallelPort::drv::linux # Set up your parallel port object and tell it what driver to use. my $parport = Device::ParallelPort->new('auto:1'); # $parport->set_bit(0,1); # $parport->set_bit(1, 1); $parport->set_bit(2, 1); $parport->set_bit(3, 1); $parport->set_bit(4, 1); $parport->set_bit(5, 1); $parport->set_bit(6, 1); $parport->set_bit(7, 1);

    If I don't comment out the CGI lines I get an Internal Server Error, that's why I have them. Is there a serious problem with doing it this way?

      tumoheat:

      If you check your server logs, I bet it's complaining about permissions. If so, talk to your system administrator about getting permission to access the parallel port for your web server account.

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

        Roboticus,

        Thanks for your assistance. I commented out the CGI lines and it works fine. Maybe it's the way I learned to write dynamic web pages, but I always put all of my Perl files (with .cgi extensions) in a cgi-bin directory and execute them from there. And I've been putting in the 'use CGI' line from the beginning. I've never had a problem with it, and it works real well when passing data between forms. BTW, the whole point of my program was to control a green house in my garage - remotely via a web page - from my desk at work. It worked, so I am attempting to build on from there. FYI. Thanks again.

Re^2: Accessing parallel ports
by tumoheat (Initiate) on Jan 07, 2011 at 05:36 UTC
    Thanks Khen1950fx, I actually got it to work using the code below. I changed auto:0 to auto:1 and that did it. require "subparseform.lib"; &Parse_Form; print "Set-cookie: cart_id=1234; user_id=123;\n"; print "Content-type: text/html\n\n"; use strict; use CGI; use Device::ParallelPort; # use Device::ParallelPort::drv::linux # Set up your parallel port object and tell it what driver to use. my $parport = Device::ParallelPort->new('auto:1'); # $parport->set_bit(0,1); # $parport->set_bit(1, 1); $parport->set_bit(2, 1); $parport->set_bit(3, 1); $parport->set_bit(4, 1); $parport->set_bit(5, 1); $parport->set_bit(6, 1); $parport->set_bit(7, 1); If I comment out the CGI lines I get an Internal Server Error, that's why I have them. Is there a serious problem with doing it this way?