diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-06-23 09:38:22 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-06-23 09:38:22 +0000 |
commit | b2cf4d32221075c96a7487b1fc0baa2598d373fe (patch) | |
tree | 593932d38a3b0edd51d95530ff4afeec5ba6588e | |
parent | 64937a62062368504cc9982d15a7d332566d8fac (diff) | |
download | lufa-b2cf4d32221075c96a7487b1fc0baa2598d373fe.tar.gz lufa-b2cf4d32221075c96a7487b1fc0baa2598d373fe.tar.bz2 lufa-b2cf4d32221075c96a7487b1fc0baa2598d373fe.zip |
Oops - SCSI INQUIRY data uses fixed-length, non-terminated strings -- need to copy the strings to a temp buffer and terminate before using them in printf.
-rw-r--r-- | Demos/Host/LowLevel/MassStorageHost/MassStorageHost.c | 11 | ||||
-rw-r--r-- | Demos/Host/LowLevel/MassStorageHost/MassStorageHost.h | 1 |
2 files changed, 11 insertions, 1 deletions
diff --git a/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.c b/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.c index 79a559234..a1febf204 100644 --- a/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.c +++ b/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.c @@ -224,8 +224,17 @@ void MassStorage_Task(void) break;
}
+ /* VendorID and ProductID are fixed-length non-null terminated strings - need to terminate them before displaying */
+ char VendorID[9];
+ char ProductID[17];
+
+ memcpy(&VendorID, &InquiryData.VendorID, 8);
+ memcpy(&ProductID, &InquiryData.ProductID, 16);
+ VendorID[8] = 0x00;
+ ProductID[16] = 0x00;
+
/* Print vendor and product names of attached device */
- printf_P(PSTR("Vendor: %s, Product: %s\r\n"), InquiryData.VendorID, InquiryData.ProductID);
+ printf_P(PSTR("Vendor \"%s\", Product \"%s\"\r\n"), VendorID, ProductID);
/* Wait until disk ready */
puts_P(PSTR("Waiting until ready.."));
diff --git a/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.h b/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.h index a299b7008..a5b84c2eb 100644 --- a/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.h +++ b/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.h @@ -43,6 +43,7 @@ #include <avr/power.h>
#include <stdio.h>
#include <ctype.h>
+ #include <string.h>
#include "ConfigDescriptor.h"
|