+ Responder ao Tópico



  1. #1

    Padrão script para enviar 1 bit para porta paralela.

    estou pensando em fazer um projeto para um monitoramento de "hosts" com LEDs.

    segue links de exemplo; Curso On-line C/C++/Porta Paralela.

    usando os seguintes: ""

    1. LEDs
    2. Linux
    3. liguagens ( )

    o ping está sendo execultado da seguinte forma

    #################

    $1BIT = "00000010"

    ping -c 2 10.100.108.2
    if [ $? = 0 ];
    then

    ##se o ip responder o ping mostra online
    echo $1BIT > /home/online // aqui eu envio para um arquivo ou execulto um codigo para a porta paralela.
    else
    #se o ip não responder mostra offline!
    echo "" > /home/hoste // aqui eu envio para um arquivo ou execulto um codigo para a porta paralela para um LED (verde)

    fi

    ########################
    segue link do modelo http://zz2kzq.site90.com/CursoHtml/Modulo01/LigaLed.gif

  2. #2

    Padrão

    esquici.....

    vai ser rodado no linux.

    encotrei isso em perl, alguem pode me dar um "luz"

    #!/usr/bin/perl -w

    # Not necessary, this just makes you write cleaner
    # code than you probably normally would.
    use strict;

    # Load the Parallel Port Module.
    use Device::ParallelPort;

    # Set up your parallel port object and tell it what
    # driver to use. Note, I used 'linux' as the driver.
    # the documentation will explain how to use the
    # other drivers.
    my $parport = Device::ParallelPort->new('linux');

    # Now that you have $parport, you can turn your # data bits on and off which will send +5VDC down # each wires.

    # This line tells it to set data bit 0 on.
    $parport->set_bit(0, 1);
    # Now there is +5VDC going down the wire.

    # This line tells it to set data bit 0 off.
    $parport->set_bit(0, 0);
    # Now there is 0VDC going down the wire.

    # Note that the first argument is the data bit, and
    # the second number is either 1 for on, or 0 for
    # off. the data bits range from 0 to 7 (8 total).
    # With that in mind, the following eight lines will
    # turn on all 8 data bits.
    $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);

    # One more important line of code that isn't
    # directly related to the parallel port, but can be
    # very handy none the less, is how to make a
    # pause for less than a second. Traditionally, you
    # would use the 'sleep(1)' function to sleep for any
    # amount of seconds. However, in controlling
    # devices or whatnot you may only want to pause
    # for a split second. That's where the select
    # statement comes in.
    select(undef,undef,undef, .25);

    # That line would pause for .25 seconds. So, for
    # example, if you want to pause for three and a
    # half seconds (3.5) you would type.
    select(undef,undef,undef, 3.5);
    Última edição por fsoaress76; 25-05-2009 às 13:32.