CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

HID how to change "iManufacturer" and "iProdu

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
spilz



Joined: 30 Jan 2012
Posts: 220

View user's profile Send private message

HID how to change "iManufacturer" and "iProdu
PostPosted: Sun Aug 11, 2013 6:37 am     Reply with quote

Hello,

I'm trying to use HID usb example, everything is doing well, but now, I would like to change "iManufacturer" and "iProduct" name when I connect it to a computer.

How can I do it? Is it in the chip ? or in the driver ?

thanks for your help

Spilz
Ttelmah



Joined: 11 Mar 2010
Posts: 19551

View user's profile Send private message

PostPosted: Sun Aug 11, 2013 8:46 am     Reply with quote

Both...

The driver recognises a number the 'PID' (product ID), and 'VID' (vendor ID), and will only load for ones that match what it is written for. These numbers come from the chip.

Legally the PID is _sold_ by the USB org. The holder of a VID, can then sell ranges of product ID's to other companies.

However what is displayed (so for instance 'CCS', and 'SERIAL DEMO'), is in the USB string descriptor from the chip. So these two text strings, can be changed in the chip.

Best Wishes
ze.vana



Joined: 11 Jun 2011
Posts: 15

View user's profile Send private message Send e-mail

PostPosted: Tue Aug 12, 2014 8:31 am     Reply with quote

Hello mr. Ttelmah
Sorry for reopen this thread, but could you be more specific on this:
"So these two text strings, can be changed in the chip."
Where can I change here the VID and PID?


usb_desc_hid.h
Code:

const char USB_CLASS_SPECIFIC_DESC[] = {
      6, 0, 255,    // Usage Page = Vendor Defined
      9, 1,            // Usage = IO device
      0xa1, 1,       // Collection = Application
      0x19, 1,        // Usage minimum
      0x29, 8,        // Usage maximum

      0x15, 0x80,        // Logical minimum (-128)
      0x25, 0x7F,        // Logical maximum (127)

      0x75, 8,        // Report size = 8 (bits)
      0x95, 2,        // Report count = 16 bits (2 bytes)
      0x81, 2,        // Input (Data, Var, Abs)
      0x19, 1,        // Usage minimum
      0x29, 8,        // Usage maximum
      0x75, 8,        // Report size = 8 (bits)
      0x95, 2,        // Report count = 16 bits (2 bytes)
      0x91, 2,        // Output (Data, Var, Abs)
      0xc0            // End Collection
   };

I have this VISUAL C# example asking for these Vendor ID and Product ID (0x04D8, 0x0042)
see code above:

WFF_Generic_HID_Demo_3 VISUAL C# 2010
Code:

public Form1()
                       
            {
            InitializeComponent();

            // Create the USB reference device object (passing VID and PID)
            theUsbDemoDevice = new usbDemoDevice(0x04D8, 0x0042);

            // Add a listener for usb events
            theUsbDemoDevice.usbEvent += new usbDemoDevice.usbEventsHandler(usbEvent_receiver);

            // Perform an initial search for the target device
            theUsbDemoDevice.findTargetDevice();
            }

        // Create an instance of the USB reference device
        private usbDemoDevice theUsbDemoDevice;

        // Listener for USB events
        private void usbEvent_receiver(object o, EventArgs e)
            {
            // Check the status of the USB device and update the form accordingly
            if (theUsbDemoDevice.isDeviceAttached)
                {
                // Device is currently attached

                // Update the status label
                this.toolStripStatusLabel1.Text = "USB Device is attached";

                // Update the form
                this.toggleLedStateButton.Enabled = true;
                }
            else
                {
                // Device is currently unattached

                // Update the status label
                this.toolStripStatusLabel1.Text = "USB Device is detached";

                // Update the form
                this.toggleLedStateButton.Enabled = false;
                }
            }
Ttelmah



Joined: 11 Mar 2010
Posts: 19551

View user's profile Send private message

PostPosted: Tue Aug 12, 2014 1:14 pm     Reply with quote

How about just searching in the file for PID or VID?.
It's not in the descriptor.

Just #define USB_CONFIG_PID and USB_CONFIG_VID, before loading the descriptor file.
ze.vana



Joined: 11 Jun 2011
Posts: 15

View user's profile Send private message Send e-mail

PostPosted: Wed Aug 13, 2014 8:33 am     Reply with quote

Yes I've done searching in all CCS folders and in this Forum about related usb PID, VDI.
I also made your recommended changing, but I think it doesn't make sense because "USB_CONFIG_PID"
is not called anywehere. I'm using example ex_usb_hid.c.
Code:

///////////////////////////////////////////////////////////////////////////////////////
//How about just searching in the file for PID or VID?.                              //
//It's not in the descriptor.                                                        //
//Just #define USB_CONFIG_PID and USB_CONFIG_VID, before loading the descriptor file.//
///////////////////////////////////////////////////////////////////////////////////////
#define USB_CONFIG_PID 0x0042
#define USB_CONFIG_VID 0x04d8
//////////////////////////////////////////////////////////////////////////////////////

#if __USB_PIC_PERIF__
 #if defined(__PCM__)
  #include <pic_usb.h>   //Microchip PIC16C765 hardware layer for usb.c
 #else
  #include <pic18_usb.h>   //Microchip 18Fxx5x hardware layer for usb.c
 #endif
#else
 #include <usbn960x.c>   //National 960x hardware layer for usb.c
#endif
#include <usb_desc_hid.h>   //USB Configuration and Device descriptors for this UBS device
#include <usb.c>        //handles usb setup tokens and get descriptor reports


Now I think I'm using a very old compiler (CCS 4.057). Do you think It is the problem?
Ttelmah



Joined: 11 Mar 2010
Posts: 19551

View user's profile Send private message

PostPosted: Thu Aug 14, 2014 1:00 am     Reply with quote

A #define, is not 'called', but used. It is a macro.

However age is a core problem.

4.057, is _before_ V4, started to produce useable/working code. Do a search here. V4, started to properly work around the mid 4.07x versions. Before this, V3 was better...

In your version, the VID/PID is 'hard coded' in the descriptor. However a search on 'vendor', or 'product' would still find it.
ze.vana



Joined: 11 Jun 2011
Posts: 15

View user's profile Send private message Send e-mail

PostPosted: Thu Aug 14, 2014 1:42 pm     Reply with quote

Thanks Mister for reply
I'll do that. Your help was very usefull.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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