Changed the unique id generation to be 8 characters long. This is so Mac OS X uses the the unique id for naming the device file instead of the location.
This commit is contained in:
parent
53ebc6770e
commit
a7f14e3cc0
@ -350,7 +350,7 @@ static const struct usb_config_descriptor config = {
|
|||||||
.interface = ifaces,
|
.interface = ifaces,
|
||||||
};
|
};
|
||||||
|
|
||||||
static char serial_no[25];
|
static char serial_no[9];
|
||||||
|
|
||||||
static const char *usb_strings[] = {
|
static const char *usb_strings[] = {
|
||||||
"x",
|
"x",
|
||||||
@ -532,17 +532,20 @@ void usb_lp_can_rx0_isr(void)
|
|||||||
|
|
||||||
static char *get_dev_unique_id(char *s)
|
static char *get_dev_unique_id(char *s)
|
||||||
{
|
{
|
||||||
volatile uint8_t *unique_id = (volatile uint8_t *)0x1FFFF7E8;
|
volatile uint32_t *unique_id_p = (volatile uint32_t *)0x1FFFF7E8;
|
||||||
|
uint32_t unique_id = *unique_id_p +
|
||||||
|
*(unique_id_p + 1) +
|
||||||
|
*(unique_id_p + 2);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Fetch serial number from chip's unique ID */
|
/* Fetch serial number from chip's unique ID */
|
||||||
for(i = 0; i < 24; i+=2) {
|
for(i = 0; i < 8; i++) {
|
||||||
s[i] = ((*unique_id >> 4) & 0xF) + '0';
|
s[7-i] = ((unique_id >> (4*i)) & 0xF) + '0';
|
||||||
s[i+1] = (*unique_id++ & 0xF) + '0';
|
|
||||||
}
|
}
|
||||||
for(i = 0; i < 24; i++)
|
for(i = 0; i < 8; i++)
|
||||||
if(s[i] > '9')
|
if(s[i] > '9')
|
||||||
s[i] += 'A' - '9' - 1;
|
s[i] += 'A' - '9' - 1;
|
||||||
|
s[8] = 0;
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user