Rev 2162 | Rev 2170 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 2162 | Rev 2164 | ||
|---|---|---|---|
| 1 | 1 | ||
| 2 | Node_ResetNodeId = null; |
2 | Node_ResetNodeId = null; |
| 3 | Node_ResetClientId = null; |
3 | Node_ResetClientId = null; |
| 4 | 4 | ||
| 5 | Node_ProgramNodeId = null; |
5 | Node_ProgramNodeId = null; |
| 6 | Node_ProgramClientId = null; |
6 | Node_ProgramClientId = null; |
| 7 | 7 | ||
| 8 | Node_WaitClientId = null; |
8 | Node_WaitClientId = null; |
| 9 | 9 | ||
| 10 | Node_Native_Reset = false; |
10 | Node_Native_Reset = false; |
| 11 | Node_Native_Program = false; |
11 | Node_Native_Program = false; |
| 12 | Node_Native_WaitNodeId = false; |
12 | Node_Native_WaitNodeId = false; |
| 13 | 13 | ||
| 14 | Node_HexData = ""; |
14 | Node_HexData = ""; |
| 15 | Node_HexNumLines = 0; |
15 | Node_HexNumLines = 0; |
| 16 | 16 | ||
| 17 | function Node_OnChange(node_id, available) |
17 | function Node_OnChange(node_id, available) |
| 18 | { |
18 | { |
| 19 | //Log("Node_OnChange "+Node_ResetNodeId+" "+Node_ProgramNodeId+" "+node_id+" "+available+"\n"); |
19 | //Log("Node_OnChange "+Node_ResetNodeId+" "+Node_ProgramNodeId+" "+node_id+" "+available+"\n"); |
| 20 | if (node_id == Node_ResetNodeId && available) |
20 | if (node_id == Node_ResetNodeId && available) |
| 21 | { |
21 | { |
| 22 | //Log("ResetNodeId "+Node_Native_Reset+"\n"); |
22 | //Log("ResetNodeId "+Node_Native_Reset+"\n"); |
| 23 | Console_LogToClient(Node_ResetClientId, "\033[32m" + Node_ResetNodeId + " started okay.\033[0m\n"); |
23 | Console_LogToClient(Node_ResetClientId, "\033[32m" + Node_ResetNodeId + " started okay.\033[0m\n"); |
| 24 | 24 | ||
| 25 | Console_NewConnection(Node_ResetClientId); // This is a ugly hack for a bad design for multiusers |
25 | Console_NewConnection(Node_ResetClientId); // This is a ugly hack for a bad design for multiusers |
| 26 | Node_ResetNodeId = null; |
26 | Node_ResetNodeId = null; |
| 27 | Node_ResetClientId = null; |
27 | Node_ResetClientId = null; |
| 28 | 28 | ||
| 29 | Node_Native_Reset = true; |
29 | Node_Native_Reset = true; |
| 30 | } |
30 | } |
| 31 | 31 | ||
| 32 | if (node_id == Node_ProgramNodeId && available) |
32 | if (node_id == Node_ProgramNodeId && available) |
| 33 | { |
33 | { |
| 34 | //Log("ProgramNodeId "+Node_Native_Program+"\n"); |
34 | //Log("ProgramNodeId "+Node_Native_Program+"\n"); |
| 35 | Console_LogToClient(Node_ProgramClientId, "\033[32m" + Node_ProgramNodeId + " started okay.\033[0m\n"); |
35 | Console_LogToClient(Node_ProgramClientId, "\033[32m" + Node_ProgramNodeId + " started okay.\033[0m\n"); |
| 36 | 36 | ||
| 37 | Console_NewConnection(Node_ProgramClientId); // This is a ugly hack for a bad design for multiusers |
37 | Console_NewConnection(Node_ProgramClientId); // This is a ugly hack for a bad design for multiusers |
| 38 | Node_ProgramNodeId = null; |
38 | Node_ProgramNodeId = null; |
| 39 | Node_ProgramClientId = null; |
39 | Node_ProgramClientId = null; |
| 40 | 40 | ||
| 41 | Node_Native_Program = true; |
41 | Node_Native_Program = true; |
| 42 | } |
42 | } |
| 43 | 43 | ||
| 44 | if (Node_WaitClientId != null && available) |
44 | if (Node_WaitClientId != null && available) |
| 45 | { |
45 | { |
| 46 | var result = NodeExport_GetNodeInformation(node_id); |
46 | var result = NodeExport_GetNodeInformation(node_id); |
| 47 | Node_Native_WaitNodeId = node_id; |
47 | Node_Native_WaitNodeId = node_id; |
| 48 | 48 | ||
| 49 | if (!result) |
49 | if (!result) |
| 50 | { |
50 | { |
| 51 | Console_LogToClient(Node_WaitClientId, "\033[31mNo node with id " + node_id + " found.\033[0m\n"); |
51 | Console_LogToClient(Node_WaitClientId, "\033[31mNo node with id " + node_id + " found.\033[0m\n"); |
| 52 | return false; |
52 | return false; |
| 53 | } |
53 | } |
| 54 | 54 | ||
| 55 | var date = new Date(result["LastActive"] * 1000); |
55 | var date = new Date(result["LastActive"] * 1000); |
| 56 | 56 | ||
| 57 | Console_LogToClient(Node_WaitClientId, "Id: " + result["Id"] + "\n"); |
57 | Console_LogToClient(Node_WaitClientId, "Id: " + result["Id"] + "\n"); |
| 58 | Console_LogToClient(Node_WaitClientId, "Valid: " + result["Valid"] + "\n"); |
58 | Console_LogToClient(Node_WaitClientId, "Valid: " + result["Valid"] + "\n"); |
| 59 | Console_LogToClient(Node_WaitClientId, "Bios Version: " + result["BiosVersion"] + "\n"); |
59 | Console_LogToClient(Node_WaitClientId, "Bios Version: " + result["BiosVersion"] + "\n"); |
| 60 | Console_LogToClient(Node_WaitClientId, "Device Type: " + result["DeviceType"] + "\n"); |
60 | Console_LogToClient(Node_WaitClientId, "Device Type: " + result["DeviceType"] + "\n"); |
| 61 | Console_LogToClient(Node_WaitClientId, "Has Application: " + result["HasApplication"] + "\n"); |
61 | Console_LogToClient(Node_WaitClientId, "Has Application: " + result["HasApplication"] + "\n"); |
| 62 | Console_LogToClient(Node_WaitClientId, "Last Active: " + date.toString() + "\n"); |
62 | Console_LogToClient(Node_WaitClientId, "Last Active: " + date.toString() + "\n"); |
| 63 | 63 | ||
| 64 | Console_NewConnection(Node_WaitClientId); // This is a ugly hack for a bad design for multiusers |
64 | Console_NewConnection(Node_WaitClientId); // This is a ugly hack for a bad design for multiusers |
| 65 | Node_WaitClientId = null; |
65 | Node_WaitClientId = null; |
| 66 | } |
66 | } |
| 67 | } |
67 | } |
| 68 | 68 | ||
| 69 | function Node_GetAvailableIds() |
69 | function Node_GetAvailableIds() |
| 70 | { |
70 | { |
| 71 | var result_list = []; |
71 | var result_list = []; |
| 72 | var available_nodes = NodeExport_GetAvailableNodes(); |
72 | var available_nodes = NodeExport_GetAvailableNodes(); |
| 73 | 73 | ||
| 74 | for (var n in available_nodes) |
74 | for (var n in available_nodes) |
| 75 | { |
75 | { |
| 76 | var id_parts = available_nodes[n].split(",", 2); |
76 | var id_parts = available_nodes[n].split(",", 2); |
| 77 | 77 | ||
| 78 | result_list.push(id_parts[0]); |
78 | result_list.push(id_parts[0]); |
| 79 | } |
79 | } |
| 80 | 80 | ||
| 81 | return result_list; |
81 | return result_list; |
| 82 | } |
82 | } |
| 83 | 83 | ||
| 84 | function Node_ListAvailable() |
84 | function Node_ListAvailable() |
| 85 | { |
85 | { |
| 86 | var available_nodes = NodeExport_GetAvailableNodes(); |
86 | var available_nodes = NodeExport_GetAvailableNodes(); |
| 87 | 87 | ||
| 88 | var lines = [["Id", "Modules"]]; |
88 | var lines = [["Id", "Modules"]]; |
| 89 | 89 | ||
| 90 | for (var n in available_nodes) |
90 | for (var n in available_nodes) |
| 91 | { |
91 | { |
| 92 | var parts = available_nodes[n].split(","); |
92 | var parts = available_nodes[n].split(","); |
| 93 | var id = parts.shift(); |
93 | var id = parts.shift(); |
| 94 | var modules = "<none>"; |
94 | var modules = "<none>"; |
| 95 | 95 | ||
| 96 | if (parts.length > 0) |
96 | if (parts.length > 0) |
| 97 | { |
97 | { |
| 98 | modules = parts.join(", "); |
98 | modules = parts.join(", "); |
| 99 | } |
99 | } |
| 100 | 100 | ||
| 101 | lines.push([id, modules]); |
101 | lines.push([id, modules]); |
| 102 | } |
102 | } |
| 103 | 103 | ||
| 104 | var table_lines = create_table(lines); |
104 | var table_lines = create_table(lines); |
| 105 | 105 | ||
| 106 | Log("\033[29;1m" + table_lines[0] + "\033[0m\n"); |
106 | Log("\033[29;1m" + table_lines[0] + "\033[0m\n"); |
| 107 | 107 | ||
| 108 | for (var n = 1; n < table_lines.length; n++) |
108 | for (var n = 1; n < table_lines.length; n++) |
| 109 | { |
109 | { |
| 110 | Log(table_lines[n] + "\n"); |
110 | Log(table_lines[n] + "\n"); |
| 111 | } |
111 | } |
| 112 | 112 | ||
| 113 | return true; |
113 | return true; |
| 114 | } |
114 | } |
| 115 | Console_RegisterCommand(Node_ListAvailable); |
115 | Console_RegisterCommand(Node_ListAvailable); |
| 116 | 116 | ||
| 117 | function Node_WaitNodePollNative() |
117 | function Node_WaitNodePollNative() |
| 118 | { |
118 | { |
| 119 | if (Node_Native_WaitNodeId) |
119 | if (Node_Native_WaitNodeId) |
| 120 | { |
120 | { |
| 121 | var result = NodeExport_GetNodeInformation(Node_Native_WaitNodeId); |
121 | var result = NodeExport_GetNodeInformation(Node_Native_WaitNodeId); |
| 122 | 122 | ||
| 123 | if (!result) |
123 | if (!result) |
| 124 | { |
124 | { |
| 125 | return "\033[31mError: No node with id " + Node_Native_WaitNodeId + " found.\033[0m"; |
125 | return "\033[31mError: No node with id " + Node_Native_WaitNodeId + " found.\033[0m"; |
| 126 | } |
126 | } |
| 127 | 127 | ||
| 128 | var date = new Date(result["LastActive"] * 1000); |
128 | var date = new Date(result["LastActive"] * 1000); |
| 129 | 129 | ||
| 130 | return "Id: " + result["Id"] + "\t"+ |
130 | return "Id: " + result["Id"] + "\t"+ |
| 131 | "Valid: " + result["Valid"] + "\t"+ |
131 | "Valid: " + result["Valid"] + "\t"+ |
| 132 | "Bios Version: " + result["BiosVersion"] + "\t"+ |
132 | "Bios Version: " + result["BiosVersion"] + "\t"+ |
| 133 | "Device Type: " + result["DeviceType"] + "\t"+ |
133 | "Device Type: " + result["DeviceType"] + "\t"+ |
| 134 | "Has Application: " + result["HasApplication"] + "\t"+ |
134 | "Has Application: " + result["HasApplication"] + "\t"+ |
| 135 | "Last Active: " + date.toString(); |
135 | "Last Active: " + date.toString(); |
| 136 | } |
136 | } |
| 137 | else |
137 | else |
| 138 | { |
138 | { |
| 139 | return false; |
139 | return false; |
| 140 | } |
140 | } |
| 141 | } |
141 | } |
| 142 | 142 | ||
| 143 | function Node_WaitForInformationNative() |
143 | function Node_WaitForInformationNative() |
| 144 | { |
144 | { |
| 145 | Node_WaitClientId = Console_GetClientId(); |
145 | Node_WaitClientId = Console_GetClientId(); |
| 146 | Node_Native_WaitNodeId = false; |
146 | Node_Native_WaitNodeId = false; |
| 147 | } |
147 | } |
| 148 | 148 | ||
| 149 | function Node_ResetPollNative() |
149 | function Node_ResetPollNative() |
| 150 | { |
150 | { |
| 151 | return Node_Native_Reset; |
151 | return Node_Native_Reset; |
| 152 | } |
152 | } |
| 153 | 153 | ||
| 154 | function Node_ResetNative(node_id) |
154 | function Node_ResetNative(node_id) |
| 155 | { |
155 | { |
| 156 | if (arguments.length < 1) |
156 | if (arguments.length < 1) |
| 157 | { |
157 | { |
| 158 | return "\033[31mError: Not enough parameters given.\033[0m"; |
158 | return "\033[31mError: Not enough parameters given.\033[0m"; |
| 159 | } |
159 | } |
| 160 | 160 | ||
| 161 | Node_Native_Reset = false; |
161 | Node_Native_Reset = false; |
| 162 | if (!NodeExport_ResetNode(node_id)) |
162 | if (!NodeExport_ResetNode(node_id)) |
| 163 | { |
163 | { |
| 164 | return "\033[31mError: Failed to send reset, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m"; |
164 | return "\033[31mError: Failed to send reset, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m"; |
| 165 | } |
165 | } |
| 166 | 166 | ||
| 167 | Node_ResetClientId = Console_GetClientId(); |
167 | Node_ResetClientId = Console_GetClientId(); |
| 168 | Node_ResetNodeId = node_id; |
168 | Node_ResetNodeId = node_id; |
| 169 | 169 | ||
| 170 | return "Reset command sent successfully"; |
170 | return "Reset command sent successfully"; |
| 171 | } |
171 | } |
| 172 | 172 | ||
| 173 | function Node_Reset(node_id) |
173 | function Node_Reset(node_id) |
| 174 | { |
174 | { |
| 175 | if (arguments.length < 1) |
175 | if (arguments.length < 1) |
| 176 | { |
176 | { |
| 177 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
177 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 178 | return false; |
178 | return false; |
| 179 | } |
179 | } |
| 180 | 180 | ||
| 181 | Log("Sending reset to " + node_id + "...\n"); |
181 | Log("Sending reset to " + node_id + "...\n"); |
| 182 | 182 | ||
| 183 | if (!NodeExport_ResetNode(node_id)) |
183 | if (!NodeExport_ResetNode(node_id)) |
| 184 | { |
184 | { |
| 185 | Log("\033[31mFailed to send reset, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m\n"); |
185 | Log("\033[31mFailed to send reset, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m\n"); |
| 186 | return false; |
186 | return false; |
| 187 | } |
187 | } |
| 188 | 188 | ||
| 189 | Node_ResetClientId = Console_GetClientId(); |
189 | Node_ResetClientId = Console_GetClientId(); |
| 190 | Node_ResetNodeId = node_id; |
190 | Node_ResetNodeId = node_id; |
| 191 | Console_PreventDefaultPrompt(); |
191 | Console_PreventDefaultPrompt(); |
| 192 | 192 | ||
| 193 | return true; |
193 | return true; |
| 194 | } |
194 | } |
| 195 | Console_RegisterCommand(Node_Reset, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds()); }); |
195 | Console_RegisterCommand(Node_Reset, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds()); }); |
| 196 | 196 | ||
| 197 | function Node_ProgramPollNative() |
197 | function Node_ProgramPollNative() |
| 198 | { |
198 | { |
| 199 | return Node_Native_Program; |
199 | return Node_Native_Program; |
| 200 | } |
200 | } |
| 201 | 201 | ||
| 202 | function Node_AppendHexNative(hexrow) |
202 | function Node_AppendHexNative(hexrow) |
| 203 | { |
203 | { |
| 204 | if (arguments.length < 1) |
204 | if (arguments.length < 1) |
| 205 | { |
205 | { |
| 206 | return "\033[31mError: Not enough parameters given.\033[0m"; |
206 | return "\033[31mError: Not enough parameters given.\033[0m"; |
| 207 | } |
207 | } |
| 208 | 208 | ||
| 209 | Node_HexData = Node_HexData + hexrow + "\n"; |
209 | Node_HexData = Node_HexData + hexrow + "\n"; |
| 210 | Node_HexNumLines += 1; |
210 | Node_HexNumLines += 1; |
| 211 | 211 | ||
| 212 | return true; |
212 | return true; |
| - | 213 | } |
|
| - | 214 | ||
| - | 215 | function Node_GetProgramProgress(node_id) |
|
| - | 216 | { |
|
| - | 217 | if (arguments.length < 1) |
|
| - | 218 | { |
|
| - | 219 | return "\033[31mError: Not enough parameters given.\033[0m"; |
|
| - | 220 | } |
|
| - | 221 | ||
| - | 222 | //if (!NodeExport_ProgramNodeHex(node_id, bios > 0, Node_HexData)) |
|
| - | 223 | //{ |
|
| - | 224 | // return "\033[31mError: Failed to start programming, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m"; |
|
| - | 225 | //} |
|
| - | 226 | ||
| - | 227 | return NodeExport_GetProgramProgress(node_id); |
|
| 213 | } |
228 | } |
| 214 | 229 | ||
| 215 | function Node_ProgramNative(node_id, bios, hexnumlines) |
230 | function Node_ProgramNative(node_id, bios, hexnumlines) |
| 216 | { |
231 | { |
| 217 | if (arguments.length < 3) |
232 | if (arguments.length < 3) |
| 218 | { |
233 | { |
| 219 | return "\033[31mError: Not enough parameters given.\033[0m"; |
234 | return "\033[31mError: Not enough parameters given.\033[0m"; |
| 220 | } |
235 | } |
| 221 | if (Node_HexNumLines != hexnumlines) |
236 | if (Node_HexNumLines != hexnumlines) |
| 222 | { |
237 | { |
| 223 | return "\033[31mError: Number of hex lines does not match received (" + Node_HexNumLines + " received, should be " + hexnumlines + ").\033[0m"; |
238 | return "\033[31mError: Number of hex lines does not match received (" + Node_HexNumLines + " received, should be " + hexnumlines + ").\033[0m"; |
| 224 | } |
239 | } |
| 225 | 240 | ||
| 226 | Node_Native_Program = false; |
241 | Node_Native_Program = false; |
| 227 | if (!NodeExport_ProgramNodeHex(node_id, bios > 0, Node_HexData)) |
242 | if (!NodeExport_ProgramNodeHex(node_id, bios > 0, Node_HexData)) |
| 228 | { |
243 | { |
| 229 | return "\033[31mError: Failed to start programming, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m"; |
244 | return "\033[31mError: Failed to start programming, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m"; |
| 230 | } |
245 | } |
| 231 | 246 | ||
| 232 | Node_ProgramClientId = Console_GetClientId(); |
247 | Node_ProgramClientId = Console_GetClientId(); |
| 233 | Node_ProgramNodeId = node_id; |
248 | Node_ProgramNodeId = node_id; |
| 234 | Node_HexData = ""; |
249 | Node_HexData = ""; |
| 235 | Node_HexNumLines = 0; |
250 | Node_HexNumLines = 0; |
| 236 | 251 | ||
| 237 | return "Program command sent successfully"; |
252 | return "Program command sent successfully"; |
| 238 | } |
253 | } |
| 239 | 254 | ||
| 240 | function Node_Program(node_id, bios, filename) |
255 | function Node_Program(node_id, bios, filename) |
| 241 | { |
256 | { |
| 242 | if (arguments.length < 3) |
257 | if (arguments.length < 3) |
| 243 | { |
258 | { |
| 244 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
259 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 245 | return false; |
260 | return false; |
| 246 | } |
261 | } |
| 247 | 262 | ||
| 248 | Log("Initiating programming of " + node_id + "...\n"); |
263 | Log("Initiating programming of " + node_id + "...\n"); |
| 249 | 264 | ||
| 250 | if (!NodeExport_ProgramNode(node_id, bios > 0, filename)) |
265 | if (!NodeExport_ProgramNode(node_id, bios > 0, filename)) |
| 251 | { |
266 | { |
| 252 | Log("\033[31mFailed to start programming, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m\n"); |
267 | Log("\033[31mFailed to start programming, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m\n"); |
| 253 | return false; |
268 | return false; |
| 254 | } |
269 | } |
| 255 | 270 | ||
| 256 | Node_ProgramClientId = Console_GetClientId(); |
271 | Node_ProgramClientId = Console_GetClientId(); |
| 257 | Node_ProgramNodeId = node_id; |
272 | Node_ProgramNodeId = node_id; |
| 258 | Console_PreventDefaultPrompt(); |
273 | Console_PreventDefaultPrompt(); |
| 259 | 274 | ||
| 260 | return true; |
275 | return true; |
| 261 | } |
276 | } |
| 262 | Console_RegisterCommand(Node_Program, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds(), [0, 1]); }); |
277 | Console_RegisterCommand(Node_Program, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds(), [0, 1]); }); |
| 263 | 278 | ||
| 264 | function Node_ProgramHex(node_id, bios, hexnumlines) |
279 | function Node_ProgramHex(node_id, bios, hexnumlines) |
| 265 | { |
280 | { |
| 266 | if (arguments.length < 2) |
281 | if (arguments.length < 2) |
| 267 | { |
282 | { |
| 268 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
283 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 269 | return false; |
284 | return false; |
| 270 | } |
285 | } |
| 271 | if (Node_HexNumLines != hexnumlines) |
286 | if (Node_HexNumLines != hexnumlines) |
| 272 | { |
287 | { |
| 273 | Log("\033[31mNumber of hex lines does not match received (" + Node_HexNumLines + " received, should be " + hexnumlines + ").\033[0m\n"); |
288 | Log("\033[31mNumber of hex lines does not match received (" + Node_HexNumLines + " received, should be " + hexnumlines + ").\033[0m\n"); |
| 274 | return false; |
289 | return false; |
| 275 | } |
290 | } |
| 276 | 291 | ||
| 277 | Log("Initiating programming of " + node_id + "...\n"); |
292 | Log("Initiating programming of " + node_id + "...\n"); |
| 278 | 293 | ||
| 279 | if (!NodeExport_ProgramNodeHex(node_id, bios > 0, Node_HexData)) |
294 | if (!NodeExport_ProgramNodeHex(node_id, bios > 0, Node_HexData)) |
| 280 | { |
295 | { |
| 281 | Log("\033[31mFailed to start programming, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m\n"); |
296 | Log("\033[31mFailed to start programming, this can happen if node only contains bios and it was connected before atom was started/restarted.\033[0m\n"); |
| 282 | return false; |
297 | return false; |
| 283 | } |
298 | } |
| 284 | 299 | ||
| 285 | Node_ProgramClientId = Console_GetClientId(); |
300 | Node_ProgramClientId = Console_GetClientId(); |
| 286 | Node_ProgramNodeId = node_id; |
301 | Node_ProgramNodeId = node_id; |
| 287 | Console_PreventDefaultPrompt(); |
302 | Console_PreventDefaultPrompt(); |
| 288 | 303 | ||
| 289 | Node_HexData = ""; |
304 | Node_HexData = ""; |
| 290 | Node_HexNumLines = 0; |
305 | Node_HexNumLines = 0; |
| 291 | 306 | ||
| 292 | 307 | ||
| 293 | return true; |
308 | return true; |
| 294 | } |
309 | } |
| 295 | Console_RegisterCommand(Node_ProgramHex, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds(), [0, 1]); }); |
310 | Console_RegisterCommand(Node_ProgramHex, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds(), [0, 1]); }); |
| 296 | 311 | ||
| 297 | function Node_ClearHex() |
312 | function Node_ClearHex() |
| 298 | { |
313 | { |
| 299 | // Log("Clearing hexdata...\n"); |
314 | // Log("Clearing hexdata...\n"); |
| 300 | 315 | ||
| 301 | Node_HexData = ""; |
316 | Node_HexData = ""; |
| 302 | Node_HexNumLines = 0; |
317 | Node_HexNumLines = 0; |
| 303 | 318 | ||
| 304 | return true; |
319 | return true; |
| 305 | } |
320 | } |
| 306 | Console_RegisterCommand(Node_ClearHex); |
321 | Console_RegisterCommand(Node_ClearHex); |
| 307 | 322 | ||
| 308 | function Node_AppendHex(hexrow) |
323 | function Node_AppendHex(hexrow) |
| 309 | { |
324 | { |
| 310 | if (arguments.length < 1) |
325 | if (arguments.length < 1) |
| 311 | { |
326 | { |
| 312 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
327 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 313 | return false; |
328 | return false; |
| 314 | } |
329 | } |
| 315 | 330 | ||
| 316 | // Log("Appending hexrow...\n"); |
331 | // Log("Appending hexrow...\n"); |
| 317 | 332 | ||
| 318 | Node_HexData = Node_HexData + hexrow + "\n"; |
333 | Node_HexData = Node_HexData + hexrow + "\n"; |
| 319 | Node_HexNumLines += 1; |
334 | Node_HexNumLines += 1; |
| 320 | 335 | ||
| 321 | return true; |
336 | return true; |
| 322 | } |
337 | } |
| 323 | Console_RegisterCommand(Node_AppendHex); |
338 | Console_RegisterCommand(Node_AppendHex); |
| 324 | 339 | ||
| 325 | function Node_GetInformation(node_id) |
340 | function Node_GetInformation(node_id) |
| 326 | { |
341 | { |
| 327 | if (arguments.length < 1) |
342 | if (arguments.length < 1) |
| 328 | { |
343 | { |
| 329 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
344 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 330 | return false; |
345 | return false; |
| 331 | } |
346 | } |
| 332 | 347 | ||
| 333 | var result = NodeExport_GetNodeInformation(node_id); |
348 | var result = NodeExport_GetNodeInformation(node_id); |
| 334 | 349 | ||
| 335 | if (!result) |
350 | if (!result) |
| 336 | { |
351 | { |
| 337 | Log("\033[31mNo node with id " + node_id + " found.\033[0m\n"); |
352 | Log("\033[31mNo node with id " + node_id + " found.\033[0m\n"); |
| 338 | return false; |
353 | return false; |
| 339 | } |
354 | } |
| 340 | 355 | ||
| 341 | var date = new Date(result["LastActive"] * 1000); |
356 | var date = new Date(result["LastActive"] * 1000); |
| 342 | 357 | ||
| 343 | Log("\033[96mId: \033[0;1m" + result["Id"] + "\033[0m\n"); |
358 | Log("\033[96mId: \033[0;1m" + result["Id"] + "\033[0m\n"); |
| 344 | Log("\033[96mValid: \033[0;1m" + result["Valid"] + "\033[0m\n"); |
359 | Log("\033[96mValid: \033[0;1m" + result["Valid"] + "\033[0m\n"); |
| 345 | Log("\033[96mBios Version: \033[0;1m" + result["BiosVersion"] + "\033[0m\n"); |
360 | Log("\033[96mBios Version: \033[0;1m" + result["BiosVersion"] + "\033[0m\n"); |
| 346 | Log("\033[96mDevice Type: \033[0;1m" + result["DeviceType"] + "\033[0m\n"); |
361 | Log("\033[96mDevice Type: \033[0;1m" + result["DeviceType"] + "\033[0m\n"); |
| 347 | Log("\033[96mHas Application: \033[0;1m" + result["HasApplication"] + "\033[0m\n"); |
362 | Log("\033[96mHas Application: \033[0;1m" + result["HasApplication"] + "\033[0m\n"); |
| 348 | Log("\033[96mLast Active: \033[0;1m" + date.toString() + "\033[0m\n"); |
363 | Log("\033[96mLast Active: \033[0;1m" + date.toString() + "\033[0m\n"); |
| 349 | 364 | ||
| 350 | return true; |
365 | return true; |
| 351 | } |
366 | } |
| 352 | Console_RegisterCommand(Node_GetInformation, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds()); }); |
367 | Console_RegisterCommand(Node_GetInformation, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Node_GetAvailableIds()); }); |
| 353 | 368 | ||
| 354 | function Node_WaitForInformation() |
369 | function Node_WaitForInformation() |
| 355 | { |
370 | { |
| 356 | Node_WaitClientId = Console_GetClientId(); |
371 | Node_WaitClientId = Console_GetClientId(); |
| 357 | Console_PreventDefaultPrompt(); |
372 | Console_PreventDefaultPrompt(); |
| 358 | 373 | ||
| 359 | return true; |
374 | return true; |
| 360 | } |
375 | } |
| 361 | Console_RegisterCommand(Node_WaitForInformation); |
376 | Console_RegisterCommand(Node_WaitForInformation); |
| 362 | 377 | ||