Oops - SCSI INQUIRY data uses fixed-length, non-terminated strings -- need to copy...
authorDean Camera <dean@fourwalledcubicle.com>
Tue, 23 Jun 2009 09:38:22 +0000 (09:38 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Tue, 23 Jun 2009 09:38:22 +0000 (09:38 +0000)
Demos/Host/LowLevel/MassStorageHost/MassStorageHost.c
Demos/Host/LowLevel/MassStorageHost/MassStorageHost.h

index 79a5592..a1febf2 100644 (file)
@@ -224,8 +224,17 @@ void MassStorage_Task(void)
                                break;\r
                        }\r
                        \r
+                       /* VendorID and ProductID are fixed-length non-null terminated strings - need to terminate them before displaying */\r
+                       char VendorID[9];\r
+                       char ProductID[17];\r
+                       \r
+                       memcpy(&VendorID, &InquiryData.VendorID, 8);\r
+                       memcpy(&ProductID, &InquiryData.ProductID, 16);\r
+                       VendorID[8]   = 0x00;\r
+                       ProductID[16] = 0x00;\r
+\r
                        /* Print vendor and product names of attached device */\r
-                       printf_P(PSTR("Vendor: %s, Product: %s\r\n"), InquiryData.VendorID, InquiryData.ProductID);\r
+                       printf_P(PSTR("Vendor \"%s\", Product \"%s\"\r\n"), VendorID, ProductID);\r
                                                \r
                        /* Wait until disk ready */\r
                        puts_P(PSTR("Waiting until ready.."));\r
index a299b70..a5b84c2 100644 (file)
@@ -43,6 +43,7 @@
                #include <avr/power.h>\r
                #include <stdio.h>\r
                #include <ctype.h>\r
+               #include <string.h>\r
 \r
                #include "ConfigDescriptor.h"\r
 \r