PilotinControl has asked for the wisdom of the Perl Monks concerning the following question:
Good Afternoon Monks,
I have a program that uses Win32-Serial and I am sending commands to a receiving decoder which is installed into a model railroad locomotive. Individually the commands work: Ring the bell, blow the horn etc. However, when each command is sent it shuts off the previous command. Below is my code and what I need to be able to do is for example: Lights On stays on even if Bell On is selected. The receiver/decoder does not store commands...it just executes what is sent.
### LIGHTS ON/OFF CODE### sub leftefzeroone { $button53->configure(-text => 'F0 - Left Lights On'); $button53->bind('<ButtonPress>', \&leftefzerotwo); my $tlightson = "<f 1108 144>"; $port->write($tlightson); $port->lookclear(); } sub leftefzerotwo { $button53->configure(-text => 'F0 - Left Lights Off'); $button53->bind('<ButtonPress>', \&leftefzeroone); my $tlightsoff = "<f 1108 128>"; $port->write($tlightsoff); $port->lookclear(); } ### BELL ON/OFF CODE### sub leftefoneone { $button54->configure(-text => 'F1 - Left Bell On'); $button54->bind('<ButtonPress>', \&leftefonetwo); my $tbellon = "<f 1108 136>"; $port->write($tbellon); $port->lookclear(); } sub leftefonetwo { $button54->configure(-text => 'F0 - Left Bell Off'); $button54->bind('<ButtonPress>', \&leftefoneone); my $tbelloff = "<f 1108 128>"; $port->write($tbelloff); $port->lookclear(); }
As you can see from the code the number 128 is the byte number in the receiver/decoder that shuts any function ON to OFF. What I need to implement is a type of IF EXISTS statement. I'm lost as to where to begin on that. I can do simple IF FILE EXISTS type of routines. Thanks in advance!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Saving Options
by cragapito (Scribe) on Dec 20, 2015 at 21:01 UTC | |
by PilotinControl (Pilgrim) on Dec 20, 2015 at 22:15 UTC | |
by cragapito (Scribe) on Dec 20, 2015 at 23:05 UTC | |
|
Re: Saving Options
by FreeBeerReekingMonk (Deacon) on Dec 20, 2015 at 21:28 UTC | |
by PilotinControl (Pilgrim) on Dec 20, 2015 at 22:08 UTC | |
|
Re: Saving Options
by poj (Abbot) on Dec 20, 2015 at 21:50 UTC | |
by FreeBeerReekingMonk (Deacon) on Dec 21, 2015 at 18:16 UTC | |
|
Re: Saving Options
by Mr. Muskrat (Canon) on Dec 21, 2015 at 20:09 UTC | |
by PilotinControl (Pilgrim) on Dec 22, 2015 at 12:14 UTC |