"Fossies" - the Fresh Open Source Software Archive

Member "astrocam-2.7.6/acam_console.pl" (26 May 2009, 2470 Bytes) of package /linux/www/old/astrocam-2.7.6.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "acam_console.pl" see the Fossies "Dox" file reference documentation.

    1 #!/usr/bin/perl -w
    2 
    3 # acam_console.pl is distributed under the following license:
    4 #
    5 # Copyright (C) 2007-2008 Steffen Wendzel <steffen (at) ploetner-it (dot) de>
    6 #
    7 # Redistribution and use in source and binary forms, with or without
    8 # modification, are permitted provided that the following conditions
    9 # are met:
   10 # 1. Redistributions of source code must retain the above copyright
   11 #    notice, this list of conditions and the following disclaimer.
   12 # 2. Redistributions in binary form must reproduce the above copyright
   13 #    notice, this list of conditions and the following disclaimer in the
   14 #    documentation and/or other materials provided with the distribution.
   15 #
   16 # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   19 # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   26 # SUCH DAMAGE.
   27 
   28 use strict;
   29 use IPC::Msg;
   30 use IPC::SysV; # qw/IPC_PRIVATE S_IRWXU/;
   31 
   32 sub ReadConfig {
   33     my %CONFIG;
   34     open(FP, "</etc/astrocam.conf") || die "Cannot open /etc/astrocam.conf!";
   35     while (my $zeile = <FP>) {
   36         (my $name, my $value) = split(/[\ \t]/, $zeile);
   37         $value =~ s/[\r\n]//g;
   38         $CONFIG{$name} = $value;
   39     }
   40     close(FP);
   41     return %CONFIG;
   42 }
   43 
   44 ######################################################################################
   45 # handle form data
   46 ######################################################################################
   47 
   48 my %CONFIG = ReadConfig();
   49 
   50 sub move
   51 {
   52     my $action = $_[0];
   53     if (not ($action =~ m/^[lLrRud]$/)) {
   54         die "action value not allowed!";
   55     }
   56     # now send the $action value via IPC to astrocam daemon
   57     msgsnd(msgget($CONFIG{"ipckey"}, 0),
   58         pack("l! a*", 1, $action), 0);
   59 }
   60 
   61 print "This test programm moves the stepengine to left and right.\n";
   62 print "Moving left ...\n";
   63 move("L");
   64 move("L");
   65 move("L");
   66 move("L");
   67 move("L");
   68 print "Moving right ...\n";
   69 move("R");
   70 move("R");
   71 move("R");
   72 move("R");
   73 move("R");
   74 
   75