#!/usr/bin/perl # This code is Copyright (C) 2002 Christopher M. Bergeron. All rights # reserved. This code is being made available for private use by the # owners, users, and potential buyers of the Dashwerks DSSC circuit. # Any other use or publication (without permission) is strictly prohibited. # For permission to use this code in a commercial application or # publication, please contact Christopher M. Bergeron # (christopher@bergeron.com) for express permission. # If you get an error about perl not being found, try searching for perl # on your computer. This command works on most systems: # locate perl | grep bin # It will likely be in /usr/bin/perl or /bin/perl or /usr/local/bin/perl # if so, just change the top line of this file to #!/usr/local/bin/perl # or whatever your perl location is. If "locate" doesn't find it, try using: # find / -name "perl" | grep bin # if you still don't get a result, you will probably have to # download and install perl. You [probably] can find # it at: http://www.perl.com/CPAN/src/stable.tar.gz # Become a daemon fork and exit; # Set this to the serial port that your DSSC is connected to. my $device="/dev/ttyS0"; # set the serial port for 9600,N,8,1 my $str="/bin/stty -F $device ospeed 9600 ispeed 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke"; system("$str"); # Uncomment the line below for debugging... # print "Watching $device for [SHUTDOWN]...\n"; open(FILE,"<$device"); while () { # to debug - uncomment the line below... # print "$_\n"; # watch for "[SHUTDOWN]" from serial port (DSSC) and when received, when received, # tell the PC to shutdown properly if ($_ eq "[SHUTDOWN]\r\n") { exec("/sbin/shutdown -h now"); } }