Change device name

Status
Not open for further replies.

floretan

Member
I've integrated the Teensy 2.0 into a midi controller pedal project. When I connect the device to a computer the device name is indicated as "Teensy 2.0", is there a way to rename it to something else, like "MySuperMidiController"? I couldn't find any documentation or anyone mentioning this kind of change, so I'm wondering if this is possible.
 
The good news - it is possible. The bad news - it isn't something you can set in your program. Instead you have to edit a file that comes with Teensy (and those changes will affect every other program you write that uses MIDI, unless you maintain multiple copies of the file somewhere and copy them into the folder as needed).

The file you want (for Teensy 2.0 or ++2.0) is (wherever you installed arduino)/hardware/teensy/cores/usbmidi/usb_private.h and I would recommend backing up the usbmidi directory before editing anything.

You will need to change
Code:
#define STR_PRODUCT             L"Teensy MIDI"
you may need to change (to defeat cacheing of USB device IDs)
Code:
#define PRODUCT_ID              0x0485

Avoid using a number that is already used (and be prepared to change it if the owner of the vendor ID (PJRC) adds new ones). These are already in use:
Code:
$ find . -name *.h -exec grep PRODUCT_ID {} \;
  #define PRODUCT_ID            0x0483
  #define PRODUCT_ID            0x0482
  #define PRODUCT_ID            0x0487
  #define PRODUCT_ID            0x0485
  #define PRODUCT_ID            0x0486
  #define PRODUCT_ID            0x0488
#define PRODUCT_ID              0x0484
#define PRODUCT_ID              0x0488
#define PRODUCT_ID              0x0482
#define PRODUCT_ID              0x0485
#define PRODUCT_ID              0x0485
#define PRODUCT_ID              0x0486
#define PRODUCT_ID              0x0483
#define PRODUCT_ID              0x0487
 
The bad news - it isn't something you can set in your program.

This is on my to-do list.

But since it is possible to change the name by editing the code, it's a relatively low priority.

There are a number of challenges to make this configurable from the sketch in Arduino. The only realistic option, due to how the Arduino build process works, is a weak symbol which your code can override. Changing the Arduino build process is really not an option, because there are a huge number of libraries and existing projects which are subtle dependencies on the build process.

The trouble with a weak symbol is the USB descriptor stuff depends on finding the string length as a compile-time constant. Obviously the compiler can't know the length of your string in the sketch while compiling the USB code (remember, restructuring the build process is not an option because compatibility with Arduino is a major design goal). So the USB descriptor sending code, inside that interrupt-based code, needs to be redesigned to handle data somewhat differently. That's the main reason this is still on my to-do list... there's no quick and easy way to do it. On AVR, there's also the issue of making sure the user's data is in the right memory space, but that's a lesser concern because people will probably just copy and edit an example.
 
Hey Nantonos,
thank you for the instructions!
But how does it work with Teensy 3.1? Is it possible, too?
 
Hey,
just found it out: You can edit the device name for 'teensy 3' in this file: 'usb_desc.h'
You'll find it in the teensy 3 folder!
Have fun!
 
I have just stumbled across this thread while doing a search. I am using a Teensy 2.0 and have followed the steps above. I am received a string of errors when trying to upload my sketch to Teensy. Any assistance would be greatly appreciated!


Error:

Arduino: 1.0.5 (Mac OS X), Board: "Teensy 2.0"
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega32u4 -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -DTEENSYDUINO=118 -felide-constructors -std=c++0x -DUSB_HID -DLAYOUT_US_ENGLISH -I/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy -I/Applications/Arduino-1.app/Contents/Resources/Java/libraries/Bounce /var/folders/w7/hnpx1z2s0sjfzgywfg5h69dc0000gn/T/build5311875877911810759.tmp/MediaButtons.cpp -o /var/folders/w7/hnpx1z2s0sjfzgywfg5h69dc0000gn/T/build5311875877911810759.tmp/MediaButtons.cpp.o
Using previously compiled: /var/folders/w7/hnpx1z2s0sjfzgywfg5h69dc0000gn/T/build5311875877911810759.tmp/Bounce/Bounce.cpp.o
Using previously compiled: /var/folders/w7/hnpx1z2s0sjfzgywfg5h69dc0000gn/T/build5311875877911810759.tmp/keylayouts.c.o
Using previously compiled: /var/folders/w7/hnpx1z2s0sjfzgywfg5h69dc0000gn/T/build5311875877911810759.tmp/malloc.c.o
Using previously compiled: /var/folders/w7/hnpx1z2s0sjfzgywfg5h69dc0000gn/T/build5311875877911810759.tmp/pins_teensy.c.o
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-gcc -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega32u4 -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -DTEENSYDUINO=118 -DUSB_HID -DLAYOUT_US_ENGLISH -DSERIALNUM=949474865 -I/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy /Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/usb.c -o /var/folders/w7/hnpx1z2s0sjfzgywfg5h69dc0000gn/T/build5311875877911810759.tmp/usb.c.o
In file included from /Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/usb.c:4:
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:383: error: stray '\342' in program
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:383: error: stray '\200' in program
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:383: error: stray '\235' in program
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:383: error: 'L' undeclared here (not in a function)
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:383: error: expected ')' before 'Weston'
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:383: error: stray '\342' in program
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:383: error: stray '\200' in program
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:383: error: stray '\235' in program
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:385: error: stray '\342' in program
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:385: error: stray '\200' in program
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:385: error: stray '\235' in program
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:385: error: expected '}' before 'Weston'
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:385: error: stray '\342' in program
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:385: error: stray '\200' in program
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:385: error: stray '\235' in program
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:409: error: stray '\342' in program
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:409: error: stray '\200' in program
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:409: error: stray '\235' in program
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:409: error: expected ')' before 'Weston'
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:409: error: stray '\342' in program
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:409: error: stray '\200' in program
/Applications/Arduino-1.app/Contents/Resources/Java/hardware/teensy/cores/teensy/../usb_hid/usb.c:409: error: stray '\235' in program
 
From those errors, it looks like you copied non-ASCII characters into the usb.c source code.

I'd suggest restoring usb.c to an original copy, and then try again with a text editor, manually typing or copy-paste from a simple text editor, not something fancy that could include non-ASCII stuff.
 
Paul -

Thank you for your suggestion. I have tried the steps below, restoring to original copy (I actually completely uninstalled and reinstalled Arduino and Teensyduino). I edited the usb_private.h per the instructions above simply using the Mac OSX Text Edit application. I am still getting the same results.

I must be doing some incorrectly, just next exactly sure what it is.
 
hey naweston, I wonder if you could post the string of characters you are trying to change the device string to and attach the file you are changing (with your change(s)) to that post - just an idea that by seeing those the people who can help will have a better chance of finding the actual problem and helping you fix it.
 
Per request here is the file (usb_private.h) that I have updated. This file came from the ...\hardware\teensy\usb_hid folder. I am trying to update the name for my Teensy 2.0 device.

Thank you again for taking the time to help me out!


Code:
#ifndef usb_serial_h__
#define usb_serial_h__

#include <stdint.h>

#ifdef __cplusplus
extern "C"{
#endif

/**************************************************************************
 *
 *  Configurable Options
 *
 **************************************************************************/

#define VENDOR_ID               0x16C0
#define PRODUCT_ID              0x0482
#define TRANSMIT_FLUSH_TIMEOUT  4   /* in milliseconds */
#define TRANSMIT_TIMEOUT        25   /* in milliseconds */


/**************************************************************************
 *
 *  Endpoint Buffer Configuration
 *
 **************************************************************************/

// These buffer sizes are best for most applications, but perhaps if you
// want more buffering on some endpoint at the expense of others, this
// is where you can make such changes.  The AT90USB162 has only 176 bytes
// of DPRAM (USB buffers) and only endpoints 3 & 4 can double buffer.


// 0: control				32	64
// 1: debug IN				64	64x2
// 2: debug OUT				32	32x2
// 3: keyboard IN			8x2	8x2
// 4: mouse + joystick IN  (IDs)	16x2	16x2
// 5: joystick					16x2
// 6: 

#if defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)

// Some operating systems, especially Windows, may cache USB device
// info.  Changes to the device name may not update on the same
// computer unless the vendor or product ID numbers change, or the
// "bcdDevice" revision code is increased.

#define STR_PRODUCT             L”Nick Weston”
#define ENDPOINT0_SIZE          64

#define DEBUG_INTERFACE		2
#define DEBUG_TX_ENDPOINT	1
#define DEBUG_TX_SIZE		64
#define DEBUG_TX_BUFFER		EP_DOUBLE_BUFFER
#define DEBUG_TX_INTERVAL	1
#define DEBUG_RX_ENDPOINT	2
#define DEBUG_RX_SIZE		32
#define DEBUG_RX_BUFFER		EP_DOUBLE_BUFFER
#define DEBUG_RX_INTERVAL	2

#define KEYBOARD_INTERFACE	0
#define KEYBOARD_ENDPOINT	3
#define KEYBOARD_SIZE		8
#define KEYBOARD_BUFFER		EP_DOUBLE_BUFFER
#define KEYBOARD_INTERVAL	1

#define MOUSE_INTERFACE		1
#define MOUSE_ENDPOINT		4
#define MOUSE_SIZE		8
#define MOUSE_BUFFER		EP_DOUBLE_BUFFER
#define MOUSE_INTERVAL		1

#define JOYSTICK_INTERFACE	3
#define JOYSTICK_ENDPOINT	5
#define JOYSTICK_SIZE		16
#define JOYSTICK_BUFFER		EP_DOUBLE_BUFFER
#define JOYSTICK_INTERVAL	2

#define NUM_ENDPOINTS		7
#define NUM_INTERFACE		4

#elif defined(__AVR_AT90USB162__)

#define STR_PRODUCT             L”Nick Weston”
#define ENDPOINT0_SIZE          32

#define DEBUG_INTERFACE		2
#define DEBUG_TX_ENDPOINT	1
#define DEBUG_TX_SIZE		64
#define DEBUG_TX_BUFFER		EP_SINGLE_BUFFER
#define DEBUG_TX_INTERVAL	2
#define DEBUG_RX_ENDPOINT	2
#define DEBUG_RX_SIZE		32
#define DEBUG_RX_BUFFER		EP_SINGLE_BUFFER
#define DEBUG_RX_INTERVAL	8

#define KEYBOARD_INTERFACE	0
#define KEYBOARD_ENDPOINT	3
#define KEYBOARD_SIZE		8
#define KEYBOARD_BUFFER		EP_DOUBLE_BUFFER
#define KEYBOARD_INTERVAL	1

#define MOUSE_INTERFACE		1
#define MOUSE_ENDPOINT		4
#define MOUSE_SIZE		8
#define MOUSE_BUFFER		EP_DOUBLE_BUFFER
#define MOUSE_INTERVAL		8

#define NUM_ENDPOINTS		5
#define NUM_INTERFACE		3

#endif



// setup
void usb_init(void);			// initialize everything
void usb_shutdown(void);		// shut off USB

// variables
extern volatile uint8_t usb_configuration;
extern volatile uint8_t usb_suspended;
extern volatile uint8_t debug_flush_timer;
extern uint8_t keyboard_report_data[];
extern uint8_t keyboard_idle_count;
extern volatile uint8_t keyboard_leds;
extern uint8_t mouse_buttons;
#ifdef JOYSTICK_INTERFACE
extern uint8_t joystick_report_data[12];
#endif



#ifdef __cplusplus
} // extern "C"
#endif

#endif
 
I have solved this issue! The issue was that when I was editing the name, my Text Editor (default Mac OSX Text Edit), was adding different looking (I assuming different program language as well) quotation marks. See examples below, notice how the end quotes have a slight slant to them.

THIS WORKS
Code:
#define STR_PRODUCT             L"THIS WORKS"

THIS DOES NOT
Code:
#define STR_PRODUCT             L”THIS DOES NOT”
 
Last edited:
How did you stop it doing that? Is there a preference settin in the editor, or did you use a different editor?
 
There maybe a preference in the editor, however that is not how I accomplished this. I simply copied the quotations marks from the original file and pasted them around my text.
 
(...) The only realistic option, due to how the Arduino build process works, is a weak symbol which your code can override. (...)

Why would it have to be done on linker level? Couldn`t one just use the c preprocessor to modify the standard settings? (through modification of the compiler command line of or by including a project specific header file)
 
Hm, I just tried to include my mySketch/custom_settings.h within the teensy arduino.h
but did not find a way to tell the compiler where to find my sketch folder.
I am a bit puzzeled now since from what I have read so far it looked like the sketch directory is part of the include path.
(http://arduino.cc/en/Hacking/BuildProcess)
As it turns out this only seems to be true for the sketch but not for the core files.
Is there a more detailled documentation of the build process available somewhere?
Thanks!
 
So I'm reviving this thread, as I'm having a strange problem.

When I change the name for the MIDI descriptor to anything - and in fact even if I leave it alone - it appears in the OSX System Report correctly (as either my custom name/manufacturer, or 'Teensy MIDI/TeensyDuino,' but all other programs I've tried it with (MaxMSP and Pro Tools) see it as 'USB MIDI Device.' Completely ignoring the name that I've given, and the name that the OS seems to see. I've tried tweaking the product and manufacturer IDs, to see if somehow it was just a caching problem, but it persists no matter what ID combo I use.

I'm using Teensyduino v1.20RC4 on Arduino 1.0.5 (about to update to 1.20, and arduino 1.0.6 to see if that resolves anything). OSX 10.9.5. Anyone have any ideas what would cause this?

Edit: When I try and install Teensyduino 1.20 atop Arduino 1.0.6, the resulting app is 'damaged and cannot be opened' and I 'should move it to the trash.' ????

Edit 2: Teensyduino 1.20 on Arduino 1.0.5 will run (hooray!) but still makes MIDI devices appear as 'USB MIDI Device' in all applications except System Profiler.
 
Last edited:
Update: So, simple, odd fix for the problem I was having. I had to 'rescan MIDI' from the Audio MIDI Setup app, and then it recognized the name and manufacturer strings correctly.

I don't recall ever having to do that before, so maybe Apple screwed something up in 10.9.5.
 
I would be interested to know if there is any new information on this. I have at least two Teensy-based MIDI interfaces that I will need to use on the same system soon, and juggling back-end files that shouldn't change is not one of my strong suits.
 
I've noticed something strange. After changing the MIDI device name on Teensy's 3.1, it doesn't load the sketches properly anymore. It requires to press the reset button everytime when uploading.

Anybody experienced that before ? Any idea how to avoid that ?
 
If you've changed the Vendor ID or Product ID from usb_desc.h, you lose the auto-reboot function (and thus auto loading sketches). The teensy loader app is looking for something with a specific range of ID#'s to send a reset signal too.
 
If you've changed the Vendor ID or Product ID from usb_desc.h, you lose the auto-reboot function (and thus auto loading sketches). The teensy loader app is looking for something with a specific range of ID#'s to send a reset signal too.

that makes sense. thank you MuShoo.
 
It still should auto-reboot if you leave the ID numbers the same. The teensy_reboot program only looks for the numbers, not the name.

If you're using Windows, please keep in mind the new hardware wizard caches lots of stuff in the windows registry. Yes, that's absolutely silly, since the USB descriptors have to be always be fully read during USB enumeration.... but this is Microsoft we're talking about and they do love their registry. Often it's necessary to increment the BCD version number to get Windows to recognize you've changed something.
 
Last edited:
It still should auto-reboot if you leave the ID numbers the same. The teensy_reboot program only looks for the numbers, not the name.

If you're using Windows, please keep in mind the new hardware wizard caches lots of stuff in the windows registry. Yes, that's absolutely silly, since the USB descriptors have to be always be fully read during USB enumeration.... but this is Microsoft we're talking about and they do love their registry. Often it's necessary to increment the BCD version number to get Windows to recognize you've changed something.

Thank you so much for confirming this Paul, it works out now and it's all going smooth.
 
It still should auto-reboot if you leave the ID numbers the same. The teensy_reboot program only looks for the numbers, not the name.

If you're using Windows, please keep in mind the new hardware wizard caches lots of stuff in the windows registry. Yes, that's absolutely silly, since the USB descriptors have to be always be fully read during USB enumeration.... but this is Microsoft we're talking about and they do love their registry. Often it's necessary to increment the BCD version number to get Windows to recognize you've changed something.

Just so it's known, I've noticed similar behavior from OSX 10.9.5. The name, and often the capabilities (I've been experimenting with multi-port MIDI again), won't refresh in OSX's System Report, or the Audio MIDI Setup app, without swapping out an ID number. Annoyingly, I've no idea WHERE OSX keeps it's USB device-name cache, or how to clear it out.
 
Status
Not open for further replies.
Back
Top