I'm trying to have a custom serial number presented over the USB protocol. It works but there is a small issue.
EDIT: Serial numbers are unique and read from the EEPROM at boot.
I use this in setup of my code, so it's triggered quite early at boot:
The problem I face now is that my flash tool (build with Luni's awesome libTeensySharp) doesn't like this solution.
Devices reboots into halfkay just as it should, but the program doesn't detect that unless I unplug and plug back in my device (it's battery powered so stays in halfkay).
So you might think it's a problem with my custom flash tool, which may very well be the case.
If I don't do the custom serial number code above, it all works fine.
I would greatly appreciate any help to solve the last little hurdle.
Thanks!
EDIT: Serial numbers are unique and read from the EEPROM at boot.
I use this in setup of my code, so it's triggered quite early at boot:
Code:
extern "C"
{
struct usb_string_descriptor_struct
{
uint8_t bLength;
uint8_t bDescriptorType;
uint16_t wString[22];
};
usb_string_descriptor_struct usb_string_serial_number =
{
12,
3,
{0,0,0,0,0,0,0,0,0,0}
};
}
void setUSBserialNo(long Serial)
{
char buf[11];
uint32_t i, num;
num = Serial;
// add extra zero to work around OS-X CDC-ACM driver bug
if (num < 10000000) num = num * 10;
ultoa(num, buf, 10);
for (i=0; i<10; i++) {
char c = buf[i];
if (!c) break;
usb_string_serial_number.wString[i] = c;
}
usb_string_serial_number.bLength = i * 2 + 2;
}
setUSBserialNo("12345678");
The problem I face now is that my flash tool (build with Luni's awesome libTeensySharp) doesn't like this solution.
Devices reboots into halfkay just as it should, but the program doesn't detect that unless I unplug and plug back in my device (it's battery powered so stays in halfkay).
So you might think it's a problem with my custom flash tool, which may very well be the case.
If I don't do the custom serial number code above, it all works fine.
I would greatly appreciate any help to solve the last little hurdle.
Thanks!
Last edited: