Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print cdb and data in Trace mode #1448

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion cpp/controllers/scsi_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ void ScsiController::Send()

if (HasValidLength()) {
LogTrace("Sending data, offset: " + to_string(GetOffset()) + ", length: " + to_string(GetLength()));
uint8_t *data = GetBuffer().data() + GetOffset();

// The delay should be taken from the respective LUN, but as there are no Daynaport drivers for
// LUNs other than 0 this work-around works.
Expand All @@ -444,6 +445,16 @@ void ScsiController::Send()
Error(sense_key::aborted_command);
return;
}
else {
if ((GetLength() > 0) && (GetLength() < 512) && (spdlog::get_level() == spdlog::level::trace)) {
stringstream s;
s << "Sent data $" << setfill('0') << hex;
for (uint32_t i = 0; i < GetLength(); i++) {
s << setw(2) << (int)(*data++);
}
LogTrace(s.str());
}
}

UpdateOffsetAndLength();

Expand Down Expand Up @@ -510,14 +521,24 @@ void ScsiController::Receive()

if (HasValidLength()) {
LogTrace("Receiving data, transfer length: " + to_string(GetLength()) + " byte(s)");

uint8_t *data = GetBuffer().data() + GetOffset();
// If not able to receive all, move to status phase
if (uint32_t len = GetBus().ReceiveHandShake(GetBuffer().data() + GetOffset(), GetLength()); len != GetLength()) {
LogError("Not able to receive " + to_string(GetLength()) + " byte(s) of data, only received "
+ to_string(len));
Error(sense_key::aborted_command);
return;
}
else {
if ((GetLength() > 0) && (GetLength() < 512) && (spdlog::get_level() == spdlog::level::trace)) {
stringstream s;
s << "Received data $" << setfill('0') << hex;
for (uint32_t i = 0; i < GetLength(); i++) {
s << setw(2) << (int)(*data++);
}
LogTrace(s.str());
}
}
}

if (IsByteTransfer()) {
Expand Down
Loading