changing usb name?

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
ulao
Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

changing usb name?

Post by ulao » Tue Jun 30, 2009 10:23 pm

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.

Grendel
Rank 4
Rank 4
Posts: 167
Joined: Sat Dec 16, 2006 9:53 pm
Location: Oregon, USA
Contact:

Re: changing usb name?

Post by Grendel » Wed Jul 01, 2009 7:13 am

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.

ulao
Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

Re: changing usb name?

Post by ulao » Thu Jul 02, 2009 6:15 am

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.

Post Reply