Subversion Repositories HomeAutomation

Rev

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

Rev 1063 Rev 1066
Line 72... Line 72...
72
    {
72
    {
73
        print("No such service found.\n");
73
        print("No such service found.\n");
74
    }
74
    }
75
   
75
   
76
    return ServiceManager.Services[fullId];
76
    return ServiceManager.Services[fullId];
77
}
-
 
78
 
-
 
79
function testOutput()
-
 
80
{
-
 
81
_print(ClientId, "====");
-
 
82
_print(ClientId, "\r");
-
 
83
_print(ClientId, "=AR=");
-
 
84
 
-
 
85
}
77
}
86
 
78
 
87
function ethStart()
79
function ethStart()
88
{
80
{
89
    var canMessage = new CanNMTMessage("nmt", "Time");
81
    var canMessage = new CanNMTMessage("nmt", "Time");
90
    canMessage.send();
82
    canMessage.send();
91
}
83
}
92
 
84
 
93
function resetNode(hardwareId)
85
function resetNode(hardwareId)
94
{
86
{
95
    ProgrammingClientId = ClientId;
87
    ProgrammingClientId = ClientId;
96
 
88
 
97
    if (hardwareId.length > 2)
89
    if (hardwareId.length > 2)
98
    {
90
    {
99
        if (hardwareId.substr(0,2)=="0x")
91
        if (hardwareId.substr(0,2)=="0x")
100
        {
92
        {
101
            hardwareId = hex2uint(hardwareId.substring(2,hardwareId.length));
93
            hardwareId = hex2uint(hardwareId.substring(2,hardwareId.length));
102
        }
94
        }
-
 
95
    }
-
 
96
   
-
 
97
    var node = CanNodes[hardwareId];
-
 
98
 
-
 
99
    if (!node)
-
 
100
    {
-
 
101
        printTo(ProgrammingClientId, "STOP: Failed. No node is online that has that hardware id, " + hardwareId + "\n");
-
 
102
        return;
-
 
103
    }
-
 
104
   
-
 
105
    node.reset( function(status)
-
 
106
            {
-
 
107
                if (status)
-
 
108
                {
-
 
109
                    printTo(ProgrammingClientId, "STOP: Success: Node reset and bios started okay.\n");
-
 
110
                }
-
 
111
                else
-
 
112
                {
-
 
113
                    printTo(ProgrammingClientId, "STOP: Failed. Node did not respond failed.\n");
103
    }
114
                }
104
   
-
 
105
    var node = CanNodes[hardwareId];
-
 
106
 
-
 
107
    if (!node)
-
 
108
    {
-
 
109
        printTo(ProgrammingClientId, "Failed. No node is online that has that hardware id, " + hardwareId + "\n");
-
 
110
        return;
-
 
111
    }
-
 
112
   
-
 
113
    node.reset( function(status)
-
 
114
            {
-
 
115
                if (status)
-
 
116
                {
-
 
117
                    printTo(ProgrammingClientId, "Success: Node reset and bios started okay.\n");
-
 
118
                }
-
 
119
                else
-
 
120
                {
-
 
121
                    printTo(ProgrammingClientId, "Failed. Node did not respond failed.\n");
-
 
122
                }
-
 
123
            });
115
            });
124
}
116
}
125
 
117
 
126
var ProgrammingClientId = null;
118
var ProgrammingClientId = null;
127
 
119
 
128
function programNodeCallback(status, event, text, raw)
120
function programNodeCallback(status, event, text, raw)
129
{
121
{
130
    if (raw)
122
    if (raw)
131
    {
123
    {
132
        printTo(ProgrammingClientId, text);
124
        printTo(ProgrammingClientId, text);
133
    }
125
    }
134
    else
126
    else
135
    {
127
    {
136
        printTo(ProgrammingClientId, event + ": " + text + "\n");
128
        printTo(ProgrammingClientId, event + ": " + text + "\n");
137
    }
129
    }
138
}
130
}
139
 
131
 
140
function programNode(hardwareId, hexData, bios)
132
function programNode(hardwareId, hexData, bios)
141
{
133
{
142
    ProgrammingClientId = ClientId;
134
    ProgrammingClientId = ClientId;
143
 
135
 
144
    if (hardwareId.length > 2)
136
    if (hardwareId.length > 2)
145
    {
137
    {
146
        if (hardwareId.substr(0,2)=="0x")
138
        if (hardwareId.substr(0,2)=="0x")
147
        {
139
        {
148
            hardwareId = hex2uint(hardwareId.substring(2,hardwareId.length));
140
            hardwareId = hex2uint(hardwareId.substring(2,hardwareId.length));
149
        }
141
        }
150
    }
142
    }
151
   
143
   
152
    var node = CanNodes[hardwareId];
144
    var node = CanNodes[hardwareId];
153
 
145
 
154
    if (!node)
146
    if (!node)
155
    {
147
    {
156
        print("Failed. No node is online that has that hardware id, " + hardwareId + "\n");
148
        print("STOP: Failed. No node is online that has that hardware id, " + hardwareId + "\n");
157
        return;
149
        return;
158
    }
150
    }
159
 
151
 
160
    hexData = unescape(hexData);
152
    hexData = unescape(hexData);
161
 
153
 
162
    //print("helo, hexData: " + hexData);
-
 
163
 
-
 
164
    //var hexData = getFileContents(hexFilename);
-
 
165
    if (hexData)
154
    if (hexData)
166
    {
155
    {
167
        var hexLinesOrg = hexData.split('\n');
156
        var hexLinesOrg = hexData.split('\n');
168
        var hexLines = new Array();
157
        var hexLines = new Array();
169
   
158
   
Line 177... Line 166...
177
            }
166
            }
178
        }
167
        }
179
 
168
 
180
        var hexObj = new IntelHex(hexLines);
169
        var hexObj = new IntelHex(hexLines);
181
        if (hexObj.isValid()) {
170
        if (hexObj.isValid()) {
182
            //print("hexfile is valid");
-
 
183
            //for (var i = 0; i < 16; i++) { print(hexObj.getByte(i)+" "); }
-
 
184
            //print("len: "+hexObj.getLength()+" laddr: "+hexObj.getAddrLower()+" uaddr: "+hexObj.getAddrUpper()+"\n");
-
 
185
            node.startProgramming(hexObj, programNodeCallback, bios);
171
            node.startProgramming(hexObj, programNodeCallback, bios);
186
        }
172
        }
187
        else
173
        else
188
        {
174
        {
189
            print("Failed. Invalid hexfile\n");
175
            print("STOP: Failed. Invalid hexfile\n");
190
        }
176
        }
191
    }
177
    }
192
    else
178
    else
193
    {
179
    {
194
        //print("File was not found, " + hexFilename + "\n");
180
        //print("File was not found, " + hexFilename + "\n");