Subversion Repositories HomeAutomation

Rev

Rev 1667 | Rev 1885 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

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