in src/main/c/Posix/PosixHelperFunctions.c [499:549]
static void getUsbDetails(const char* fileName, char* basePathEnd, int* vendorID, int* productID, char* serialNumber, char* manufacturer, char* driverName)
{
// Attempt to read the Vendor ID
char *temp = (char*)malloc(8);
sprintf(basePathEnd, "../idVendor");
FILE *input = fopen(fileName, "rb");
if (input)
{
fgets(temp, 8, input);
*vendorID = (int)strtol(temp, NULL, 16);
fclose(input);
}
// Attempt to read the Product ID
sprintf(basePathEnd, "../idProduct");
input = fopen(fileName, "rb");
if (input)
{
fgets(temp, 8, input);
*productID = (int)strtol(temp, NULL, 16);
fclose(input);
}
free(temp);
// Attempt to read the Serial Number
strcpy(serialNumber, "Unknown");
sprintf(basePathEnd, "../serial");
input = fopen(fileName, "rb");
if (input)
{
fgets(serialNumber, 128, input);
serialNumber[strcspn(serialNumber, "\r\n")] = 0;
fclose(input);
}
// Attempt to read the Manufacturer
strcpy(manufacturer, "Unknown");
sprintf(basePathEnd, "../manufacturer");
input = fopen(fileName, "rb");
if (input)
{
fgets(manufacturer, 128, input);
manufacturer[strcspn(manufacturer, "\r\n")] = 0;
fclose(input);
}
// Attempt to read the Device Driver
strcpy(driverName, "Unknown");
sprintf(basePathEnd, "driver/module/drivers");
getDriverName(fileName, driverName);
}