Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions log_and_stream_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,85 @@ void LogAndStream_processDaughterCardId(void)
/* Initialise any GPIOs that depend on the hardware revision. */
platform_initGpioForRevision();
}

#if defined(SHIMMER3R)
void LogAndStream_generateUsbDiskDriveId(char *usbDeviceIdStr)
{
char *macIdStrPtr = ShimBt_macIdStrPtrGet();
char sdCardSize[10];
printSdCardSize(sdCardSize);

/* Validate macIdStrPtr and its length */
char c8 = 'X', c9 = 'X', c10 = 'X', c11 = 'X';
if (macIdStrPtr != NULL)
{
size_t macLen = strlen(macIdStrPtr);
if (macLen >= 12)
{
c8 = macIdStrPtr[8];
c9 = macIdStrPtr[9];
c10 = macIdStrPtr[10];
c11 = macIdStrPtr[11];
}
}
/* Use snprintf to avoid buffer overflow */
snprintf(usbDeviceIdStr, USB_DEVICE_ID_STR_LEN, "Shimmer %c%c%c%c SD %s", c8,
c9, c10, c11, sdCardSize);
}

void LogAndStream_generateUsbMscId(char *usbDeviceIdStr)
{
char *macIdStrPtr = ShimBt_macIdStrPtrGet();
char c8 = 'X', c9 = 'X', c10 = 'X', c11 = 'X';
if (macIdStrPtr != NULL)
{
size_t macLen = strlen(macIdStrPtr);
if (macLen >= 12)
{
c8 = macIdStrPtr[8];
c9 = macIdStrPtr[9];
c10 = macIdStrPtr[10];
c11 = macIdStrPtr[11];
}
}
snprintf(usbDeviceIdStr, USB_DEVICE_ID_STR_LEN, "Shimmer %c%c%c%c MSC", c8, c9, c10, c11);
}

void LogAndStream_generateUsbCdcId(char *usbDeviceIdStr)
{
char *macIdStrPtr = ShimBt_macIdStrPtrGet();
char c8 = 'X', c9 = 'X', c10 = 'X', c11 = 'X';
if (macIdStrPtr != NULL)
{
size_t macLen = strlen(macIdStrPtr);
if (macLen >= 12)
{
c8 = macIdStrPtr[8];
c9 = macIdStrPtr[9];
c10 = macIdStrPtr[10];
c11 = macIdStrPtr[11];
}
}
snprintf(usbDeviceIdStr, USB_DEVICE_ID_STR_LEN, "Shimmer %c%c%c%c CDC ACM",
c8, c9, c10, c11);
}

void LogAndStream_generateUsbCompositeDeviceId(char *usbDeviceIdStr)
{
char *macIdStrPtr = ShimBt_macIdStrPtrGet();
char c8 = 'X', c9 = 'X', c10 = 'X', c11 = 'X';
if (macIdStrPtr != NULL)
{
size_t macLen = strlen(macIdStrPtr);
if (macLen >= 12)
{
c8 = macIdStrPtr[8];
c9 = macIdStrPtr[9];
c10 = macIdStrPtr[10];
c11 = macIdStrPtr[11];
}
}
snprintf(usbDeviceIdStr, USB_DEVICE_ID_STR_LEN,
"Shimmer %c%c%c%c Composite Device", c8, c9, c10, c11);
}
#endif
6 changes: 6 additions & 0 deletions log_and_stream_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,11 @@ void LogAndStream_setupDock(void);
void LogAndStream_setupUndock(void);
uint8_t LogAndStream_checkSdInSlot(void);
void LogAndStream_processDaughterCardId(void);
#if defined(SHIMMER3R)
void LogAndStream_generateUsbDiskDriveId(char *usbDeviceIdStr);
void LogAndStream_generateUsbMscId(char *usbDeviceIdStr);
void LogAndStream_generateUsbCdcId(char *usbDeviceIdStr);
void LogAndStream_generateUsbCompositeDeviceId(char *usbDeviceIdStr);
#endif /* defined(SHIMMER3R) */

#endif /* LOG_AND_STREAM_COMMON_LOG_AND_STREAM_COMMON_H_ */
4 changes: 4 additions & 0 deletions log_and_stream_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@

#define TIMEOUT_100_MS (3277)

#if defined(SHIMMER3R)
#define USB_DEVICE_ID_STR_LEN 32
#endif

#if defined(SHIMMER3)
#define __NOP() __no_operation()
#endif
Expand Down