iCub-main
Loading...
Searching...
No Matches
diagnosticInfoParsers.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) Istituto Italiano di Tecnologia (IIT)
3 * All rights reserved.
4 *
5 * This software may be modified and distributed under the terms of the
6 * BSD-3-Clause license. See the accompanying LICENSE file for details.
7 */
8
11#include "EoBoards.h"
12#include "embot_core_binary.h"
13
14#include <yarp/os/Time.h>
15#include <algorithm>
16
17
18using namespace Diagnostic::LowLevel;
19
20
21
22
23/**************************************************************************************************************************/
24/****************************************** DefaultParser ***************************************************/
25/**************************************************************************************************************************/
26DefaultParser::DefaultParser(AuxEmbeddedInfo &dnginfo, EntityNameProvider &entityNameProvider):m_dnginfo(dnginfo), m_entityNameProvider(entityNameProvider){;}
27
29{
30 char str[512] = {0};
31 uint8_t *p64 = (uint8_t*)&(m_dnginfo.param64);
32 snprintf(str, sizeof(str), " src %s, adr %d,(code 0x%.8x, par16 0x%.4x par64 0x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x) -> %s %s %s",
37 p64[7], p64[6], p64[5], p64[4], p64[3], p64[2], p64[1], p64[0],
38 eoerror_code2string(m_dnginfo.errorCode),
39 eoerror_code2rulesstring(m_dnginfo.errorCode),
41 );
44
45}
46
48{
49 char str[512] = {0};
50 snprintf(str, sizeof(str), "%s", m_dnginfo.baseMessage.c_str());
52}
53
54/**************************************************************************************************************************/
55/****************************************** ConfigParser ***************************************************/
56/**************************************************************************************************************************/
57
58ConfigParser::ConfigParser(AuxEmbeddedInfo &dnginfo, EntityNameProvider &entityNameProvider):DefaultParser(dnginfo, entityNameProvider){;}
59
61{
62 char str[512] = {0};
63 eOerror_value_t value = eoerror_code2value(m_dnginfo.errorCode);
64
66
67 switch(value)
68 {
69
70 case eoerror_value_CFG_candiscovery_started:
71 {
72 uint16_t maskcan2 = m_dnginfo.param16;
73 eObrd_type_t brdnum = static_cast<eObrd_type_t>((m_dnginfo.param64 & 0x0000ff0000000000) >> 40);
74 const char *canboardname = eoboards_type2string(brdnum);
75 uint16_t maskcan1 = (m_dnginfo.param64 & 0xffff000000000000) >> 48;
76 eObrd_protocolversion_t prot = {0};
77 eObrd_firmwareversion_t appl = {0};
78 uint64_t reqpr = (m_dnginfo.param64 & 0x000000ffff000000) >> 24;
79 uint64_t reqfw = (m_dnginfo.param64 & 0x0000000000ffffff);
80 uint8_t num =0;
81 prot.major = reqpr >> 8;
82 prot.minor = reqpr & 0xff;
83 appl.major = (reqfw >> 16) & 0xff;
84 appl.minor = (reqfw >> 8) & 0xff;
85 appl.build = reqfw & 0xff;
86 num = eo_common_hlfword_bitsetcount(maskcan1)+eo_common_hlfword_bitsetcount(maskcan2);
87
88 snprintf(str, sizeof(str), " %s %d %s boards on (can1map, can2map) = (0x%.4x, 0x%.4x) with target can protocol ver %d.%d and application ver %d.%d.%d.",
89 m_dnginfo.baseMessage.c_str(),
90 num, canboardname,
91 maskcan1, maskcan2,
92 prot.major, prot.minor,
93 appl.major, appl.minor, appl.build
94 );
96 } break;
97
98 case eoerror_value_CFG_candiscovery_ok:
99 {
100 uint8_t num = m_dnginfo.param16 & 0x00ff;
101 eObool_t fakesearch = (0x0000 == (m_dnginfo.param16 & 0xf000)) ? (eobool_false) : (eobool_true);
102 uint64_t brdnum = (m_dnginfo.param64 & 0x0000ff0000000000) >> 40;
103 const char *canboardname = eoboards_type2string(static_cast<eObrd_type_t>(brdnum));
104 uint64_t searchtime = (m_dnginfo.param64 & 0xffff000000000000) >> 48;
105 eObrd_protocolversion_t prot = {0};
106 eObrd_firmwareversion_t appl = {0};
107 uint64_t reqpr = (m_dnginfo.param64 & 0x000000ffff000000) >> 24;
108 uint64_t reqfw = (m_dnginfo.param64 & 0x0000000000ffffff);
109 char strOK[80] = "OK";
110
111 prot.major = reqpr >> 8;
112 prot.minor = reqpr & 0xff;
113 appl.major = (reqfw >> 16) & 0xff;
114 appl.minor = (reqfw >> 8) & 0xff;
115 appl.build = reqfw & 0xff;
116
117
118 if(eobool_true == fakesearch)
119 {
120 snprintf(strOK, sizeof(strOK), "OK but FAKE (without any control on CAN w/ get-fw-version<> message)");
121 }
122
123 snprintf(str, sizeof(str), "%s is %s for %d %s boards with target can protocol ver %d.%d and application ver %d.%d.%d. Search time was %d ms",
124 m_dnginfo.baseMessage.c_str(),
125 strOK,
126 num, canboardname,
127 prot.major, prot.minor,
128 appl.major, appl.minor, appl.build,
129 (int)searchtime
130 );
131 m_dnginfo.baseInfo.finalMessage.append(str);
132 } break;
133
134 case eoerror_value_CFG_candiscovery_detectedboard:
135 {
136 uint64_t brdnum = (m_dnginfo.param64 & 0x0000ff0000000000) >> 40;
137 const char *canboardname = eoboards_type2string(static_cast<eObrd_type_t>(brdnum));
138 uint64_t searchtime = (m_dnginfo.param64 & 0xffff000000000000) >> 48;
139 eObrd_protocolversion_t prot = {0};
140 eObrd_firmwareversion_t appl = {0};
141 uint64_t reqpr = (m_dnginfo.param64 & 0x000000ffff000000) >> 24;
142 uint64_t reqfw = (m_dnginfo.param64 & 0x0000000000ffffff);
143 uint8_t address;
144 prot.major = reqpr >> 8;
145 prot.minor = reqpr & 0xff;
146 appl.major = (reqfw >> 16) & 0xff;
147 appl.minor = (reqfw >> 8) & 0xff;
148 appl.build = reqfw & 0xff;
149 address = m_dnginfo.param16 & 0x000f;
150
151
152 snprintf(str, sizeof(str), "%s %s board in %s addr %d with can protocol ver %d.%d and application ver %d.%d.%d Search time was %d ms",
153 m_dnginfo.baseMessage.c_str(),
154 canboardname,
155 m_dnginfo.baseInfo.sourceCANPortStr.c_str(), address,
156 prot.major, prot.minor,
157 appl.major, appl.minor, appl.build,
158 (int)searchtime
159 );
160 m_dnginfo.baseInfo.finalMessage.append(str);
161 } break;
162
163 case eoerror_value_CFG_candiscovery_boardsmissing:
164 {
165 uint8_t numofmissing = m_dnginfo.param16 & 0x00ff;
166 const char *canboardname = eoboards_type2string(static_cast<eObrd_type_t>((m_dnginfo.param16 >> 8)));
167 uint64_t searchtime = (m_dnginfo.param64 & 0xffff000000000000) >> 48;
168 uint16_t maskofmissing = m_dnginfo.param64 & 0x000000000000ffff;
169
170 uint8_t n = 1;
171 uint8_t i = 0;
172
173 snprintf(str, sizeof(str), "%s %d missing %s boards for %d ms in %s:",
174 m_dnginfo.baseMessage.c_str(),
175 numofmissing,
176 canboardname,
177 (int)searchtime,
179 );
180 m_dnginfo.baseInfo.finalMessage.append(str);
181 for(i=1; i<15; i++)
182 {
183 if(eobool_true == eo_common_hlfword_bitcheck(maskofmissing, i))
184 {
185 snprintf(str, sizeof(str), "%d of %d: missing %s BOARD %s:%s:%d",
186 n, numofmissing, canboardname,
188 );
189 m_dnginfo.baseInfo.finalMessage.append(str);
190 n++;
191
192 }
193 }
194
195 } break;
196
197 case eoerror_value_CFG_candiscovery_boardsinvalid:
198 {
199 uint8_t numofinvalid = m_dnginfo.param16 & 0x00ff;
200 const char *canboardname = eoboards_type2string(static_cast<eObrd_type_t>(m_dnginfo.param16 >> 8));
201 uint64_t invalidmask = m_dnginfo.param64;
202 uint8_t n = 1;
203 uint8_t i = 0;
204 const char *empty = "";
205 const char *wrongtype = "WRONG BOARD TYPE";
206 const char *wrongprot = "WRONG PROTOCOL VERSION";
207 const char *wrongappl = "WRONG APPLICATION VERSION";
208
209 snprintf(str, sizeof(str), "%s %d invalid %s boards in %s:\n",
210 m_dnginfo.baseMessage.c_str(),
211 numofinvalid,
212 canboardname,
214 );
215 m_dnginfo.baseInfo.finalMessage.append(str);
216
217 for(int i=1; i<15; i++)
218 {
219 uint64_t val = (invalidmask >> (4*i)) & 0x0f;
220 if(0 != val)
221 {
222 snprintf(str, sizeof(str), "\t %d of %d: wrong %s because it has: %s%s%s \n",
223 n, numofinvalid, canboardname,
224 ((val & 0x1) == 0x1) ? (wrongtype) : (empty),
225 ((val & 0x2) == 0x2) ? (wrongappl) : (empty),
226 ((val & 0x4) == 0x4) ? (wrongprot) : (empty)
227 );
228
229 m_dnginfo.baseInfo.finalMessage.append(str);
230 n++;
231
232 }
233 }
234
235 } break;
236
237 case eoerror_value_CFG_skin_ok:
238 {
239 uint16_t maskcan1 = (m_dnginfo.param64 & 0x0000ffff00000000) >> 32;
240 uint16_t maskcan2 = (m_dnginfo.param64 & 0xffff000000000000) >> 48;
241 eObrd_protocolversion_t prot = {0};
242 eObrd_firmwareversion_t appl = {0};
243 uint64_t reqpr = (m_dnginfo.param64 & 0x00000000ffff0000) >> 16;
244 uint64_t reqfw = (m_dnginfo.param64 & 0x000000000000ffff);
245 prot.major = reqpr >> 8;
246 prot.minor = reqpr & 0xff;
247 appl.major = (reqfw >> 8) & 0xff;
248 appl.minor = reqfw & 0xff;
249 uint16_t numOfpatches = m_dnginfo.param16;
250
251 snprintf(str, sizeof(str), "%s on %d skin patches for boards on (can1map, can2map) = (0x%.4x, 0x%.4x) with target can protocol ver %d.%d and application ver %d.%d",
252 m_dnginfo.baseMessage.c_str(),
253 numOfpatches,
254 maskcan1, maskcan2,
255 prot.major, prot.minor,
256 appl.major, appl.minor
257 );
258 m_dnginfo.baseInfo.finalMessage.append(str);
259 } break;
260
261 case eoerror_value_CFG_skin_failed_toomanyboards:
262 case eoerror_value_CFG_inertials3_failed_toomanyboards:
263 case eoerror_value_CFG_temperatures_failed_toomanyboards:
264 {
265 uint8_t numOfReqBoards = (m_dnginfo.param16 & 0xff00) >> 8;
266 uint8_t numOfMaxBoards = m_dnginfo.param16 & 0x00ff;
267
268 uint16_t maskcan1 = (m_dnginfo.param64 & 0x000000000000ffff);
269 uint16_t maskcan2 = (m_dnginfo.param64 & 0x00000000ffff0000) >> 16;
270
271 snprintf(str, sizeof(str), " %s for %d boards. Limit of max number of boards is %d. Boards are on (can1map, can2map) = (0x%.4x, 0x%.4x)",
272 m_dnginfo.baseMessage.c_str(),
273 numOfReqBoards, numOfMaxBoards,
274 maskcan1, maskcan2
275 );
276 m_dnginfo.baseInfo.finalMessage.append(str);
277 } break;
278
279 case eoerror_value_CFG_skin_failed_candiscovery:
280 case eoerror_value_CFG_inertials3_failed_candiscovery:
281 case eoerror_value_CFG_temperatures_failed_candiscovery:
282 {
283 uint16_t incompMaskcan2 = (m_dnginfo.param64 & 0xffff000000000000) >> 48;
284 uint16_t incompMaskcan1 = (m_dnginfo.param64 & 0x0000ffff00000000) >> 32;
285 uint16_t missMaskcan2 = (m_dnginfo.param64 & 0x00000000ffff0000) >> 16;
286 uint16_t missMaskcan1 = (m_dnginfo.param64 & 0x000000000000ffff);
287 uint16_t numOfPatches = m_dnginfo.param16;
288
289 if (eoerror_value_CFG_skin_failed_candiscovery == value)
290 {
291 snprintf(str, sizeof(str), "%s for %d skin patches. ", m_dnginfo.baseMessage.c_str(), numOfPatches);
292 m_dnginfo.baseInfo.finalMessage.append(str);
293 }
294 else
295 {
296 snprintf(str, sizeof(str), "%s. ", m_dnginfo.baseMessage.c_str());
297 m_dnginfo.baseInfo.finalMessage.append(str);
298 }
299
300 snprintf(str, sizeof(str), "Missing can boards on (can1map, can2map) = (0x%.4x, 0x%.4x) and found but incompatible can boards on (can1map, can2map) = (0x%.4x, 0x%.4x)",
301 missMaskcan1, missMaskcan2,
302 incompMaskcan1, incompMaskcan2
303 );
304
305 m_dnginfo.baseInfo.finalMessage.append(str);
306 } break;
307
308 case eoerror_value_CFG_strain_ok:
309 case eoerror_value_CFG_strain_failed_candiscovery:
310 {
311 eObrd_protocolversion_t prot = {0};
312 eObrd_firmwareversion_t appl = {0};
313 uint64_t reqpr = (m_dnginfo.param64 & 0x00000000ffff0000) >> 16;
314 uint64_t reqfw = (m_dnginfo.param64 & 0x000000000000ffff);
315 prot.major = reqpr >> 8;
316 prot.minor = reqpr & 0xff;
317 appl.major = (reqfw >> 8) & 0xff;
318 appl.minor = reqfw & 0xff;
319 uint8_t strain = (m_dnginfo.param64 & 0x0000000f00000000) >> 20;
320 uint8_t address = m_dnginfo.param16 & 0x00ff;
321 uint8_t port = m_dnginfo.param16 >> 8;
322
323 snprintf(str, sizeof(str), "%s for board at addr:%d and port:%d with can protocol ver %d.%d and application ver %d.%d. Strain number is:%d",
324 m_dnginfo.baseMessage.c_str(),
325 address, port,
326 prot.major, prot.minor,
327 appl.major, appl.minor,
328 strain
329 );
330 m_dnginfo.baseInfo.finalMessage.append(str);
331 } break;
332
333 case eoerror_value_CFG_mais_ok:
334 case eoerror_value_CFG_mais_failed_candiscovery:
335 case eoerror_value_CFG_psc_ok:
336 case eoerror_value_CFG_psc_failed_candiscovery:
337 case eoerror_value_CFG_pos_ok:
338 case eoerror_value_CFG_pos_failed_candiscovery:
339 {
340 eObrd_protocolversion_t prot = {0};
341 eObrd_firmwareversion_t appl = {0};
342 uint64_t reqpr = (m_dnginfo.param64 & 0x00000000ffff0000) >> 16;
343 uint64_t reqfw = (m_dnginfo.param64 & 0x000000000000ffff);
344 prot.major = reqpr >> 8;
345 prot.minor = reqpr & 0xff;
346 appl.major = (reqfw >> 8) & 0xff;
347 appl.minor = reqfw & 0xff;
348 uint8_t address = m_dnginfo.param16 & 0x00ff;
349 uint8_t port = m_dnginfo.param16 >> 8;
350
351 snprintf(str, sizeof(str), "%s on board at addr: %d and port:%d with can protocol ver %d.%d and application ver %d.%d.",
352 m_dnginfo.baseMessage.c_str(),
353 address,
354 port,
355 prot.major, prot.minor,
356 appl.major, appl.minor
357 );
358 m_dnginfo.baseInfo.finalMessage.append(str);
359 } break;
360
361 case eoerror_value_CFG_mais_failed_verify_because_active:
362 case eoerror_value_CFG_mc_foc_ok:
363 case eoerror_value_CFG_mc_foc_failed_candiscovery_of_foc:
364 case eoerror_value_CFG_mc_foc_failed_encoders_verify:
365 case eoerror_value_CFG_mc_mc4_ok:
366 case eoerror_value_CFG_mc_mc4_failed_candiscovery_of_mc4:
367 case eoerror_value_CFG_mc_mc4_failed_mais_verify:
368 case eoerror_value_CFG_mc_mc4plus_ok:
369 case eoerror_value_CFG_mc_mc4plus_failed_encoders_verify:
370 case eoerror_value_CFG_comm_cannotloadaregularrop:
371 case eoerror_value_CFG_mc_mc4plusmais_ok:
372 case eoerror_value_CFG_mc_mc4plusmais_failed_encoders_verify:
373 case eoerror_value_CFG_mc_mc4plusmais_failed_candiscovery_of_mais:
374 case eoerror_value_CFG_services_not_verified_yet:
375 case eoerror_value_CFG_mc_not_verified_yet:
376 case eoerror_value_CFG_strain_not_verified_yet:
377 case eoerror_value_CFG_mais_not_verified_yet:
378 case eoerror_value_CFG_skin_not_verified_yet:
379 case eoerror_value_CFG_inertials3_not_verified_yet:
380 case eoerror_value_CFG_encoders_not_verified_yet:
381 case eoerror_value_CFG_mc_using_onboard_config:
382 case eoerror_value_CFG_strain_using_onboard_config:
383 case eoerror_value_CFG_mais_using_onboard_config:
384 case eoerror_value_CFG_inertials3_using_onboard_config:
385 case eoerror_value_CFG_skin_using_onboard_config:
386 case eoerror_value_CFG_inertials3_ok:
387 case eoerror_value_CFG_temperatures_not_verified_yet:
388 case eoerror_value_CFG_temperatures_ok:
389 case eoerror_value_CFG_temperatures_using_onboard_config:
390 case eoerror_value_CFG_psc_failed_verify_because_active:
391 case eoerror_value_CFG_psc_not_verified_yet:
392 case eoerror_value_CFG_psc_using_onboard_config:
393 case eoerror_value_CFG_mc_mc2pluspsc_ok:
394 case eoerror_value_CFG_mc_mc2pluspsc_failed_encoders_verify:
395 case eoerror_value_CFG_mc_mc2pluspsc_failed_candiscovery_of_pscs:
396 case eoerror_value_CFG_inertials3_failed_notsupported:
397 case eoerror_value_CFG_temperatures_failed_notsupported:
398 case eoerror_value_CFG_mais_failed_notsupported:
399 case eoerror_value_CFG_strain_failed_notsupported:
400 case eoerror_value_CFG_skin_failed_notsupported:
401 case eoerror_value_CFG_psc_failed_notsupported:
402 case eoerror_value_CFG_mc_failed_notsupported:
403 case eoerror_value_CFG_encoders_failed_notsupported:
404 case eoerror_value_CFG_pos_not_verified_yet:
405 case eoerror_value_CFG_pos_using_onboard_config:
406 case eoerror_value_CFG_pos_failed_notsupported:
407 case eoerror_value_CFG_mc_mc4plusfaps_ok:
408 case eoerror_value_CFG_mc_mc4plusfaps_failed_encoders_verify:
409 case eoerror_value_CFG_mc_mc4plusfaps_failed_candiscovery:
410 case eoerror_value_CFG_mc_mc4pluspmc_ok:
411 case eoerror_value_CFG_mc_mc4pluspmc_failed_encoders_verify:
412 case eoerror_value_CFG_mc_mc4pluspmc_failed_candiscovery_of_pmc:
413 case eoerror_value_CFG_ft_ok:
414 case eoerror_value_CFG_ft_failed_candiscovery:
415 case eoerror_value_CFG_ft_not_verified_yet:
416 case eoerror_value_CFG_ft_using_onboard_config:
417 case eoerror_value_CFG_ft_failed_notsupported:
418 case eoerror_value_CFG_ft_failed_fullscales:
419 case eoerror_value_CFG_bat_ok:
420 case eoerror_value_CFG_bat_failed_candiscovery:
421 case eoerror_value_CFG_bat_not_verified_yet:
422 case eoerror_value_CFG_bat_using_onboard_config:
423 case eoerror_value_CFG_bat_failed_notsupported:
424 {
426 } break;
427
428 // p16&0xf000: number of joint; primary encs: failure mask in p16&0x000f and errorcodes in p64&0x0000ffff; secondary encs: failure mask in p16&0x00f0 and errorcodes in p64&0xffff0000"},
429 case eoerror_value_CFG_encoders_ok:
430 case eoerror_value_CFG_encoders_failed_verify:
431 {
432 uint8_t numOfJoints = (m_dnginfo.param16 & 0xf000) >> 12;
433 uint8_t failmaskenc1 = m_dnginfo.param16 & 0x000f;
434 int16_t errorenc1 = m_dnginfo.param64 & 0x0000ffff;
435 uint8_t failmaskenc2 = (m_dnginfo.param16 & 0x00f0) >> 4;
436 int16_t errorenc2 = (m_dnginfo.param64 & 0xffff0000) >> 16;
437
438 int16_t rawerror1 = errorenc1 & failmaskenc1;
439 int16_t rawerror2 = errorenc2 & failmaskenc2;
440 snprintf(str, sizeof(str), "%s", m_dnginfo.baseMessage.c_str());
441 m_dnginfo.baseInfo.finalMessage.append(str);
442
443 for(auto i=0; i < numOfJoints; i++)
444 {
445 // 1. check if joint ith has encoder with errors
446 auto primary_enc_with_error = (failmaskenc1 & (1<<i));
447 auto secondary_enc_with_error = (failmaskenc2 & (1<<i));
448 auto primary_error_code = 0;
449 auto secondary_error_code = 0;
450 if(primary_enc_with_error)
451 {
452 primary_error_code = ( (errorenc1 & (0xf <<i)) >> 4*i);
454 snprintf(str, sizeof(str), " joint %d (%s) has error on primary encoder (code=%d). ",
455 i, m_dnginfo.baseInfo.axisName.c_str(), primary_error_code); //TODO: get a string instead of a code
456 m_dnginfo.baseInfo.finalMessage.append(str);
457 }
458
459 if(secondary_enc_with_error)
460 {
461 secondary_error_code = ( (errorenc2 & (0xf <<i)) >> 4*i);
463 snprintf(str, sizeof(str), " joint %d (%s) has error on secodary encoder (code=%d)",
464 i, m_dnginfo.baseInfo.axisName.c_str(), secondary_error_code); //TODO: get a string instead of a code
465 m_dnginfo.baseInfo.finalMessage.append(str);
466 }
467
468
469 }
470
471 } break;
472
473 case eoerror_value_CFG_inertials3_failed_unsupportedsensor:
474 {
475 int16_t unsuppsens = m_dnginfo.param16;
476
477 snprintf(str, sizeof(str), "%s. Number of unsupported sens is %d",
478 m_dnginfo.baseMessage.c_str(),
479 unsuppsens
480 );
481 m_dnginfo.baseInfo.finalMessage.append(str);
482 } break;
483
484 case eoerror_value_CFG_inertials3_changed_requestedrate:
485 case eoerror_value_CFG_temperatures_changed_requestedrate:
486 case eoerror_value_CFG_psc_changed_requestedrate:
487 case eoerror_value_CFG_pos_changed_requestedrate:
488 {
489 uint8_t reqrate = (m_dnginfo.param16 & 0xff00) >> 8;
490 uint8_t assrate = m_dnginfo.param16 & 0x00ff;
491
492 snprintf(str, sizeof(str), "%s. Requested rate %u and Assigned rate %u",
493 m_dnginfo.baseMessage.c_str(),
494 reqrate,
495 assrate
496 );
497 m_dnginfo.baseInfo.finalMessage.append(str);
498 } break;
499
500 case eoerror_value_CFG_inertials3_failed_generic:
501 case eoerror_value_CFG_temperatures_failed_generic:
502 {
503 uint8_t numOfSens = m_dnginfo.param64;
504
505 snprintf(str, sizeof(str), "%s for %d sensors",
506 m_dnginfo.baseMessage.c_str(),
507 numOfSens
508 );
509 m_dnginfo.baseInfo.finalMessage.append(str);
510 } break;
511
512 case EOERROR_VALUE_DUMMY:
513 {
514 m_dnginfo.baseInfo.finalMessage.append(": unrecognised eoerror_category_Config error value.");
515
516
517 } break;
518
519 default:
520 {
522
523 }
524
525 }//end switch
526
527
528
529}
530
531
532
533
534/**************************************************************************************************************************/
535/****************************************** MotionControlParser ***************************************************/
536/**************************************************************************************************************************/
537
538// private class functions
539std::string MotionControlParser::motorStatusBitsToString(eOmc_motorFaultState_t motorstatus)
540{
541 // dimesion of the array is hard-code but it must be aligned w/ the union typedef eOmc_motorFaultState_t
542 static const std::array<std::string_view, eOmc_motorFaultState_numberof> s_motor_fault_status =
543 {
544 //B0 L
545 "ExternalFaultAsserted",
546 "UnderVoltageFailure",
547 "OverVoltageFailure",
548 "OverCurrentFailure",
549 //B0 H
550 "DHESInvalidValue",
551 "AS5045CSumError",
552 "DHESInvalidSequence",
553 "CANInvalidProtocol",
554 //B1 L
555 "CAN_BufferOverRun",
556 "SetpointExpired",
557 "CAN_TXIsPasv",
558 "CAN_RXIsPasv",
559 //B1 H
560 "CAN_IsWarnTX",
561 "CAN_IsWarnRX",
562 "OverHeatingFailure",
563 "",
564 //B2 L
565 "ADCCalFailure",
566 "I2TFailure",
567 "EMUROMFault",
568 "EMUROMCRCFault",
569 //B2 H
570 "EncoderFault",
571 "FirmwareSPITimingError",
572 "AS5045CalcError",
573 "FirmwarePWMFatalError",
574 //B3 L
575 "CAN_TXWasPasv",
576 "CAN_RXWasPasv",
577 "CAN_RTRFlagActive",
578 "CAN_WasWarn",
579 //B3 H
580 "CAN_DLCError",
581 "SiliconRevisionFault",
582 "PositionLimitUpper",
583 "PositionLimitLower"
584 };
585
586 std::string statusstring = {};
587 statusstring.reserve(256);
588
589 for (uint8_t i = 0; i < eOmc_motorFaultState_numberof; i++) // important to loop over the eOmc_motorFaultState_numberof (dimension of the union typedef eOmc_motorFaultState_t)
590 {
591 // check bit by bit and add to ss the faulted bits
592 if(embot::core::binary::bit::check(motorstatus.bitmask, i))
593 {
594 statusstring.append(static_cast<const char*>(s_motor_fault_status.at(i).data()));
595 statusstring.append(" ");
596 }
597 }
598 return statusstring;
599}
600
601MotionControlParser::MotionControlParser(AuxEmbeddedInfo &dnginfo, EntityNameProvider &entityNameProvider):DefaultParser(dnginfo, entityNameProvider){;}
602
604{
605 char str[512] = {0};
606 eOerror_value_t value = eoerror_code2value(m_dnginfo.errorCode);
608
609 switch(value)
610 {
611
612 case eoerror_value_MC_motor_external_fault:
613 case eoerror_value_MC_motor_qencoder_phase_disappeared:
614 {
615 snprintf(str, sizeof(str), " %s", m_dnginfo.baseMessage.c_str());
616 m_dnginfo.baseInfo.finalMessage.append(str);
617 } break;
618
619 case eoerror_value_MC_motor_overcurrent:
620 case eoerror_value_MC_motor_i2t_limit:
621 case eoerror_value_MC_motor_hallsensors:
622 case eoerror_value_MC_motor_can_invalid_prot:
623 case eoerror_value_MC_motor_can_generic:
624 case eoerror_value_MC_motor_can_no_answer:
625 case eoerror_value_MC_axis_torque_sens:
626 case eoerror_value_MC_joint_hard_limit:
627 {
628 uint8_t joint_num = m_dnginfo.param16 & 0x00ff;
630
631 snprintf(str, sizeof(str), " %s (Joint=%s (NIB=%d))", m_dnginfo.baseMessage.c_str(), m_dnginfo.baseInfo.axisName.c_str(), joint_num);
632 m_dnginfo.baseInfo.finalMessage.append(str);
633 } break;
634
635 case eoerror_value_MC_abs_enc_invalid:
636 case eoerror_value_MC_abs_enc_spikes:
637 case eoerror_value_MC_abs_enc_timeout:
638 {
639 std::string encoderTypeName = {};
640 uint8_t joint_num = m_dnginfo.param16 & 0x00ff;
641 uint8_t enc_port = (m_dnginfo.param16 & 0xff00)>>8;
643 m_entityNameProvider.getEncoderTypeName(joint_num, eomc_pos_atjoint, encoderTypeName);
644 std::transform(encoderTypeName.begin(), encoderTypeName.end(), encoderTypeName.begin(), ::toupper);
645
646 snprintf(str, sizeof(str), " %s (Joint=%s (NIB=%d), encoderPort=%d, encoderType=%s)",
647 m_dnginfo.baseMessage.c_str(), m_dnginfo.baseInfo.axisName.c_str(), joint_num, enc_port, encoderTypeName.c_str()
648 );
649 m_dnginfo.baseInfo.finalMessage.append(str);
650 } break;
651
652
653 //case eoerror_value_MC_motor_qencoder_dirty:
654 case eoerror_value_MC_motor_qencoder_phase: //TBD: check encoder raw value
655 {
656 uint16_t joint_num = m_dnginfo.param16;
657 uint16_t enc_raw_value = m_dnginfo.param64 & 0xffff;
659
660 snprintf(str, sizeof(str), " %s (Joint=%s (NIB=%d), Raw_quad_encoder_value=%d)",
661 m_dnginfo.baseMessage.c_str(), m_dnginfo.baseInfo.axisName.c_str(), joint_num, enc_raw_value
662 );
663 m_dnginfo.baseInfo.finalMessage.append(str);
664 } break;
665
666 case eoerror_value_MC_motor_qencoder_dirty:
667 {
668 uint16_t joint_num = m_dnginfo.param16;
669 uint16_t dirty_error = m_dnginfo.param64 & 0xffff;
670 uint16_t index_error = (m_dnginfo.param64 & 0xffff0000)>>16;
671 uint16_t phase_error = (m_dnginfo.param64 & 0xffff00000000)>>32;
673
674 snprintf(str, sizeof(str), " %s (Joint=%s (NIB=%d), index=%d, dirty=%d, phase=%d)",
675 m_dnginfo.baseMessage.c_str(), m_dnginfo.baseInfo.axisName.c_str(), joint_num, index_error, dirty_error, phase_error
676 );
677 m_dnginfo.baseInfo.finalMessage.append(str);
678 } break;
679
680 case eoerror_value_MC_generic_error: //TBD Check print
681 {
682 eOmc_motorFaultState_t motor_status;
683 uint16_t joint_num = m_dnginfo.param16;
684 motor_status.bitmask = m_dnginfo.param64 & 0xffffffff;
686 std::string motorStatusString = motorStatusBitsToString(motor_status);
687 snprintf(str, sizeof(str), " %s (Joint=%s (NIB=%d) (Errors:%s)",
688 m_dnginfo.baseMessage.c_str(), m_dnginfo.baseInfo.axisName.c_str(), joint_num, motorStatusString.c_str()
689 );
690 m_dnginfo.baseInfo.finalMessage.append(str);
691 } break;
692
693 case eoerror_value_MC_motor_wrong_state: //TBD: check states
694 {
695 uint16_t joint_num = m_dnginfo.param16;
696 uint16_t req_state = (m_dnginfo.param64 & 0xf0)>>4;
697 uint16_t cur_state = m_dnginfo.param64 & 0x0f;
698
700
701
702 snprintf(str, sizeof(str), " %s Joint=%s (NIB=%d). The requested state is %d, but the current is %d)",
703 m_dnginfo.baseMessage.c_str(), m_dnginfo.baseInfo.axisName.c_str(), joint_num, req_state, cur_state
704 );
705 m_dnginfo.baseInfo.finalMessage.append(str);
706 } break;
707
708 case eoerror_value_MC_motor_overheating:
709 {
710 uint16_t joint_num = m_dnginfo.param16;
711 int16_t temp_raw_value = m_dnginfo.param64 & 0xffff;
712
714
715 snprintf(str, sizeof(str), " %s (Joint=%s (NIB=%d), Raw_temperature_value=%d)",
716 m_dnginfo.baseMessage.c_str(), m_dnginfo.baseInfo.axisName.c_str(), joint_num, temp_raw_value
717 );
718 m_dnginfo.baseInfo.finalMessage.append(str);
719 } break;
720
721 case EOERROR_VALUE_DUMMY:
722 {
723 m_dnginfo.baseInfo.finalMessage.append(": unrecognised eoerror_category_MotionControl error value.");
724
725
726 } break;
727
728 default:
729 {
731
732 }
733
734 }//end switch
735
736
737
738}
739
740
741
742
743/**************************************************************************************************************************/
744/****************************************** SkinParser ***************************************************/
745/**************************************************************************************************************************/
746
747
748
749SkinParser::SkinParser(AuxEmbeddedInfo &dnginfo, EntityNameProvider &entityNameProvider):DefaultParser(dnginfo, entityNameProvider){;}
750
752{
753 char str[512] = {0};
754 eOerror_value_t value = eoerror_code2value(m_dnginfo.errorCode);
756
757 switch (value)
758 {
759 case eoerror_value_SK_unspecified:
760 case eoerror_value_SK_obsoletecommand:
761 {
763 } break;
764
765 case eoerror_value_SK_arrayofcandataoverflow:
766 {
767 uint8_t frame_id = m_dnginfo.param16 & 0x00ff;
768 uint8_t frame_size = (m_dnginfo.param16 & 0xf000) >> 12;
769 uint64_t frame_data = m_dnginfo.param64;
770
771 snprintf(str, sizeof(str), " %s. Frame.ID=%d, Frame.Size=%d Frame.Data=0x%lx",
772 m_dnginfo.baseMessage.c_str(), frame_id, frame_size, frame_data
773 );
774 m_dnginfo.baseInfo.finalMessage.append(str);
775 } break;
776
777 case eoerror_value_SK_onoroff:
778 {
779 std::string emsboardstate = "unknown";
780 switch (m_dnginfo.param16)
781 {
782 case 0: emsboardstate = "OFF"; break;
783 case 1: emsboardstate = "ON"; break;
784 };
785
786 snprintf(str, sizeof(str), " %s %s", m_dnginfo.baseMessage.c_str(), emsboardstate.c_str());
787 m_dnginfo.baseInfo.finalMessage.append(str);
788 } break;
789
790 case eoerror_value_SK_unexpecteddata:
791 {
792 std::string emsboardstate = "unknown";
793 switch (m_dnginfo.param16)
794 {
795 case 0: emsboardstate = "CFG"; break;
796 case 1: emsboardstate = "RUN"; break;
797 }
798
799 snprintf(str, sizeof(str), " %s %s", m_dnginfo.baseMessage.c_str(), emsboardstate.c_str());
800 m_dnginfo.baseInfo.finalMessage.append(str);
801 } break;
802
803 case EOERROR_VALUE_DUMMY:
804 {
805 m_dnginfo.baseInfo.finalMessage.append(": unrecognized eoerror_category_Skin error value");
806 } break;
807
808 default:
809 {
811
812 } break;
813 }
814}
815
816/**************************************************************************************************************************/
817/****************************************** HwErrorParser ***************************************************/
818/**************************************************************************************************************************/
819
820
821
822HwErrorParser::HwErrorParser(AuxEmbeddedInfo &dnginfo, EntityNameProvider &entityNameProvider):DefaultParser(dnginfo, entityNameProvider){;}
823
825{
826 char str[512] = {0};
827 eOerror_value_t value = eoerror_code2value(m_dnginfo.errorCode);
829
830 switch(value)
831 {
832
833 case eoerror_value_HW_strain_saturation:
834 {
835 uint16_t channel = m_dnginfo.param16;
836 uint32_t lower_saturation_counts = m_dnginfo.param64 & 0xffffffff;
837 uint32_t upper_saturation_counts = (m_dnginfo.param64 & 0xffffffff00000000)>>32;
838 snprintf(str, sizeof(str), " %s %d is the channel involved. In the last second, the lower saturation counts is %d and the upper one is %d",
839 m_dnginfo.baseMessage.c_str(),
840 channel,
841 lower_saturation_counts,
842 upper_saturation_counts);
843 m_dnginfo.baseInfo.finalMessage.append(str);
844 } break;
845
846 case eoerror_value_HW_encoder_invalid_value:
847 case eoerror_value_HW_encoder_close_to_limits:
848 case eoerror_value_HW_encoder_crc:
849 case eoerror_value_HW_encoder_not_connected:
850 {
851 uint8_t joint_num = m_dnginfo.param16 & 0x00ff;
852 int16_t number_of_errors = m_dnginfo.param64 & 0x000000000000ffff;
854
855 snprintf(str, sizeof(str), " %s (Joint=%s (NIB=%d) Number of error in 10 seconds is: %d)",
856 m_dnginfo.baseMessage.c_str(),
857 m_dnginfo.baseInfo.axisName.c_str(),
858 joint_num,
859 number_of_errors);
860 m_dnginfo.baseInfo.finalMessage.append(str);
861 } break;
862
863 case EOERROR_VALUE_DUMMY:
864 {
865 m_dnginfo.baseInfo.finalMessage.append(": unrecognised eoerror_category_HardWare error value.");
866
867
868 } break;
869
870 default:
871 {
873
874 }
875
876 }//end switch
877
878
879
880}
881
882
883
884/**************************************************************************************************************************/
885/****************************************** SysErrorParser ***************************************************/
886/**************************************************************************************************************************/
887
888// Private class functions
889void SysParser::canMask2canBoardsStr(uint16_t canmask, diagstr canboardsstr)
890{
891 for(int i=1; i<15; i++)
892 {
893 diagstr tmpstr{};
894 if ( (canmask & (1<<i)) == (1<<i))
895 {
896 snprintf(tmpstr, diagstr_lenght, "%d", i);
897 strcat(canboardsstr, tmpstr);
898 }
899 }
900}
901
902void SysParser::getCanMonitorInfo(eOmn_serv_category_t &serv_category, diagstr boardsOnCan1, diagstr boardsOnCan2)
903{
904 serv_category = (eOmn_serv_category_t)m_dnginfo.param16;
905 uint16_t boardsMaskCan1 = (m_dnginfo.param64 & 0x00000000ffff0000) >> 16;
906 uint16_t boardsMaskCan2 = (m_dnginfo.param64 & 0x000000000000ffff);
907
908 canMask2canBoardsStr(boardsMaskCan1, boardsOnCan1);
909 canMask2canBoardsStr(boardsMaskCan2, boardsOnCan2);
910
911}
912
913void SysParser::getCanMonitorInfoWithTime(eOmn_serv_category_t &serv_category, diagstr boardsOnCan1, diagstr boardsOnCan2, uint32_t &time)
914{
915 getCanMonitorInfo(serv_category, boardsOnCan1, boardsOnCan2);
916 time = (m_dnginfo.param64 & 0xffffffff00000000) >> 32;
917}
918
919SysParser::SysParser(AuxEmbeddedInfo &dnginfo, EntityNameProvider &entityNameProvider):DefaultParser(dnginfo, entityNameProvider){;}
921{
922 char str[512] = {0};
923 eOerror_value_t value = eoerror_code2value(m_dnginfo.errorCode);
925
926 switch(value)
927 {
928
929 case eoerror_value_SYS_runninghappily:
930 {
931 std::string appstate = "unknown";
932 switch(m_dnginfo.param16&0x000f)
933 {
934 case 0: appstate="just restarted"; break;
935 case 1: appstate="idle"; break;
936 case 2: appstate="running"; break;
937 };
938 snprintf(str, sizeof(str), " %s Application state is %s.", m_dnginfo.baseMessage.c_str(), appstate.c_str());
939 m_dnginfo.baseInfo.finalMessage.append(str);
940 }break;
941
942 case eoerror_value_SYS_ctrloop_execoverflowRX:
943 {
944 //here the param64 contains: TX RX DO TX
945 uint16_t prev_rx = (m_dnginfo.param64 & 0x0000ffff00000000)>>32;
946 uint16_t prev_do = (m_dnginfo.param64 & 0x00000000ffff0000)>>16;
947 uint16_t prev_tx = (m_dnginfo.param64 & 0x000000000000ffff);
948 uint16_t prev_prev_tx = (m_dnginfo.param64 & 0xffff000000000000)>>48;
949 //currently we don't print the two time ago TX.
950
951 //snprintf(str, sizeof(str), " %s RX execution time %d[usec]. Latest previous execution times[usec] RX=%d, DO=%d, TX=%d", m_dnginfo.baseMessage.c_str(), m_dnginfo.param16, prev_rx, prev_do, prev_tx);
952 snprintf(str, sizeof(str), " %s RX execution time %d[usec]. Latest previous execution times[usec] (..., Tx=%d);(RX=%d, DO=%d, TX=%d);",
953 m_dnginfo.baseMessage.c_str(), m_dnginfo.param16, prev_prev_tx, prev_rx, prev_do, prev_tx);
954 m_dnginfo.baseInfo.finalMessage.append(str);
955 }break;
956
957 case eoerror_value_SYS_ctrloop_execoverflowDO:
958 {
959 //here the param64 contains: RX DO TX RX
960 uint16_t prev_do = (m_dnginfo.param64 & 0x0000ffff00000000)>>32;
961 uint16_t prev_tx = (m_dnginfo.param64 & 0x00000000ffff0000)>>16;
962 uint16_t prev_rx = (m_dnginfo.param64 & 0x000000000000ffff);
963 uint16_t prev_prev_rx = (m_dnginfo.param64 & 0xffff000000000000)>>48;
964 //currently we don't print the two time ago RX.
965 //snprintf(str, sizeof(str), " %s DO execution time %d[usec]. Latest previous execution times[usec] DO=%d, TX=%d, RX=%d", m_dnginfo.baseMessage.c_str(), m_dnginfo.param16, prev_do, prev_tx, prev_rx);
966 snprintf(str, sizeof(str), " %s DO execution time %d[usec]. Latest previous execution times[usec] (..., Tx=%s);(RX=%d, DO=%d, TX=%d); (Rx=%d, ...);",
967 m_dnginfo.baseMessage.c_str(), m_dnginfo.param16, "N/A", prev_prev_rx, prev_do, prev_tx, prev_rx);
968 m_dnginfo.baseInfo.finalMessage.append(str);
969 }break;
970
971 case eoerror_value_SYS_ctrloop_execoverflowTX:
972 {
973 //here the param64 contains: DO TX RX DO
974 uint16_t prev_tx = (m_dnginfo.param64 & 0x0000ffff00000000)>>32;
975 uint16_t prev_rx = (m_dnginfo.param64 & 0x00000000ffff0000)>>16;
976 uint16_t prev_do = (m_dnginfo.param64 & 0x000000000000ffff);
977 uint8_t can1_frames = (m_dnginfo.param64 & 0x00ff000000000000) >> 48;
978 uint8_t can2_frames = (m_dnginfo.param64 & 0xff00000000000000) >> 56;
979 //snprintf(str, sizeof(str), " %s TX execution time %d[usec]. Latest previous execution times[usec] TX=%d, RX=%d, DO=%d. Num of CAN frames[CAN1,CAN2]=[%u %u]", m_dnginfo.baseMessage.c_str(),
980 //m_dnginfo.param16, prev_tx, prev_rx, prev_do, can1_frames, can2_frames );
981 snprintf(str, sizeof(str), " %s TX execution time %d[usec]. Latest previous execution times[usec] (RX=%s, DO=%s, TX=%d); (Rx=%d, DO=%d, ...). Num of CAN frames[CAN1,CAN2]=[%u %u]",
982 m_dnginfo.baseMessage.c_str(), m_dnginfo.param16, "N/A", "N/A" , prev_tx, prev_rx, prev_do, can1_frames, can2_frames);
983 m_dnginfo.baseInfo.finalMessage.append(str);
984 }break;
985
986 case eoerror_value_SYS_ropparsingerror:
987 {
988 snprintf(str, sizeof(str), " %s Error code is %d (eOparserResult_t).", m_dnginfo.baseMessage.c_str(), m_dnginfo.param16);
989 m_dnginfo.baseInfo.finalMessage.append(str);
990 }break;
991
992 case eoerror_value_SYS_halerror:
993 {
994 snprintf(str, sizeof(str), " %s HAL error code is %d.", m_dnginfo.baseMessage.c_str(), m_dnginfo.param16);
995 m_dnginfo.baseInfo.finalMessage.append(str);
996 }break;
997
998 case eoerror_value_SYS_osalerror:
999 {
1000 snprintf(str, sizeof(str), " %s OSAL error code is %d.", m_dnginfo.baseMessage.c_str(), m_dnginfo.param16);
1001 m_dnginfo.baseInfo.finalMessage.append(str);
1002 }break;
1003
1004 case eoerror_value_SYS_ipalerror:
1005 {
1006 snprintf(str, sizeof(str), " %s IPAL error code is %d.", m_dnginfo.baseMessage.c_str(), m_dnginfo.param16);
1007 m_dnginfo.baseInfo.finalMessage.append(str);
1008 }break;
1009
1010 case eoerror_value_SYS_dispatcherfifooverflow:
1011 {
1012 snprintf(str, sizeof(str), " %s Number of lost items is %d.", m_dnginfo.baseMessage.c_str(), m_dnginfo.param16);
1013 m_dnginfo.baseInfo.finalMessage.append(str);
1014 }break;
1015
1016 case eoerror_value_SYS_canservices_txfifooverflow:
1017 {
1018 snprintf(str, sizeof(str), " %s CanPort=%s Frame.ID=%d, Frame.Size=%d Frame.Data=0x%lx",
1020 m_dnginfo.baseInfo.finalMessage.append(str);
1021 }break;
1022
1023 case eoerror_value_SYS_canservices_txbusfailure:
1024 {
1025 snprintf(str, sizeof(str), " %s CanPort=%s. Size of fifo is %d", m_dnginfo.baseMessage.c_str(), m_dnginfo.baseInfo.sourceCANPortStr.c_str(), ((m_dnginfo.param16 & 0xff00) >>8));
1026 m_dnginfo.baseInfo.finalMessage.append(str);
1027 }break;
1028
1029 case eoerror_value_SYS_canservices_formingfailure:
1030 {
1031 snprintf(str, sizeof(str), " %s CanPort=%s. Message class is %d. Message cmd is %d", m_dnginfo.baseMessage.c_str(), m_dnginfo.baseInfo.sourceCANPortStr.c_str(), ((m_dnginfo.param16 & 0xff00) >>8), (m_dnginfo.param16 & 0x00ff));
1032 m_dnginfo.baseInfo.finalMessage.append(str);
1033 }break;
1034
1035 case eoerror_value_SYS_canservices_parsingfailure:
1036 {
1037 snprintf(str, sizeof(str), " %s CanPort=%s. Frame.size=%d. Frame.Id=%d ", m_dnginfo.baseMessage.c_str(), m_dnginfo.baseInfo.sourceCANPortStr.c_str(), ((m_dnginfo.param16 & 0xf000) >>12), (m_dnginfo.param16 & 0x0fff));
1038 m_dnginfo.baseInfo.finalMessage.append(str);
1039 }break;
1040
1041 case eoerror_value_SYS_canservices_genericerror:
1042 {
1043 snprintf(str, sizeof(str), " %s error code is %d ", m_dnginfo.baseMessage.c_str(), m_dnginfo.param16);
1044 m_dnginfo.baseInfo.finalMessage.append(str);
1045
1046 }break;
1047
1048 case eoerror_value_SYS_ctrloop_rxphasemin:
1049 case eoerror_value_SYS_ctrloop_dophasemin:
1050 case eoerror_value_SYS_ctrloop_txphasemin:
1051 case eoerror_value_SYS_ctrloop_rxphaseaverage:
1052 case eoerror_value_SYS_ctrloop_dophaseaverage:
1053 case eoerror_value_SYS_ctrloop_txphaseaverage:
1054 case eoerror_value_SYS_ctrloop_rxphasemax:
1055 case eoerror_value_SYS_ctrloop_dophasemax:
1056 case eoerror_value_SYS_ctrloop_txphasemax:
1057 {
1058 snprintf(str, sizeof(str), " %s, monitored over %f sec is %d microsec", m_dnginfo.baseMessage.c_str(),
1059 0.01*static_cast<float>(m_dnginfo.param64 & 0xffff),
1061 );
1062 m_dnginfo.baseInfo.finalMessage.append(str);
1063 } break;
1064
1065 case eoerror_value_SYS_exec_time_stats:
1066 {
1067 static constexpr const char * const names[4] = { "runner.RX()", "runner.DO()", "runner.TX()", "other.ID = " };
1068 std::string actor = {};
1069 if(m_dnginfo.param16 < 3)
1070 {
1071 actor = names[m_dnginfo.param16];
1072 }
1073 else
1074 {
1075 actor= names[3] + std::to_string(m_dnginfo.param16);
1076 }
1077
1078 snprintf(str, sizeof(str), " %s: %s -> (%d, %d, %d) us over %f sec",
1079 m_dnginfo.baseMessage.c_str(),
1080 actor.c_str(),
1081 static_cast<uint16_t>((m_dnginfo.param64 >> 48) & 0xffff), // min
1082 static_cast<uint16_t>((m_dnginfo.param64 >> 32) & 0xffff), // average
1083 static_cast<uint16_t>((m_dnginfo.param64 >> 16) & 0xffff), // max
1084 0.01*static_cast<float>(m_dnginfo.param64 & 0xffff) // period
1085 );
1086 m_dnginfo.baseInfo.finalMessage.append(str);
1087 } break;
1088
1089 case eoerror_value_SYS_proxy_forward_fails:
1090 {
1091 snprintf(str, sizeof(str), " %s. ROP.sign=%d, ROP.id=%d. Proxy list capacity is %d, size is %d ",
1092 m_dnginfo.baseMessage.c_str(),
1093 (int32_t)((m_dnginfo.param64&0xffffffff00000000)>>32),
1094 (int32_t)(m_dnginfo.param64&0x00000000ffffffff),
1095 ((m_dnginfo.param16&0xff00)>>8), (m_dnginfo.param16&0x00ff));
1096 m_dnginfo.baseInfo.finalMessage.append(str);
1097
1098 }break;
1099
1100 case eoerror_value_SYS_proxy_ropdes_notfound:
1101 {
1102 snprintf(str, sizeof(str), " %s ROP.id=%d ", m_dnginfo.baseMessage.c_str(), (int32_t)(m_dnginfo.param64&0x00000000ffffffff));
1103 m_dnginfo.baseInfo.finalMessage.append(str);
1104
1105 }break;
1106
1107 case eoerror_value_SYS_canservices_canprint:
1108 {
1109 snprintf(str, sizeof(str), " %s CanPort=%s Frame.Size=%d Frame.Data=0x%lx", m_dnginfo.baseMessage.c_str(), m_dnginfo.baseInfo.sourceCANPortStr.c_str(), m_dnginfo.param16, m_dnginfo.param64 );
1110 m_dnginfo.baseInfo.finalMessage.append(str);
1111 }break;
1112
1113 case eoerror_value_SYS_canservices_rxmaisbug:
1114 {
1115 snprintf(str, sizeof(str), " %s CanPort=%s Frame.Size=%d Frame.Data=0x%lx", m_dnginfo.baseMessage.c_str(), m_dnginfo.baseInfo.sourceCANPortStr.c_str(), m_dnginfo.param16, m_dnginfo.param64 );
1116 m_dnginfo.baseInfo.finalMessage.append(str);
1117 }break;
1118
1119 case eoerror_value_SYS_canservices_rxfromwrongboard:
1120 {
1121 snprintf(str, sizeof(str), " %s CanPort=%s Frame.Size=%d Frame.Data=0x%lx", m_dnginfo.baseMessage.c_str(), m_dnginfo.baseInfo.sourceCANPortStr.c_str(), m_dnginfo.param16, m_dnginfo.param64 );
1122 m_dnginfo.baseInfo.finalMessage.append(str);
1123 }break;
1124
1125 case eoerror_value_SYS_transceiver_rxseqnumber_error:
1126 {
1127 int16_t receivedNum = m_dnginfo.param64+ m_dnginfo.param16;
1128 snprintf(str, sizeof(str), " %s Expected number is %ld, received number is %d ", m_dnginfo.baseMessage.c_str(), m_dnginfo.param64, receivedNum);
1129 m_dnginfo.baseInfo.finalMessage.append(str);
1130 }break;
1131
1132 case eoerror_value_SYS_transceiver_rxseqnumber_restarted:
1133 {
1134 snprintf(str, sizeof(str), " %s Expected number is %ld", m_dnginfo.baseMessage.c_str(), m_dnginfo.param64);
1135 m_dnginfo.baseInfo.finalMessage.append(str);
1136 }break;
1137
1138 case eoerror_value_SYS_canservices_board_detected:
1139 {
1140 //in param64 the fw copies the struct eObrd_typeandversions_t defined in EoBoards.h in icub=firmware repo
1157 //TODO:
1158 //checking the fw it seems this error code is no longer used.
1159 //So I cannot retrieve the board type.
1160 //For now I leave the code. When I'm sure that it is old, I'll remove it
1161 int fw_build = (m_dnginfo.param64 & 0x00000000000000ff);
1162 int fw_major = (m_dnginfo.param64 & 0x000000000000ff00) >> 8;
1163 int fw_minor = (m_dnginfo.param64 & 0x0000000000ff0000) >> 16;
1164 int proto_major = (m_dnginfo.param64 & 0x00000000ff000000) >> 24;
1165 int proto_minor = (m_dnginfo.param64 & 0x000000ff00000000) >> 32;
1166
1167 //used in comm-v1 protocol
1168 // eObrd_typeandversions_t *brd_info_ptr = (eObrd_typeandversions_t *)&m_dnginfo.param64;
1169 // int fw_build = brd_info_ptr->firmwarebuildnumber;
1170 // int fw_major = brd_info_ptr->firmwareversion.major;
1171 // int fw_minor = brd_info_ptr->firmwareversion.minor;
1172 // int proto_major =brd_info_ptr->protocolversion.major;
1173 // int proto_minor =brd_info_ptr->protocolversion.minor;
1174
1175 // eObrd_type_t general_brd_type = eoboards_cantype2type((eObrd_cantype_t )brd_info_ptr->boardtype);
1176
1177 // std::string board_type_str = eoboards_type2string(general_brd_type);
1178
1179 snprintf(str, sizeof(str), " %s on CAN port=%s with address %d. Fw ver is %d.%d.%d. Proto ver is %d.%d",
1181 fw_build, fw_major, fw_minor, proto_major, proto_minor );
1182 m_dnginfo.baseInfo.finalMessage.append(str);
1183 }break;
1184
1185 case eoerror_value_SYS_canservices_board_wrongprotversion:
1186 {
1187 //in param64 the fw copies the struct eObrd_typeandversions_t defined in EoBoards.h in icub=firmware repo
1204 //as above
1205 int fw_build = (m_dnginfo.param64 & 0x00000000000000ff);
1206 int fw_major = (m_dnginfo.param64 & 0x000000000000ff00) >> 8;
1207 int fw_minor = (m_dnginfo.param64 & 0x0000000000ff0000) >> 16;
1208 int proto_major = (m_dnginfo.param64 & 0x00000000ff000000) >> 24;
1209 int proto_minor = (m_dnginfo.param64 & 0x000000ff00000000) >> 32;
1210 int req_proto_major = (m_dnginfo.param16 & 0xff00) >>8;
1211 int req_proto_minor = (m_dnginfo.param16 & 0x00ff);
1212
1213
1214 snprintf(str, sizeof(str), " %s on CAN port=%s with address %d. Fw ver is %d.%d.%d. Proto ver is %d.%d. Required Version is %d.%d",
1216 fw_build, fw_major, fw_minor, proto_major, proto_minor, req_proto_major, req_proto_minor );
1217 m_dnginfo.baseInfo.finalMessage.append(str);
1218 }break;
1219
1220 case eoerror_value_SYS_canservices_board_notfound:
1221 {
1222 eObrd_type_t general_brd_type = eoboards_cantype2type((eObrd_cantype_t)m_dnginfo.param16);
1223 snprintf(str, sizeof(str), " %s The board is on CAN port=%s with address %d. Board type is %s.",
1225 m_dnginfo.baseInfo.sourceCANBoardAddr, eoboards_type2string(general_brd_type));
1226 m_dnginfo.baseInfo.finalMessage.append(str);
1227
1228 }break;
1229
1230 case eoerror_value_SYS_canservices_boards_lostcontact:
1231 {
1232 eOmn_serv_category_t serv_category;
1233 diagstr lostCanBoards1 = {0};
1234 diagstr lostCanBoards2 = {0};
1235 getCanMonitorInfo(serv_category, lostCanBoards1, lostCanBoards2);
1236
1237 snprintf(str, sizeof(str), "%s Type of service category is %s. Lost can boards on (can1map, can2map) = ([ %s ], [ %s ] ).",
1238 m_dnginfo.baseMessage.c_str(),
1239 eomn_servicecategory2string(serv_category),
1240 lostCanBoards1, lostCanBoards2
1241 );
1242
1243 m_dnginfo.baseInfo.finalMessage.append(str);
1244
1245 } break;
1246
1247 case eoerror_value_SYS_canservices_boards_retrievedcontact:
1248 {
1249 eOmn_serv_category_t serv_category;
1250 diagstr retrievedCanBoards1 = {0};
1251 diagstr retrievedCanBoards2 = {0};
1252 getCanMonitorInfo(serv_category, retrievedCanBoards1, retrievedCanBoards2);
1253
1254 snprintf(str, sizeof(str), "%s Type of service category is %s. Retrieved can boards on (can1map, can2map) = ([ %s ], [ %s ] ).",
1255 m_dnginfo.baseMessage.c_str(),
1256 eomn_servicecategory2string(serv_category),
1257 retrievedCanBoards1, retrievedCanBoards2
1258 );
1259
1260 m_dnginfo.baseInfo.finalMessage.append(str);
1261
1262 } break;
1263
1264 case eoerror_value_SYS_canservices_monitor_regularcontact:
1265 {
1266 eOmn_serv_category_t serv_category;
1267 diagstr foundCanBoards1 = {0};
1268 diagstr foundCanBoards2 = {0};
1269 getCanMonitorInfo(serv_category, foundCanBoards1, foundCanBoards2);
1270
1271 snprintf(str, sizeof(str), "%s Type of service category is %s. CAN boards are on (can1map, can2map) = ([ %s ], [ %s ])",
1272 m_dnginfo.baseMessage.c_str(),
1273 eomn_servicecategory2string(serv_category),
1274 foundCanBoards1,
1275 foundCanBoards2
1276 );
1277 m_dnginfo.baseInfo.finalMessage.append(str);
1278 } break;
1279
1280 case eoerror_value_SYS_canservices_monitor_lostcontact:
1281 {
1282 eOmn_serv_category_t serv_category;
1283 diagstr lostCanBoards1 = {0};
1284 diagstr lostCanBoards2 = {0};
1285 getCanMonitorInfo(serv_category, lostCanBoards1, lostCanBoards2);
1286
1287 snprintf(str, sizeof(str), "%s Type of service category is %s. Lost CAN boards are on (can1map, can2map) = ([ %s ], [ %s ]).",
1288 m_dnginfo.baseMessage.c_str(),
1289 eomn_servicecategory2string(serv_category),
1290 lostCanBoards1,
1291 lostCanBoards2
1292 );
1293 m_dnginfo.baseInfo.finalMessage.append(str);
1294 } break;
1295
1296 case eoerror_value_SYS_canservices_monitor_retrievedcontact:
1297 {
1298 eOmn_serv_category_t serv_category;
1299 uint32_t totRetrvTime;
1300 diagstr retrievedCanBoards1 = {0};
1301 diagstr retrievedCanBoards2 = {0};
1302 getCanMonitorInfoWithTime(serv_category, retrievedCanBoards1, retrievedCanBoards2, totRetrvTime);
1303
1304
1305 snprintf(str, sizeof(str), "%s Type of service category is %s. CAN boards are on (can1map, can2map) = ([ %s ], [ %s ]). Total retrieving time: %d [ms]",
1306 m_dnginfo.baseMessage.c_str(),
1307 eomn_servicecategory2string(serv_category),
1308 retrievedCanBoards1,
1309 retrievedCanBoards2,
1310 totRetrvTime
1311 );
1312 m_dnginfo.baseInfo.finalMessage.append(str);
1313 } break;
1314
1315
1316 case eoerror_value_SYS_canservices_monitor_stillnocontact:
1317 {
1318 eOmn_serv_category_t serv_category;
1319 uint32_t totDisappTime;
1320 diagstr lostCanBoards1 = {0};
1321 diagstr lostCanBoards2 = {0};
1322 getCanMonitorInfoWithTime(serv_category, lostCanBoards1, lostCanBoards2, totDisappTime);
1323
1324 snprintf(str, sizeof(str), "%s Type of service category is %s. Lost CAN boards are on (can1map, can2map) = ([ %s ] , [ %s ]). Total disappearance time: %d [ms]",
1325 m_dnginfo.baseMessage.c_str(),
1326 eomn_servicecategory2string(serv_category),
1327 lostCanBoards1,
1328 lostCanBoards2,
1329 totDisappTime
1330 );
1331 m_dnginfo.baseInfo.finalMessage.append(str);
1332 } break;
1333
1334
1335 case eoerror_value_SYS_unspecified:
1336 case eoerror_value_SYS_tobedecided:
1337 case eoerror_value_SYS_memory_zerorequested:
1338 case eoerror_value_SYS_memory_notinitialised:
1339 case eoerror_value_SYS_memory_missing:
1340 case eoerror_value_SYS_mutex_timeout:
1341 case eoerror_value_SYS_wrongparam:
1342 case eoerror_value_SYS_wrongusage:
1343 case eoerror_value_SYS_runtimeerror:
1344 case eoerror_value_SYS_runninginfatalerrorstate:
1345 case eoerror_value_SYS_udptxfailure:
1346 case eoerror_value_SYS_configurator_udptxfailure:
1347 case eoerror_value_SYS_runner_udptxfailure:
1348 case eoerror_value_SYS_runner_transceivererror:
1349 case eoerror_value_SYS_canservices_rxfifooverflow:
1350 case eoerror_value_SYS_proxy_forward_ok:
1351 case eoerror_value_SYS_proxy_forward_callback_fails:
1352 case eoerror_value_SYS_proxy_reply_ok:
1353 case eoerror_value_SYS_proxy_reply_fails:
1354 case eoerror_value_SYS_canservices_boards_missing:
1355 case eoerror_value_SYS_canservices_boards_searched:
1356 case eoerror_value_SYS_canservices_boards_found:
1357 case eoerror_value_SYS_transceiver_rxinvalidframe_error:
1358 {
1359 printBaseInfo();
1360 } break;
1361
1362
1363 case EOERROR_VALUE_DUMMY:
1364 {
1365 m_dnginfo.baseInfo.finalMessage.append(": unrecognised eoerror_category_HardWare error value.");
1366
1367
1368 } break;
1369
1370 default:
1371 {
1373
1374 }
1375
1376 }//end switch
1377
1378
1379
1380}
1381
1382
1383
1384
1385
1386
1387/**************************************************************************************************************************/
1388/****************************************** EthMonitorParser *****************************************/
1389/**************************************************************************************************************************/
1390
1391
1392
1393EthMonitorParser::EthMonitorParser(AuxEmbeddedInfo &dnginfo, EntityNameProvider &entityNameProvider):DefaultParser(dnginfo, entityNameProvider){;}
1394
1396{
1397 char str[512] = {0};
1398 eOerror_value_t value = eoerror_code2value(m_dnginfo.errorCode);
1400
1401 switch(value)
1402 {
1403
1404 case eoerror_value_ETHMON_link_goes_up:
1405 case eoerror_value_ETHMON_link_goes_down:
1406 case eoerror_value_ETHMON_error_rxcrc:
1407 {
1408 std::string appstate = "unknown";
1409 switch(m_dnginfo.param64&0xff00000000000000)
1410 {
1411 case 0: appstate="N/A"; break;
1412 case 1: appstate="idle"; break;
1413 case 3: appstate="running"; break;
1414 };
1415
1416 std::string ethport = "unknown";
1417 switch(m_dnginfo.param16)
1418 {
1419 case 0: ethport="ETH input (P2/P13/J4)"; break;
1420 case 1: ethport="ETH output (P3/P12/J5)"; break;
1421 case 2: ethport="internal"; break;
1422 };
1423 if(eoerror_value_ETHMON_error_rxcrc == value)
1424 snprintf(str, sizeof(str), " %s in port %s. Application state is %s. Number of erros is %ld",
1425 m_dnginfo.baseMessage.c_str(), ethport.c_str(), appstate.c_str(), (m_dnginfo.param64&0xffffffff));
1426 else
1427 snprintf(str, sizeof(str), " %s in port %s. Application state is %s.", m_dnginfo.baseMessage.c_str(), ethport.c_str(), appstate.c_str());
1428
1429 m_dnginfo.baseInfo.finalMessage.append(str);
1430 }break;
1431
1432 case eoerror_value_ETHMON_txseqnumbermissing:
1433 {
1434 snprintf(str, sizeof(str), " %s w/ expected sequence %ld and number of detected %d", m_dnginfo.baseMessage.c_str(), m_dnginfo.param64, m_dnginfo.param16);
1435 m_dnginfo.baseInfo.finalMessage.append(str);
1436 }break;
1437
1438
1439 case eoerror_value_ETHMON_juststarted:
1440 case eoerror_value_ETHMON_justverified:
1441 {
1442 printBaseInfo();
1443 } break;
1444
1445
1446 case EOERROR_VALUE_DUMMY:
1447 {
1448 m_dnginfo.baseInfo.finalMessage.append(": unrecognised eoerror_category_HardWare error value.");
1449
1450
1451 } break;
1452
1453 default:
1454 {
1456
1457 }
1458
1459 }//end switch
1460}
1461
1462
1463/**************************************************************************************************************************/
1464/****************************************** InertialSensorParser ********************************************/
1465/**************************************************************************************************************************/
1466
1467InertialSensorParser::InertialSensorParser(AuxEmbeddedInfo &dnginfo, EntityNameProvider &entityNameProvider):DefaultParser(dnginfo, entityNameProvider){;}
1468
1470{
1471 char str[512] = {0};
1472 eOerror_value_t value = eoerror_code2value(m_dnginfo.errorCode);
1474
1475 switch(value)
1476 {
1477
1478 case eoerror_value_IS_arrayofinertialdataoverflow:
1479 {
1480
1481 uint8_t frame_id = m_dnginfo.param16 & 0x0fff;
1482 uint8_t frame_size = (m_dnginfo.param16 & 0xf000) >> 12;
1483 uint64_t frame_data = m_dnginfo.param64;
1484
1485 snprintf(str, sizeof(str), " %s. Frame.ID=%d, Frame.Size=%d Frame.Data=0x%lx",
1486 m_dnginfo.baseMessage.c_str(), frame_id, frame_size, frame_data
1487 );
1488 m_dnginfo.baseInfo.finalMessage.append(str);
1489 } break;
1490
1491 case eoerror_value_IS_unknownsensor:
1492 {
1493 printBaseInfo();
1494 } break;
1495
1496
1497 case EOERROR_VALUE_DUMMY:
1498 {
1499 m_dnginfo.baseInfo.finalMessage.append(": unrecognised eoerror_category_HardWare error value.");
1500
1501
1502 } break;
1503
1504 default:
1505 {
1507
1508 }
1509
1510 }//end switch
1511}
1512
1513/**************************************************************************************************************************/
1514/****************************************** AnalogSensorParser **********************************************/
1515/**************************************************************************************************************************/
1516
1517AnalogSensorParser::AnalogSensorParser(AuxEmbeddedInfo &dnginfo, EntityNameProvider &entityNameProvider):DefaultParser(dnginfo, entityNameProvider){;}
1519{
1520 char str[512] = {0};
1521 eOerror_value_t value = eoerror_code2value(m_dnginfo.errorCode);
1523
1524 switch(value)
1525 {
1526
1527 case eoerror_value_AS_arrayoftemperaturedataoverflow:
1528 {
1529
1530 uint8_t frame_id = m_dnginfo.param16 & 0x00ff;
1531 uint8_t frame_size = (m_dnginfo.param16 & 0xf000) >> 12;
1532 uint64_t frame_data = m_dnginfo.param64;
1533
1534 snprintf(str, sizeof(str), " %s. Frame.ID=%d, Frame.Size=%d Frame.Data=0x%lx",
1535 m_dnginfo.baseMessage.c_str(), frame_id, frame_size, frame_data
1536 );
1537 m_dnginfo.baseInfo.finalMessage.append(str);
1538 } break;
1539
1540 case eoerror_value_AS_unknownsensor:
1541 {
1542 printBaseInfo();
1543 } break;
1544
1545
1546 case EOERROR_VALUE_DUMMY:
1547 {
1548 m_dnginfo.baseInfo.finalMessage.append(": unrecognised eoerror_category_HardWare error value.");
1549
1550
1551 } break;
1552
1553 default:
1554 {
1556
1557 }
1558
1559 }//end switch
1560}
1561
Diagnostic::LowLevel::EntityNameProvider & m_entityNameProvider
Diagnostic::LowLevel::AuxEmbeddedInfo & m_dnginfo
bool getEncoderTypeName(uint32_t jomoId, eOmc_position_t pos, std::string &encoderTypeName)
bool getAxisName(uint32_t entityId, std::string &axisName)
int n
char diagstr[diagstr_lenght]
constexpr int diagstr_lenght
degrees time
Definition sine.m:5