Subversion Repositories HomeAutomation

Rev

Rev 1885 | Rev 1913 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1885 Rev 1890
Line 2... Line 2...
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
use File::Basename;
6
use File::Basename;
-
 
7
use Time::HiRes qw( usleep );
7
 
8
 
8
$| = 1;
9
$| = 1;
9
 
10
 
10
$numArgs = $#ARGV + 1;
11
$numArgs = $#ARGV + 1;
11
 
12
 
Line 65... Line 66...
65
    require $path."/setConfig/AtomLib.pl";
66
    require $path."/setConfig/AtomLib.pl";
66
} else {
67
} else {
67
    print "Error: No AtomLib.pl was found in ".$path.". \n\n";
68
    print "Error: No AtomLib.pl was found in ".$path.". \n\n";
68
    exit 1;
69
    exit 1;
69
}
70
}
70
 
-
 
71
 
71
 
72
#0x14f90d1f to 0x1f0df914
72
#0x14f90d1f to 0x1f0df914
73
@hwidChars = split(//, $hwid);
73
@hwidChars = split(//, $hwid);
74
$hwid = $hwidChars[0]. $hwidChars[1]. uc($hwidChars[8]. $hwidChars[9]. $hwidChars[6]. $hwidChars[7]. $hwidChars[4]. $hwidChars[5]. $hwidChars[2]. $hwidChars[3]);
74
$hwid = $hwidChars[0]. $hwidChars[1]. uc($hwidChars[8]. $hwidChars[9]. $hwidChars[6]. $hwidChars[7]. $hwidChars[4]. $hwidChars[5]. $hwidChars[2]. $hwidChars[3]);
75
 
75
 
76
print "atomDude settings:\n";
76
print "atomDude settings:\n";
77
print "Hardware id: " . $hwid . "\n";
77
print "Hardware id: " . $hwid . "\n";
78
print "Atom address: " . $hostname . ":" . $port . "\n";
78
print "Atom address: " . $hostname . ":" . $port . "\n";
79
print "Hexfile: " . $filename . "\n";
79
print "Hexfile: " . $filename . "\n";
80
print "Parameters: " . "\n";
80
print "Parameters: " . "\n";
81
 
81
 
82
if ($reset eq "true" && $filename eq "")
82
if ($reset eq "true" && $filename eq "")
83
{
83
{
84
    $socket = atomd_initialize($hostname, $port);
84
    $socket = atomd_initialize($hostname, $port);
85
    atomd_send_command($socket, "Node_Reset $hwid");
85
    atomd_send_command($socket, "Node_Reset $hwid");
86
    print atomd_read_command_response($socket);
86
    print atomd_read_command_response($socket);
87
    exit(1);
87
    exit(0);
88
    #my $result = system("atomic -s $hostname -p $port -c \"Node_Reset $hwid\"");
88
    #my $result = system("atomic -s $hostname -p $port -c \"Node_Reset $hwid\"");
89
    #exit($result);
89
    #exit($result);
90
}
90
}
91
else
91
else
92
{
92
{
-
 
93
    open (FP, "+<".$filename) or die "Error: Cannot open file $filename\n";
-
 
94
    @filecontents = <FP>;
-
 
95
    close FP;
-
 
96
 
93
    $socket = atomd_initialize($hostname, $port);
97
    $socket = atomd_initialize($hostname, $port);
-
 
98
   
-
 
99
    #print "Sending Node_ClearHex\n";
-
 
100
    atomd_send_command($socket, "Node_ClearHex");
-
 
101
    atomd_kill_promt($socket);
-
 
102
       
-
 
103
    foreach $filerow (@filecontents) {
-
 
104
        #print "Sending Node_AppendHex $filerow \n";
-
 
105
        atomd_send_command($socket, "Node_AppendHex $filerow");
-
 
106
        atomd_kill_promt($socket);
-
 
107
    }
-
 
108
    #print "Sending Node_ProgramHex $hwid $bios \n";
-
 
109
    atomd_send_command($socket, "Node_ProgramHex $hwid $bios");
-
 
110
    atomd_kill_promt($socket);
-
 
111
 
-
 
112
 
94
    atomd_send_command($socket, "Node_Program $hwid $bios $filename");
113
    #atomd_send_command($socket, "Node_Program $hwid $bios $filename");
95
    print atomd_read_command_response($socket);
114
    print atomd_read_command_response($socket);
96
    exit(1);
115
    exit(0);
97
    #my $result = system("atomic -s $hostname -p $port -c \"Node_Program $hwid $bios $filename\"");
116
    #my $result = system("atomic -s $hostname -p $port -c \"Node_Program $hwid $bios $filename\"");
98
    #    exit($result);
117
    #    exit($result);
99
}
118
}
100
 
119
 
101
exit(0);
120
exit(0);