Skip to content

Commit

Permalink
Update status to uint32_t containing BMS and BAT status
Browse files Browse the repository at this point in the history
  • Loading branch information
MSECode committed Aug 1, 2023
1 parent 9aaf09e commit 7d2b6f7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,7 @@ eOresult_t embot::app::eth::theBATservice::Impl::AcceptCANframe(
(static_cast<uint16_t>(cfd.frame->data[1]) << 8) +
static_cast<uint16_t>(cfd.frame->data[0])
);
}
break;
} break;

case canFrameDescriptor::Type::status_bms:
{
Expand All @@ -602,9 +601,10 @@ eOresult_t embot::app::eth::theBATservice::Impl::AcceptCANframe(
If we have an alram, this will persist in the minute after the alarm generation
even if the alarm re-enter
**/
bat->status.timedvalue.status = cfd.frame->data[0];
break;
}
// using embot methods copy the 8bits of bms_status into the two least significant bytes of the general timedvalue.status
embot::core::binary::mask::clear(bat->status.timedvalue.status, static_cast<uint32_t>(0x0000ffff), 0);
embot::core::binary::mask::set(bat->status.timedvalue.status, static_cast<uint32_t>(cfd.frame->data[0]), 0);
} break;

case canFrameDescriptor::Type::status_bat:
{
Expand All @@ -625,21 +625,26 @@ eOresult_t embot::app::eth::theBATservice::Impl::AcceptCANframe(
If we have an alram, this will persist in the minute after the alarm generation
even if the alarm re-enter
**/
bat->status.timedvalue.status = (cfd.frame->data[1] << 8 ) | cfd.frame->data[0];
break;
}
// using embot methods copy the 16bits of bms_status into the two most significant bytes of the general timedvalue.status
uint16_t bat_status_temp16 = {0x0120};
embot::core::binary::mask::clear(bat->status.timedvalue.status, static_cast<uint32_t>(0xffff0000), 0);
bat_status_temp16 = static_cast<uint16_t>((cfd.frame->data[1] << 8 ) | cfd.frame->data[0]);
embot::core::binary::mask::set(bat->status.timedvalue.status, static_cast<uint32_t>(bat_status_temp16), 16);
} break;

case canFrameDescriptor::Type::unspecified:
{
//unspecified type do nothing - for now return unsupported error -
//this case should never be set when this method is called
return eores_NOK_unsupported;
}
break;
} break;

default:
return eores_NOK_unsupported;
}
{
return eores_NOK_unsupported;
} break;

}

return eores_OK;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class theBATservice {
static constexpr eOas_battery_status_t defaultBATstatus{
.timedvalue = {.age = 0,
.temperature = 0,
.status = 0,
//.status = 0,
.voltage = 0,
.current = 0,
.charge = 0}};
Expand Down

0 comments on commit 7d2b6f7

Please sign in to comment.