Page 1 of 1
changing usb name?
Posted: Tue Jun 30, 2009 10:23 pm
by ulao
Is there any way to change the #define USB_CFG_DEVICE_NAME later on ? I set the #define USB_CFG_DEVICE_NAME in my config, but I'd like to change this in my code main(). I only would change it once but I do a device selection and would like to find a way to state what type of device was found.
Re: changing usb name?
Posted: Wed Jul 01, 2009 7:13 am
by Grendel
I do exactly that in the
3DP-Vert project -- the USB port gets activated after a joystick was found and identified. The device name is set accordingly.
Basically you do it like this:
1. in usbconfig.h change USB_CFG_DESCR_PROPS_STRING_PRODUCT to USB_PROP_IS_DYNAMIC
2. create your own string descriptors for the names you want to use (in FLASH)
3. implement usbFunctionDescriptor to catch the request for the device name and provide your own
Check out usbconfig.h and main.c from the project for details.
Re: changing usb name?
Posted: Thu Jul 02, 2009 6:15 am
by ulao
ok I was able to set my device name like this dynamically, but is this method going to change when the device it switched without deleting the reg key? the Id can only be stored in one location per ID so how could it be changed? Just wondering if I missed something.
Assuming the to question is false...
how can I change the data after its defined? If I try to use non defines like so
const char CFG_DEVICE_NAME[ ]={'0','2'}; ( didnt work )
const int CFG_DEVICE_NAME_SZ =2
int descStringDevice[] PROGMEM= { (2*(CFG_DEVICE_NAME_SZ)+2) | (3<<8), CFG_DEVICE_NAME } ;
I get "tg16.c:224: error: initializer element is not constant" Is there a way to get the compiler to think its const?
int descStringDevice[] PROGMEM= { 6 | (3<<8), CFG_DEVICE_NAME } ;
If I put in a number it passes
but the size is definitely off as I get a strange character.
I'm not after changing the data while using it, just need to probe for a few things before I set it. I could store all possibilities but I'd be out of flash in no time as I need to store 30 some ints...
is there a way to use PSTR or to modify the upper/lower case bits? or is this a bad idea..
OFF TOPIC, can you out line the section of this descriptor that is responsible for force feed back? I'm guessing the FFP is that section but I dont see any "effect" command in the discriptor and I have been try to figure out FF for a while now.