mon / Arduino-USB-Rename

Programatically rename a USB based Arduino
MIT License
24 stars 4 forks source link

invalid conversion #3

Closed dicokruining closed 8 months ago

dicokruining commented 8 months ago

When I run the demo I get the following warnings and the name does not change. I use W11 and a arduino micro.

D:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\demo\demo.ino:3:64: warning: invalid conversion from 'const char' to 'const u8 {aka const unsigned char}' [-fpermissive] USBRename dummy = USBRename("USB Rename Demo", "mon.im", "abcd"); ^ In file included from D:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\demo\demo.ino:1:0: d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master/usb_rename.h:5:5: note: initializing argument 1 of 'USBRename::USBRename(const u8, const u8, const u8)' USBRename( ^~~~~ D:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\demo\demo.ino:3:64: warning: invalid conversion from 'const char' to 'const u8 {aka const unsigned char}' [-fpermissive] USBRename dummy = USBRename("USB Rename Demo", "mon.im", "abcd"); ^ In file included from D:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\demo\demo.ino:1:0: d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master/usb_rename.h:5:5: note: initializing argument 2 of 'USBRename::USBRename(const u8, const u8, const u8)' USBRename( ^~~~~ D:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\demo\demo.ino:3:64: warning: invalid conversion from 'const char' to 'const u8 {aka const unsigned char}' [-fpermissive] USBRename dummy = USBRename("USB Rename Demo", "mon.im", "abcd"); ^ In file included from D:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\demo\demo.ino:1:0: d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master/usb_rename.h:5:5: note: initializing argument 3 of 'USBRename::USBRename(const u8, const u8, const u8)' USBRename( ^~~~~ d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\usb_rename.cpp:30:34: warning: default argument given for parameter 1 of 'USBRename::USBRename(const u8, const u8, const u8)' [-fpermissive] const u8 serial_num = NULL) : ^ In file included from d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\usb_rename.cpp:1:0: d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\usb_rename.h:5:5: note: previous specification in 'USBRename::USBRename(const u8, const u8, const u8)' here USBRename( ^~~~~ d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\usb_rename.cpp:30:34: warning: default argument given for parameter 2 of 'USBRename::USBRename(const u8, const u8, const u8)' [-fpermissive] const u8 serial_num = NULL) : ^ In file included from d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\usb_rename.cpp:1:0: d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\usb_rename.h:5:5: note: previous specification in 'USBRename::USBRename(const u8, const u8, const u8)' here USBRename( ^~~~~ d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\usb_rename.cpp:30:34: warning: default argument given for parameter 3 of 'USBRename::USBRename(const u8, const u8, const u8)' [-fpermissive] const u8 serial_num = NULL) : ^ In file included from d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\usb_rename.cpp:1:0: d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\usb_rename.h:5:5: note: previous specification in 'USBRename::USBRename(const u8, const u8, const u8)' here USBRename( ^~~~~ d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\usb_rename.cpp: In member function 'virtual int USBRename::getDescriptor(USBSetup&)': d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\usb_rename.cpp:49:67: warning: invalid conversion from 'const u8 {aka const unsigned char}' to 'const char' [-fpermissive] return USB_SendStringDescriptor(manufacturer_name, strlen(manufacturer_name), 0); ^~~~~ In file included from C:\Users\kruining\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Arduino.h:25:0, from C:\Users\kruining\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/USBAPI.h:33, from C:\Users\kruining\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/PluggableUSB.h:23, from d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\usb_rename.h:1, from d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\usb_rename.cpp:1: c:\users\kruining\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\string.h:399:15: note: initializing argument 1 of 'size_t strlen(const char)' extern size_t strlen(const char ) ATTR_PURE; ^~ d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\usb_rename.cpp:51:62: warning: invalid conversion from 'const u8 {aka const unsigned char}' to 'const char' [-fpermissive] return USB_SendStringDescriptor(product_name, strlen(product_name), 0); ^~~~ In file included from C:\Users\kruining\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Arduino.h:25:0, from C:\Users\kruining\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/USBAPI.h:33, from C:\Users\kruining\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/PluggableUSB.h:23, from d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\usb_rename.h:1, from d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\usb_rename.cpp:1: c:\users\kruining\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\string.h:399:15: note: initializing argument 1 of 'size_t strlen(const char)' extern size_t strlen(const char *) ATTR_PURE; ^~ d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\usb_rename.cpp:53:60: warning: invalid conversion from 'const u8 {aka const unsigned char}' to 'const char' [-fpermissive] return USB_SendStringDescriptor(serial_num, strlen(serial_num), 0); ^~~~~~ In file included from C:\Users\kruining\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Arduino.h:25:0, from C:\Users\kruining\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/USBAPI.h:33, from C:\Users\kruining\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/PluggableUSB.h:23, from d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\usb_rename.h:1, from d:\Programming\Arduino\Current Projects\libraries\Arduino-USB-Rename-master\usb_rename.cpp:1: c:\users\kruining\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\string.h:399:15: note: initializing argument 1 of 'size_t strlen(const char)' extern size_t strlen(const char *) __ATTR_PURE__; ^~

What's happening?

mon commented 8 months ago

Huh, today I learned that the default option for the Arduino IDE's "Compiler warnings" is "None".

I just pushed a commit that will fix all your warnings, but I suspect it may not fix the "doesn't work" issue. Windows has a habit of not refreshing USB devices if they change their core attributes like string descriptors. I'd use UsbTreeView to confirm what the Manufacturer/Product strings are: https://www.uwe-sieber.de/usbtreeview_e.html

dicokruining commented 8 months ago

Thanks for the fast reply. I don't get the warnings anymore. I can see the descriptor has changes using treeview.