Rename serial ports on Mac OSX

I am working on a project involving several Leonardo boards that are controlled with Max MSP on one single computer, and I find it quite unclear that each one appears in the port list as "Arduino Leonardo". Could someone tell me how I can rename the name that these boards are given by default on Mac OSX, or whether there is an easier way to rename them in Max?
Thank you for your attention.

Here's how you can do it:

Tools > Board > Arduino Leonardo

File > Examples > SPI > BarometricPressureSensor

Sketch > Show Sketch Folder. This will open the BarometricPressureSensor example sketch folder.

Move up four folder levels to the folder that contains the file boards.txt

Create a file named boards.local.txt

Open boards.local.txt in a text editor

Add the following text to the file:

##############################################################

leonardo1.name=Arduino Leonardo #1
leonardo1.vid.0=0x2341
leonardo1.pid.0=0x9991

leonardo1.upload.tool=avrdude
leonardo1.upload.protocol=avr109
leonardo1.upload.maximum_size=28672
leonardo1.upload.maximum_data_size=2560
leonardo1.upload.speed=57600
leonardo1.upload.disable_flushing=true
leonardo1.upload.use_1200bps_touch=true
leonardo1.upload.wait_for_upload_port=true

leonardo1.bootloader.tool=avrdude
leonardo1.bootloader.low_fuses=0xff
leonardo1.bootloader.high_fuses=0xd8
leonardo1.bootloader.extended_fuses=0xcb
leonardo1.bootloader.file=caterina/Caterina-Leonardo.hex
leonardo1.bootloader.unlock_bits=0x3F
leonardo1.bootloader.lock_bits=0x2F

leonardo1.build.mcu=atmega32u4
leonardo1.build.f_cpu=16000000L
leonardo1.build.vid=0x2341
leonardo1.build.pid=0x9991
leonardo1.build.usb_product="Arduino Leonardo"
leonardo1.build.board=AVR_LEONARDO
leonardo1.build.core=arduino
leonardo1.build.variant=leonardo
leonardo1.build.extra_flags={build.usb_flags}

This part:

leonardo1.name=Arduino Leonardo #1

is where the name of the board is defined "Arduino Leonardo #1", so you can modify that as you like.

Add that text again for each of the boards you want. For each one, you need to modify the "leonardo1." part to have a unique value. You also need to modify this line:

leonardo1.build.pid=0x9991

to have a unique number. And of course you'll want to modify the name property.

Save the file.

Close all Arduino IDE windows.

Open the Arduino IDE.

Connect one of your Leonardos to the computer.

Tools > Board > select the board you want to change the name to.

Tools > Port > select the port of your Leonardo.

Upload any sketch. After the sketch has uploaded and the board has reinstalled, you will now see the board shows under the Tools > Port menu with the new name.

Repeat with the other boards.

Note that you will need to use the correct Tools > Board menu item for each board from now on, otherwise you will change the board's name in the Tools > Port menu.

Note that you will need to redo the boards.local.txt thing every time you update to a new version of Arduino AVR Boards (which could also happen if you update the Arduino IDE. I recommend that you save a copy of your boards.local.txt file somewhere safe so you can just copy it back to the folder with the boards.txt file after the update.

Thank you for such a detailed description! The renaming worked just fine on the IDE level (I can choose now between Arduino Leonardo #1, #2 and #3, and once a sketch is uploaded to one of them, the port is also displayed with the new board name, so on this side everything is great) but I am still getting just three “Arduino Leonardo” in the list of inports in Max MSP. I am wondering whether there is something else to be changed so the boards show up with their new name.

Just to clarify, that's the code that I added to the boards file:

##############################################################

leonardo3.name=Arduino Leonardo #3
leonardo3.vid.0=0x2341
leonardo3.pid.0=0x9993

leonardo3.upload.tool=avrdude
leonardo3.upload.protocol=avr109
leonardo3.upload.maximum_size=28672
leonardo3.upload.maximum_data_size=2560
leonardo3.upload.speed=57600
leonardo3.upload.disable_flushing=true
leonardo3.upload.use_1200bps_touch=true
leonardo3.upload.wait_for_upload_port=true

leonardo3.bootloader.tool=avrdude
leonardo3.bootloader.low_fuses=0xff
leonardo3.bootloader.high_fuses=0xd8
leonardo3.bootloader.extended_fuses=0xcb
leonardo3.bootloader.file=caterina/Caterina-Leonardo.hex
leonardo3.bootloader.unlock_bits=0x3F
leonardo3.bootloader.lock_bits=0x2F

leonardo3.build.mcu=atmega32u4
leonardo3.build.f_cpu=16000000L
leonardo3.build.vid=0x2341
leonardo3.build.pid=0x9993
leonardo3.build.usb_product="Arduino Leonardo 3"
leonardo3.build.board=AVR_LEONARDO
leonardo3.build.core=arduino
leonardo3.build.variant=leonardo
leonardo3.build.extra_flags={build.usb_flags}

The lines that I changed are:

leonardo3.name=Arduino Leonardo #3
leonardo3.pid.0=0x9993
leonardo3.build.pid=0x9993
leonardo3.build.usb_product="Arduino Leonardo 3"

Max MSP is still reading them as "Arduino Leonardo" so I guess it looks for their name in a different level. I just don't know where.

It looks good to me. Nice work catching that you were supposed to change leonardo3.pid.0=0x9993 to match leonardo3.build.pid=0x9993. I forgot to mention that.

I don't know where Max MSP is getting that "Arduino Leonardo". The names shown in the Arduino IDE's Tools > Port menu are the leonardo3.name property, as determined by a match of the devices VID/PID to any of the leonardo3.vid and leonardo3.pid values. But of course Max MSP has no way of reading the leonardo3.name property.

I would expect it to get the name from the build.usb_product property. That value is written into the USB code that runs in the background of any sketch you upload it to the Leonardo. I don't own a Mac, so I can only go off of my experiments with Windows. On Windows, after I upload the sketch after changing the PID, I get a pop up that says "Installing Arduino Leonardo 3", where "Arduino Leonardo 3" is the build.usb_product value. But when I look at the ports list in Device Manager, they are named according to the names in the driver .inf file. When I look at the device properties, the build.usb_product value is listed under "Bus reported device description". I don't understand how Max MSP can get the "Arduino Leonardo" name after you have changed the PID, since it would not match with the Arduino driver anymore.

Hopefully someone else here with experience with macOS/Max MSP/USB can step in and help out here.

I got a hint that fixes the problem on Mac, which was easier than what it looked like. You can open the Audio MIDI Setup utility, ask it for showing the MIDI studio, and there you will find the boards with the same time. Once you've changed the device names, it's ready to appear properly in Max MSP.

Ah, so it uses a system similar to how the Arduino IDE labels the ports, where the strings are defined by files specific to the Max MSP application?

Thanks for taking the time to provide an update with the solution you found. I'm sure anyone else with a similar question who finds this in a Google search will be very grateful. I'm glad to hear you got it working. Enjoy!
Per

I can still offer a new solution, which I got from a generous user from the Cycling'74 forum. They provided me with a code that you can copy to the Arduino folders and which gets the job done from within the Arduino IDE, and is recognised by the Audio MIDI Setup and therefore by Max. The good point about using it (or about exploring the code to adapt it to your needs) is that the devices so renamed as "Leo-Midi-1", "Leo-Midi-2" and "Leo-Midi-3" will appear like this regardless of the USB port where they are plugged. The Audio MIDI Setup solution, on then other hand, is port-dependent, so if you plug your second device in the port labelled as "Leonardo 1" you will see that device named after that first port. This pieces of code correct that. For the full discussion in the other forum and the code, visit here: Rename serial ports using Arduino - MaxMSP Forum | Cycling '74
I hope too that this can be useful to someone else! Thank you for the time you spent with this and for your interest.