mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Drivers: Ensure serial numbers are uppercase
This prevents mismatches if the device sends a lowercase serial number, which may happen due to an oversight in production.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <cctype>
|
||||
#include <algorithm>
|
||||
#include <libusb.h>
|
||||
|
||||
@@ -24,6 +25,8 @@ void FTDI::Find(std::vector<FoundDevice>& found) {
|
||||
FoundDevice d;
|
||||
strncpy(d.serial, serial.c_str(), deviceSerialBufferLength - 1);
|
||||
d.serial[deviceSerialBufferLength - 1] = '\0'; // strncpy does not write a null terminator if serial is too long
|
||||
for(size_t i = 0; i < deviceSerialBufferLength - 1; i++)
|
||||
d.serial[i] = toupper(serial[i]);
|
||||
std::string devHandle = serial;
|
||||
auto it = std::find(handles.begin(), handles.end(), devHandle);
|
||||
size_t foundHandle = SIZE_MAX;
|
||||
|
||||
Reference in New Issue
Block a user