Skip to content

Commit

Permalink
Reset bus after phase error
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Dec 11, 2024
1 parent 084491b commit 5f6618f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cpp/controllers/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ void Controller::Command()
Error(sense_key::illegal_request, asc::invalid_command_operation_code);
}
else {
GetBus().SetRST(true);
Error(sense_key::aborted_command, asc::command_phase_error);
}
return;
Expand All @@ -130,6 +131,7 @@ void Controller::Command()
if (actual_count != command_bytes_count) {
LogWarn(fmt::format("Received {0} byte(s) in COMMAND phase for command ${1:02x}, {2} required",
command_bytes_count, GetCdb()[0], actual_count));
GetBus().SetRST(true);
Error(sense_key::aborted_command, asc::command_phase_error);
return;
}
Expand Down Expand Up @@ -337,6 +339,7 @@ void Controller::Send()
if (const int l = GetBus().SendHandShake(GetBuffer().data() + GetOffset(), length,
GetDeviceForLun(0)->GetDelayAfterBytes()); l != length) {
LogWarn(fmt::format("Sent {0} byte(s), {1} required", l, length));
GetBus().SetRST(true);
Error(sense_key::aborted_command, asc::data_phase_error);
return;
}
Expand Down Expand Up @@ -398,6 +401,7 @@ void Controller::Receive()

if (const int l = GetBus().ReceiveHandShake(GetBuffer().data() + GetOffset(), length); l != length) {
LogWarn(fmt::format("Received {0} byte(s), {1} required", l, length));
GetBus().SetRST(true);
Error(sense_key::aborted_command, asc::data_phase_error);
return;
}
Expand Down

0 comments on commit 5f6618f

Please sign in to comment.