From 67b81bac8fd03ce1e325807c8f34d6e5bfc07029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= Date: Mon, 1 Apr 2024 14:43:57 +0200 Subject: [PATCH] Print CDB and data in Trace mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This enhances trace output for scsi_controller to print the CDB and the following data for send and receive. Signed-off-by: Klaus Kämpf --- cpp/controllers/scsi_controller.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/cpp/controllers/scsi_controller.cpp b/cpp/controllers/scsi_controller.cpp index 773b06dd..1f093f11 100644 --- a/cpp/controllers/scsi_controller.cpp +++ b/cpp/controllers/scsi_controller.cpp @@ -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. @@ -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(); @@ -510,7 +521,7 @@ 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 " @@ -518,6 +529,16 @@ void ScsiController::Receive() 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()) {