Ability to read or modify serial number string

This commit is contained in:
lucianom
2020-05-19 12:43:56 +01:00
parent 468b69cb62
commit b7cbc5fe9e
5 changed files with 49 additions and 8 deletions

View File

@@ -1,6 +1,12 @@
lib_xua Change Log
==================
1.1.0
-----
* ADDED: Ability to read or modify serial number string
1.0.1
-----

View File

@@ -62,6 +62,16 @@ void XUA_Endpoint0_setProductStr(char * unsafe product_str);
void XUA_Endpoint0_setProductStr(char * product_str);
#endif
/** Function to set the Serial string
*
* \param serial_str Serial string to set
*/
#ifdef __XC__
void XUA_Endpoint0_setSerialStr(char * unsafe serial_str);
#else
void XUA_Endpoint0_setSerialStr(char * serial_str);
#endif
/** Function to set the BCD device
*
* \param bcdDevice BCD device to set
@@ -72,7 +82,7 @@ void XUA_Endpoint0_setBcdDevice(unsigned short bcdDevice);
/** Function to get the Vendor string
*
* \param vid vendor string
* \return vendor string
*/
#ifdef __XC__
char * unsafe XUA_Endpoint0_getVendorStr();
@@ -82,7 +92,7 @@ char * XUA_Endpoint0_getVendorStr(;
/** Function to get the Product string
*
* \param pid Product string
* \return Product string
*/
#ifdef __XC__
char * unsafe XUA_Endpoint0_getProductStr();
@@ -90,15 +100,25 @@ char * unsafe XUA_Endpoint0_getProductStr();
char * XUA_Endpoint0_getProductStr(;
#endif
/** Function to get the Vendor string
/** Function to get the Serial Number string
*
* \return Vendor string
* \return Serial string
*/
#ifdef __XC__
char * unsafe XUA_Endpoint0_getSerialStr();
#else
char * XUA_Endpoint0_getSerialStr(;
#endif
/** Function to get the Vendor ID
*
* \return Vendor ID
*/
unsigned short XUA_Endpoint0_getVendorId();
/** Function to get the Product string
/** Function to get the Product ID
*
* \return Product string
* \return Product ID
*/
unsigned short XUA_Endpoint0_getProductId();

View File

@@ -1,4 +1,4 @@
VERSION = 1.0.1
VERSION = 1.1.0
DEPENDENT_MODULES = lib_logging(>=3.0.0) \
lib_xassert(>=4.0.0) \

View File

@@ -118,6 +118,8 @@ char g_product_str[XUA_MAX_STR_LEN] = PRODUCT_STR_A2;
char g_product_str[XUA_MAX_STR_LEN] = PRODUCT_STR_A1;
#endif
char g_serial_str[XUA_MAX_STR_LEN] = "";
/* Subslot */
const unsigned g_subSlot_Out_HS[OUTPUT_FORMAT_COUNT] = {HS_STREAM_FORMAT_OUTPUT_1_SUBSLOT_BYTES,
#if(OUTPUT_FORMAT_COUNT > 1)
@@ -289,6 +291,9 @@ void XUA_Endpoint0_setStrTable() {
concatenateAndCopyStrings(g_product_str, "", g_strTable.usbInputTermStr_Audio2);
concatenateAndCopyStrings(g_product_str, "", g_strTable.usbOutputTermStr_Audio2);
#endif
// update Serial strings
concatenateAndCopyStrings(g_serial_str, "", g_strTable.serialStr);
}
void XUA_Endpoint0_setVendorStr(char* vendor_str) {
@@ -301,6 +306,11 @@ void XUA_Endpoint0_setProductStr(char* product_str) {
concatenateAndCopyStrings(product_str, "", g_product_str);
}
void XUA_Endpoint0_setSerialStr(char* serial_str) {
debug_printf("XUA_Endpoint0_setSerialStr() with string %s\n", serial_str);
concatenateAndCopyStrings(serial_str, "", g_serial_str);
}
char* XUA_Endpoint0_getVendorStr() {
return g_strTable.vendorStr;
}
@@ -313,6 +323,10 @@ char* XUA_Endpoint0_getProductStr() {
#endif
}
char* XUA_Endpoint0_getSerialStr() {
return g_strTable.serialStr;
}
void XUA_Endpoint0_setProductId(unsigned short pid) {
#if (AUDIO_CLASS == 1)
devDesc_Audio1.idProduct = pid;

View File

@@ -40,6 +40,7 @@
#define XUA_CTRL_EMPTY_STRING "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\08"
#define XUA_MIDI_OUT_EMPTY_STRING "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\09"
#define XUA_MIDI_IN_EMPTY_STRING "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0a"
#define XUA_SERIAL_EMPTY_STRING "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0b"
// The value below must match the length of XUA_DESCR_EMPTY_STRING.
#define XUA_MAX_STR_LEN (32)
@@ -334,7 +335,7 @@ StringDescTable_t g_strTable =
{
.langID = "\x09\x04", /* US English */
.vendorStr = XUA_VENDOR_EMPTY_STRING,
.serialStr = "",
.serialStr = XUA_SERIAL_EMPTY_STRING,
#if (AUDIO_CLASS == 2)
.productStr_Audio2 = XUA_PRODUCT_EMPTY_STRING,
.outputInterfaceStr_Audio2 = XUA_PRODUCT_EMPTY_STRING,