Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: Serial Port

by RichardK (Parson)
on Aug 13, 2015 at 16:23 UTC ( [id://1138446]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Serial Port
in thread Serial Port

That repeat callback is not tied to anything. The Tk event loop will call the handler every 100 ms. You will need to write code in the handler to deal with every message the arduino will send.

Replies are listed 'Best First'.
Re^4: Serial Port
by PilotinControl (Pilgrim) on Aug 13, 2015 at 18:35 UTC

    RichardK a big thank you! It works! and the code is below:

    sub handler { my $timer = $mw->repeat(100,\&sighandler ); sub sighandler { my $data = $port->lookfor; return unless $data; # do stuff print STDOUT "$time Message Received: (" . $data . ")\n"; if ($data =~ /OF/) { $signalblock100->configure(-image => $mw->Photo(-file => 'picture.jpg' +)); } $port->lookclear; } }
    Had to use a sub with in a sub...unless there is a different way to do it..the code works as follow:
    1.) Button is Pushed = LEDs turn on for 8 seconds
    2.) LEDs go out and the word OF is sent from the Arduino and is Polled by the Perl Script and the button that is shaded is now unshaded and the RX/TX buffers have been purged. Thanks again!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1138446]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-24 17:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found