Skip to content

Commit

Permalink
feat(hepa-uv): add error code for door & reed state change during uv …
Browse files Browse the repository at this point in the history
…task (#758)

* send warning when door/reed state change
* make unrecoverable until further notice
  • Loading branch information
ahiuchingau authored Mar 19, 2024
1 parent 750940a commit 1413581
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions include/bootloader/core/ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ typedef enum {
can_errorcode_motor_busy = 0xb,
can_errorcode_stop_requested = 0xc,
can_errorcode_over_pressure = 0xd,
can_errorcode_door_open = 0xe,
can_errorcode_reed_open = 0xf,
} CANErrorCode;

/** Tool types detected on Head. */
Expand Down
2 changes: 2 additions & 0 deletions include/can/core/ids.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ enum class ErrorCode {
motor_busy = 0xb,
stop_requested = 0xc,
over_pressure = 0xd,
door_open = 0xe,
reed_open = 0xf,
};

/** Error Severity levels. */
Expand Down
17 changes: 14 additions & 3 deletions include/hepa-uv/core/uv_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,23 @@ class UVMessageHandler {
// reset push button state if the door is opened or the reed switch is
// not set
if (!door_closed || !reed_switch_set) {
gpio::reset(drive_pins.uv_on_off);
// Set the push button LED's to user intervention (blue)
if (_timer.is_running()) {
gpio::reset(drive_pins.uv_on_off);
_timer.stop();
// send error message when door/reed state change while uv
// is on
auto resp = can::messages::ErrorMessage{
.message_index = 0,
.severity = can::ids::ErrorSeverity::unrecoverable,
.error_code = !door_closed ? can::ids::ErrorCode::door_open
: can::ids::ErrorCode::reed_open,
};
can_client.send_can_message(can::ids::NodeId::host, resp);
}
led_control_client.send_led_control_message(
// Set the push button LED's to user intervention (blue)
led_control_task_messages::PushButtonLED(UV_BUTTON, 0, 0, 50,
0));
if (_timer.is_running()) _timer.stop();
uv_push_button = false;
uv_light_on = false;
return;
Expand Down
3 changes: 2 additions & 1 deletion include/motor-control/core/tasks/messages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ using MotionControlTaskMessage = std::variant<
can::messages::MotorPositionRequest, can::messages::ReadLimitSwitchRequest,
can::messages::HomeRequest,
can::messages::UpdateMotorPositionEstimationRequest,
can::messages::GetMotorUsageRequest, can::messages::AddSensorMoveRequest>;
can::messages::GetMotorUsageRequest, can::messages::MotorStatusRequest,
can::messages::AddSensorMoveRequest>;

using MoveGroupTaskMessage =
std::variant<std::monostate, can::messages::AddLinearMoveRequest,
Expand Down

0 comments on commit 1413581

Please sign in to comment.