|
|
View previous topic :: View next topic |
Author |
Message |
denis_11
Joined: 13 Jul 2010 Posts: 45
|
problem with usb description string... |
Posted: Fri Oct 22, 2010 11:21 am |
|
|
hello, I'm using a pic 18f14k50 with a USB CDC, I would like to change the usb desc string, but when I go to change the SERIAL DEMO in the file usb_desc_cdc.h, on the PC I get something like this:
Code: | ẙTEST HARDWARE DENIS鉤鑠ꑢ퀂鑢จĂ漁ข漃ธ漂ຈ漀欄ข漇ภ漆Āఀďꅓ퀄Āď酓驢Ā |
why? what I have to change or modify? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Oct 22, 2010 12:23 pm |
|
|
I didn't get that at all. I loaded usb_desc_cdc.h into a text editor and
it reads just like a standard text file. This is on Windows XP, with CCS
vs. 4.112. I wonder if you are looking at a compressed file. |
|
|
dbotkin
Joined: 08 Sep 2003 Posts: 197 Location: Omaha NE USA
|
|
Posted: Fri Oct 22, 2010 12:32 pm |
|
|
You need to also change USB_STRING_DESC_OFFSET and the length of string values. For example, in your case you would change the product string to
Code: |
39,
'T',0,
'E',0,
'S',0,
'T',0,
' ',0,
'H',0,
'A',0,
'R',0,
'D',0,
'W',0,
'A',0,
'R',0,
'E',0,
' ',0,
'D',0,
'E',0,
'N',0,
'I',0,
'S',0
|
If you change the manufacturer string from "CCS" you'll need to also change that length from 4 to whatever length it is. The new lengths now become the offset values. So let's assume you change the manufacturer to "MY_WIDGET" and change the product to "TEST HARDWARE DENIS"...
Code: | USB_STRING_DESC_OFFSET[]={0,4,19}; |
If the offsets or lengths are wrong, you'll start spitting out memory contents - leading to odd and unwanted characters. Yeah, I just went through this exact same exercise. On the plus side, the USB functions seem to work *perfectly*. |
|
|
denis_11
Joined: 13 Jul 2010 Posts: 45
|
|
Posted: Fri Oct 22, 2010 2:28 pm |
|
|
nothing...not work...:(
this is the code:
Code: | #if !defined(USB_STRINGS_OVERWRITTEN)
//the offset of the starting location of each string. offset[0] is the start of string 0, offset[1] is the start of string 1, etc.
char USB_STRING_DESC_OFFSET[]={0,4,19};
// Here is where the "CCS" Manufacturer string and "SERIAL DEMO" are stored.
// Strings are saved as unicode.
// These strings are mostly only displayed during the add hardware wizard.
// Once the operating system drivers have been installed it will usually display
// the name from the drivers .INF.
char const USB_STRING_DESC[]={
//string 0
4, //length of string index
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
0x09,0x04, //Microsoft Defined for US-English
//string 1 - manufacturer
8, //length of string index
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
'C',0,
'S',0,
'S',0,
//string 2 - product
39, //length of string index
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
'T',0,
'E',0,
'S',0,
'T',0,
' ',0,
'H',0,
'A',0,
'R',0,
'D',0,
'W',0,
'A',0,
'R',0,
'E',0,
' ',0,
'D',0,
'E',0,
'N',0,
'I',0,
'S',0
};
#endif //!defined(USB_STRINGS_OVERWRITTEN)
#ENDIF |
why? now it is "USB DEVICE"... |
|
|
denis_11
Joined: 13 Jul 2010 Posts: 45
|
|
Posted: Sat Oct 23, 2010 8:49 am |
|
|
nobody knows how to help?
|
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sat Oct 23, 2010 11:12 am |
|
|
Offset and length are both incorrect.
Length is always an even number, so the third length code must be 40. The offset values have to match the actual start of string, so the correct values are {0, 4, 12} |
|
|
denis_11
Joined: 13 Jul 2010 Posts: 45
|
|
Posted: Sat Oct 23, 2010 5:04 pm |
|
|
ok FvM...thanks!!you gave me the exact solution! I had to write an even number of characters...but the manufacturer still does not work...I have configured so:
Code: |
char USB_STRING_DESC_OFFSET[]={0,4,18};
...
char const USB_STRING_DESC[]={
//string 0
4, //length of string index
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
0x09,0x04, //Microsoft Defined for US-English
//string 1 - manufacturer
12, //length of string index
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
'D',0,
'E',0,
'N',0,
'I',0,
'S',0,
' ',0, |
where am I wrong? |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sun Oct 24, 2010 4:28 am |
|
|
In the shown code part, there's only one error: 4 + 12 = 16 not 18. |
|
|
denis_11
Joined: 13 Jul 2010 Posts: 45
|
|
Posted: Sun Oct 24, 2010 7:45 am |
|
|
ok I fixed the error but still can not see the manufacturer...ah if I set 16, I do not see the first character of the description...so I set this:
Code: | #if !defined(USB_STRINGS_OVERWRITTEN)
//the offset of the starting location of each string. offset[0] is the start of string 0, offset[1] is the start of string 1, etc.
char USB_STRING_DESC_OFFSET[]={0,4,18};
char const USB_STRING_DESC[]={
//string 0
4, //length of string index
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
0x09,0x04, //Microsoft Defined for US-English
//string 1 - manufacturer
14, //length of string index
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
'D',0,
'E',0,
'N',0,
'I',0,
'S',0,
' ',0,
//string 2 - product
42, //length of string index
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
'T',0,
'E',0,
'S',0,
'T',0,
' ',0,
'H',0,
'A',0,
'R',0,
'D',0,
'W',0,
'A',0,
'R',0,
'E',0,
' ',0,
'D',0,
'E',0,
'N',0,
'I',0,
'S',0,
' ',0
};
#endif //!defined(USB_STRINGS_OVERWRITTEN)
#ENDIF |
|
|
|
denis_11
Joined: 13 Jul 2010 Posts: 45
|
|
Posted: Mon Oct 25, 2010 3:19 pm |
|
|
I still have not solved the problem, you have any solution? |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Tue Oct 26, 2010 10:02 am |
|
|
The length of the string has to be accurate, garbage characters will be displayed if the number is bigger,
deleted characters will be displayed if the number of the string is lower, for it is a very simple formula:
(String chars + 1) * 2 = string length
The length of a string index is calculated in this way:
length of string index (string length + 1)*2 -> (20 + 1)*2= 21*2=42
Hence in your code:
Code: |
//the offset of the starting location of each string. offset[0] is
char USB_STRING_DESC_OFFSET[]={0,4,12};
char const USB_STRING_DESC[]={
//string 0
4, //length of string index
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
0x09,0x04, //Microsoft Defined for US-English
//string 1 - manufacturer
14, //length of string index
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
'D',0,
'E',0,
'N',0,
'I',0,
'S',0,
' ',0,
//string 2 - product
42, //length of string index
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
'T',0,
'E',0,
'S',0,
'T',0,
' ',0,
'H',0,
'A',0,
'R',0,
'D',0,
'W',0,
'A',0,
'R',0,
'E',0,
' ',0,
'D',0,
'E',0,
'N',0,
'I',0,
'S',0,
' ',0
};
#endif //!defined(USB_STRINGS_OVERWRITTEN)
#ENDIF
|
Regards. |
|
|
Danilo3012
Joined: 19 May 2011 Posts: 2 Location: Brasil
|
|
Posted: Fri Dec 13, 2013 2:37 pm |
|
|
Don't forget to change [char USB_STRING_DESC_OFFSET[]={0,4,12};] to [char USB_STRING_DESC_OFFSET[]={0,4,18};]
Code: | //the offset of the starting location of each string. offset[0] is
char USB_STRING_DESC_OFFSET[]={0,4,18};
char const USB_STRING_DESC[]={
//string 0
4, //length of string index
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
0x09,0x04, //Microsoft Defined for US-English
//string 1 - manufacturer
14, //length of string index
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
'D',0,
'E',0,
'N',0,
'I',0,
'S',0,
' ',0,
//string 2 - product
42, //length of string index
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
'T',0,
'E',0,
'S',0,
'T',0,
' ',0,
'H',0,
'A',0,
'R',0,
'D',0,
'W',0,
'A',0,
'R',0,
'E',0,
' ',0,
'D',0,
'E',0,
'N',0,
'I',0,
'S',0,
' ',0
};
#endif //!defined(USB_STRINGS_OVERWRITTEN)
#ENDIF |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|