Subversion Repositories HomeAutomation

Rev

Rev 1667 | Rev 1890 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. #!/usr/bin/perl
  2.  
  3. # Written by Mattias Runge 2008-2010
  4.  
  5. use Cwd 'abs_path';
  6.  
  7. $| = 1;
  8.  
  9. $numArgs = $#ARGV + 1;
  10.  
  11. my $hostname = "localhost";
  12. my $port = 1201;
  13. my $filename = "";
  14. my $hwid = "";
  15. my $bios = 0;
  16. my $reset = "false";
  17.  
  18. foreach $argnum (0 .. $#ARGV)
  19. {
  20.     if ($ARGV[$argnum] eq "-h")
  21.     {
  22.         $hostname = $ARGV[$argnum+1];
  23.         next;
  24.  
  25.     }
  26.     elsif ($ARGV[$argnum] eq "-p")
  27.     {
  28.         $port = $ARGV[$argnum+1];
  29.         next;
  30.  
  31.     }
  32.     elsif ($ARGV[$argnum] eq "-i")
  33.     {
  34.         $hwid = $ARGV[$argnum+1];
  35.         next;
  36.  
  37.     }
  38.     elsif ($ARGV[$argnum] eq "-f")
  39.     {
  40.         $filename = abs_path($ARGV[$argnum+1]);
  41.         next;
  42.  
  43.     }
  44.     elsif ($ARGV[$argnum] eq "-b")
  45.     {
  46.         $bios = 1;
  47.     }
  48.     elsif ($ARGV[$argnum] eq "-r")
  49.     {
  50.         $reset = "true";
  51.     }
  52. }
  53.  
  54. if ($hwid eq "")
  55. {
  56.     die "You must specify a hardware id!\n";
  57.     exit 1;
  58. }
  59.  
  60. #0x14f90d1f to 0x1f0df914
  61. @hwidChars = split(//, $hwid);
  62. $hwid = $hwidChars[0]. $hwidChars[1]. uc($hwidChars[8]. $hwidChars[9]. $hwidChars[6]. $hwidChars[7]. $hwidChars[4]. $hwidChars[5]. $hwidChars[2]. $hwidChars[3]);
  63.  
  64. print "atomDude settings:\n";
  65. print "Hardware id: " . $hwid . "\n";
  66. print "Atom address: " . $hostname . ":" . $port . "\n";
  67. print "Hexfile: " . $filename . "\n";
  68. print "Parameters: " . "\n";
  69.  
  70. if ($reset eq "true" && $filename eq "")
  71. {
  72.     my $result = system("atomic -s $hostname -p $port -c \"Node_Reset $hwid\"");
  73.     exit($result);
  74. }
  75. else
  76. {
  77.     my $result = system("atomic -s $hostname -p $port -c \"Node_Program $hwid $bios $filename\"");
  78.         exit($result);
  79. }
  80.  
  81. exit(0);
  82.