From 6ec75300c4d6a20c5cd3419166fdd75f54898168 Mon Sep 17 00:00:00 2001 From: Troy Date: Sun, 6 Nov 2022 12:20:30 -0500 Subject: [PATCH] added a full lookup table for cdb length this fixes the issue of 16 byte cdb commands from causing problems by not being detected correctly --- src/BlueSCSI.cpp | 3 +-- src/BlueSCSI.h | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/BlueSCSI.cpp b/src/BlueSCSI.cpp index 16c064c..795289a 100644 --- a/src/BlueSCSI.cpp +++ b/src/BlueSCSI.cpp @@ -1182,8 +1182,7 @@ void loop() LOGHEX(cmd[0]); // Command length selection, reception - static const int cmd_class_len[8]={6,10,10,6,6,12,6,6}; - len = cmd_class_len[cmd[0] >> 5]; + len = cdb_len_lookup[cmd[0]]; cmd[1] = readHandshake(); LOG(":");LOGHEX(cmd[1]); cmd[2] = readHandshake(); LOG(":");LOGHEX(cmd[2]); cmd[3] = readHandshake(); LOG(":");LOGHEX(cmd[3]); diff --git a/src/BlueSCSI.h b/src/BlueSCSI.h index 3e6c7bb..1d6eaff 100644 --- a/src/BlueSCSI.h +++ b/src/BlueSCSI.h @@ -325,5 +325,19 @@ typedef __attribute__((aligned(4))) struct _SCSI_DEVICE uint8_t m_sector_offset; // optical sector offset for missing sync header } SCSI_DEVICE; +static byte cdb_len_lookup[] = { + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10,10,10,10,16,16,16,16,16,16,16,16, + 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, + 16,16,16,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, + 12,12,12,12,12,12,12,12,12,12,12,12,12,12,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10,10,10,10,10 +}; -#endif \ No newline at end of file +#endif