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

Add icub_firmware_shared::embot lib to embObjLib thus to use embot::core::binary::bit::check
Update include array
  • Loading branch information
MSECode committed Mar 14, 2024
1 parent 6376390 commit cbd7976
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/libraries/icubmod/embObjLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ install(TARGETS ${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME} YARP::YARP_os
YARP::YARP_dev
icub_firmware_shared::embobj
icub_firmware_shared::embot
ACE::ACE)

icub_export_library(${PROJECT_NAME})
Expand Down
77 changes: 71 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,69 @@ void ConfigParser::parseInfo()
/****************************************** MotionControlParser ***************************************************/
/**************************************************************************************************************************/

// private class functions
std::string MotionControlParser::motorStatusBitsToString(eOmc_motorFaultState_t motorstatus)
{
// dimesion of the array is hard-code but it must be aligned w/ the union typedef eOmc_motorFaultState_t
static const std::array<std::string_view, eOmc_motorFaultState_numberof> 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 < eOmc_motorFaultState_numberof; i++) // important to loop over the eOmc_motorFaultState_numberof (dimension of the union typedef eOmc_motorFaultState_t)
{
// 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 +659,13 @@ void MotionControlParser::parseInfo()

case eoerror_value_MC_generic_error: //TBD Check print
{
eOmc_motorFaultState_t 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 +1214,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 +1458,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,7 +11,9 @@
#define __diagnosticLowLevelFormatter_hid_h__

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

void parseInfo();


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

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

0 comments on commit cbd7976

Please sign in to comment.