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