I'm using VM's 'board.txt' feature to create a post-build process for a Teensy sketch that involves launching a Windows Console App and passing it some build property parameters. As suggested by Tim, I compiled my Teensy sketch with 'show build properties' enabled which produces a list of build properties that can be utilized as labels in the post-build statement. When the post-build statement(s) is executed, the labels are expanded to their values at that time, and it is the actual values that get passed to my console application as string entries in the args[] string array.
For my application I need to know what serial port is being used, so I chose the 'serial.port.num' parameter which expands to just the numeric part of the port label, i.e. '6' for COM6. This works great, but today I discovered that this parameter was no longer part of the build properties, and instead of being expanded as part of the post-build command processing, the literal string '{serial.port.num}' was passed to my console app instead. Needless to say, this did not end well for my application.
So, I looked a little closer at the 'build properties' displayed when the Teensy app is compiled, and I see quite a bit of variation in what serial port related build properties are available. When I select COM5 (available in the list but AFAIK not connected to anything) I get:
serial.port.file=COM5
serial.port=COM5
serial.port.num=5
When I select COM6 - connected to a Pololu Wixel (the local end of a wireless serial link), I get:
serial.port.caption=COM6 - Wixel
serial.Caption=Wixel (COM6)
serial.ClassGuid={4d36e978-e325-11ce-bfc1-08002be10318}
serial.CompatibleID.value0=USB\Class_02
serial.ConfigManagerErrorCode=0
serial.ConfigManagerUserConfig=False
serial.CreationClassName=Win32_PnPEntity
serial.Description=Wixel
serial.DeviceID=USB\VID_1FFB&PID_2200\D4-AD-C5-07
serial.HardwareID.value0=USB\VID_1FFB&PID_2200
serial.Manufacturer=Pololu Corporation
serial.Name=Wixel (COM6)
serial.PNPClass=Ports
serial.PNPDeviceID=USB\VID_1FFB&PID_2200\D4-AD-C5-07
serial.Present=True
serial.Service=usbser
serial.Status=OK
serial.SystemCreationClassName=Win32_ComputerSystem
serial.SystemName=FRANKNEWXPS15
serial.vid=0x1FFB
serial.pid=0x2200
serial.vidpid=1FFB2200
serial.vid_pid=0x1FFB_0x2200
serial.iserial=D4-AD-C5-07
serial.port.iserial=D4-AD-C5-07
And when I select COM11 which shows as a Teensy 3.5 but without the actual hardware connected, I get
serial.serial.port.port=usb:10000/0/0/2/4/9
serial.serial.port.label=COM11 (Teensy 3.5) Serial
serial.serial.port.protocol=Teensy
And when I select the same port (COM11) but now with an actual Teensy 3.5 connected, I get
serial.port.caption=COM11 - USB Serial Device
serial.Caption=USB Serial Device (COM11)
serial.ClassGuid={4d36e978-e325-11ce-bfc1-08002be10318}
serial.CompatibleID.value0=USB\Class_02
serial.ConfigManagerErrorCode=0
serial.ConfigManagerUserConfig=False
serial.CreationClassName=Win32_PnPEntity
serial.Description=USB Serial Device
serial.DeviceID=USB\VID_16C0&PID_0483\3016580
serial.HardwareID.value0=USB\VID_16C0&PID_0483
serial.Manufacturer=Microsoft
serial.Name=USB Serial Device (COM11)
serial.PNPClass=Ports
serial.PNPDeviceID=USB\VID_16C0&PID_0483\3016580
serial.Present=True
serial.Service=usbser
serial.Status=OK
serial.SystemCreationClassName=Win32_ComputerSystem
serial.SystemName=FRANKNEWXPS15
serial.vid=0x16C0
serial.pid=0x0483
serial.vidpid=16C00483
serial.vid_pid=0x16C0_0x0483
serial.iserial=3016580
serial.port.iserial=3016580
So, I'm not quite sure how to proceed. It looks like build properties associated with a serial port depend to some degree on what is (or was) connected. In the case of the Teensy 3.5, it appears that if I want to know the serial port number, I have to use {serial.serial.port.label} in my post-build argument list if the actual Teensy isn't connected, but {serial.port.caption} or {serial.Caption} or {serial.Name} if it is connected.
So it appears that I'll either need some if/then logic in board.txt to determine which parameter set to use, or put multiple {serial.xxx} parameters in the board.txt argument list and then some smarts in my console app to not choke on literal parameter strings instead of build property value expansions.
I have a headache!