Skip to content

Commit

Permalink
Update generic error issue
Browse files Browse the repository at this point in the history
Update Generic error parsing adding common string map
  • Loading branch information
MSECode committed Mar 11, 2024
1 parent 6376390 commit 53bf07d
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 7 deletions.
76 changes: 70 additions & 6 deletions src/libraries/icubmod/embObjLib/diagnosticInfoParsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* BSD-3-Clause license. See the accompanying LICENSE file for details.
*/

#include <string>
#include "diagnosticLowLevelFormatter_hid.h"
#include "diagnosticLowLevelFormatter.h"
#include "EoBoards.h"
#include "embot_core_binary.h"


using namespace Diagnostic::LowLevel;
Expand Down Expand Up @@ -532,6 +532,68 @@ void ConfigParser::parseInfo()
/****************************************** MotionControlParser ***************************************************/
/**************************************************************************************************************************/

// private class functions
std::string MotionControlParser::motorStatusBitsToString(eOmc_motorFaultState motorstatus)
{
static const std::array<std::string_view, 32> s_motor_fault_status =
{
//B0 L
"ExternalFaultAsserted",
"UnderVoltageFailure",
"OverVoltageFailure",
"OverCurrentFailure",
//B0 H
"DHESInvalidValue",
"AS5045CSumError",
"DHESInvalidSequence",
"CANInvalidProtocol",
//B1 L
"CAN_BufferOverRun",
"SetpointExpired",
"CAN_TXIsPasv",
"CAN_RXIsPasv",
//B1 H
"CAN_IsWarnTX",
"CAN_IsWarnRX",
"OverHeatingFailure",
"",
//B2 L
"ADCCalFailure",
"I2TFailure",
"EMUROMFault",
"EMUROMCRCFault",
//B2 H
"EncoderFault",
"FirmwareSPITimingError",
"AS5045CalcError",
"FirmwarePWMFatalError",
//B3 L
"CAN_TXWasPasv",
"CAN_RXWasPasv",
"CAN_RTRFlagActive",
"CAN_WasWarn",
//B3 H
"CAN_DLCError",
"SiliconRevisionFault",
"PositionLimitUpper",
"PositionLimitLower"
};

std::string statusstring = {};
statusstring.reserve(256);

for (uint8_t i = 0; i < maxMotorStateFault; i++)
{
// check bit by bit and add to ss the faulted bits
if(embot::core::binary::bit::check(motorstatus.bitmask, i))
{
statusstring.append(static_cast<const char*>(s_motor_fault_status.at(i).data()));
statusstring.append(" ");
}
}
return statusstring;
}

MotionControlParser::MotionControlParser(AuxEmbeddedInfo &dnginfo, EntityNameProvider &entityNameProvider):DefaultParser(dnginfo, entityNameProvider){;}

void MotionControlParser::parseInfo()
Expand Down Expand Up @@ -596,11 +658,13 @@ void MotionControlParser::parseInfo()

case eoerror_value_MC_generic_error: //TBD Check print
{
eOmc_motorFaultState motor_status;
uint16_t joint_num = m_dnginfo.param16;
motor_status.bitmask = m_dnginfo.param64 & 0xffffffff;
m_entityNameProvider.getAxisName(joint_num, m_dnginfo.baseInfo.axisName);

snprintf(str, sizeof(str), " %s (Joint=%s (NIB=%d) (Error is %lx)",
m_dnginfo.baseMessage.c_str(), m_dnginfo.baseInfo.axisName.c_str(), joint_num, m_dnginfo.param64
std::string motorStatusString = motorStatusBitsToString(motor_status);
snprintf(str, sizeof(str), " %s (Joint=%s (NIB=%d) (Errors:%s)",
m_dnginfo.baseMessage.c_str(), m_dnginfo.baseInfo.axisName.c_str(), joint_num, motorStatusString.c_str()
);
m_dnginfo.baseInfo.finalMessage.append(str);
} break;
Expand Down Expand Up @@ -1149,7 +1213,7 @@ void SysParser::parseInfo()
diagstr lostCanBoards2 = {0};
getCanMonitorInfo(serv_category, lostCanBoards1, lostCanBoards2);

snprintf(str, sizeof(str), "%s Type of service category is %s. Lost can boards on (can1map, can2map) = ([ %s ], [ %s ] )",
snprintf(str, sizeof(str), "%s Type of service category is %s. Lost can boards on (can1map, can2map) = ([ %s ], [ %s ] ).",
m_dnginfo.baseMessage.c_str(),
eomn_servicecategory2string(serv_category),
lostCanBoards1, lostCanBoards2
Expand Down Expand Up @@ -1393,7 +1457,7 @@ void InertialSensorParser::parseInfo()
case eoerror_value_IS_arrayofinertialdataoverflow:
{

uint8_t frame_id = m_dnginfo.param16 & 0x00ff;
uint8_t frame_id = m_dnginfo.param16 & 0x0fff;
uint8_t frame_size = (m_dnginfo.param16 & 0xf000) >> 12;
uint64_t frame_data = m_dnginfo.param64;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define __diagnosticLowLevelFormatter_hid_h__

#include <string>
#include <string_view>
#include <memory>
#include <yarp/os/LogStream.h>
#include "diagnosticLowLevelFormatter.h"
Expand Down Expand Up @@ -116,7 +117,8 @@ class Diagnostic::LowLevel::MotionControlParser : public Diagnostic::LowLevel::D

void parseInfo();


private:
std::string motorStatusBitsToString(eOmc_motorFaultState motorstatus);
};

class Diagnostic::LowLevel::SkinParser : public Diagnostic::LowLevel::DefaultParser
Expand Down

0 comments on commit 53bf07d

Please sign in to comment.