From 99429e1042a0fd9fb11a2f348eb36249161134ac Mon Sep 17 00:00:00 2001 From: Mikael Olsson Date: Wed, 16 Aug 2023 15:22:19 +0200 Subject: Add command and error to IOCTL failure exception When an IOCTL call fails in the driver library, the failure exception only states "IOCTL failed" without any further information. To make it easier to see what IOCTL call failed and why, the exception will now include the command that failed and the reason for the failure. Change-Id: Ife4957d2c0d692b3fcdbdc72538690d50385d365 Signed-off-by: Mikael Olsson --- driver_library/src/ethosu.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/driver_library/src/ethosu.cpp b/driver_library/src/ethosu.cpp index 64aee4d..dcdde8c 100644 --- a/driver_library/src/ethosu.cpp +++ b/driver_library/src/ethosu.cpp @@ -20,7 +20,9 @@ #include #include +#include #include +#include #include #include #include @@ -104,7 +106,7 @@ const SemanticVersion getLibraryVersion() { __attribute__((weak)) int eioctl(int fd, unsigned long cmd, void *data = nullptr) { int ret = ::ioctl(fd, cmd, data); if (ret < 0) { - throw EthosU::Exception("IOCTL failed"); + throw EthosU::Exception(string("IOCTL cmd=").append(to_string(cmd) + " failed: " + strerror(errno)).c_str()); } Log(Severity::Debug) << "ioctl. fd=" << fd << ", cmd=" << setw(8) << setfill('0') << hex << cmd << ", ret=" << ret -- cgit v1.2.1