Skip to content

TyCommander Integration into V2 IDE and VS Code

K7MDL edited this page Feb 7, 2023 · 4 revisions

TyCommander is found at Koromix/tytools: Collection of tools to manage Teensy boards (github.com)

I have used this tool for over a year and it much better than the built-in serial monitor. Plus, you have buttons to reset and reprogram.

Found this info how to integrate TyCommanderC.exe to manage Multiple Teensy CPUs at once, and multiple serial ports per CPU.

This is my platform.txt file after modification. I commented out the 4 Teensyloader related lines above my new TyCommander lines.

# Arduino Boards Manager - original TeensyLoader lines, commented out for TyCommander below
#tools.teensyloader.cmd.path={runtime.tools.teensy-tools.path}
#tools.teensyloader.upload.params.quiet=
#tools.teensyloader.upload.params.verbose=-verbose
#tools.teensyloader.upload.pattern="{cmd.path}/teensy_post_compile" "-file={build.project_name}" "-path={build.path}" "-tools={cmd.path}" "-board= 
{build.board}" -reboot "-port={serial.port}" "-portlabel={serial.port.label}" "-portprotocol={serial.port.protocol}"

# TyCommander alternative to TeensyLoader
tools.teensyloader.cmd.path=D:\Program Files\TyTools\TyCommanderC.exe
tools.teensyloader.upload.pattern="{cmd.path}" upload --autostart --wait --delegate "{build.path}/{build.project_name}.hex"

Obviously substitute your path to the tool. Restart the IDE. On compile and upload the tools will open automatically. In its Tools menu there is an Integrate to Arduino. This is for IDE V1, the issue linked above was to add the option to integrate to IDE V2.

With the Dual Serial + Audio USB PID (0x484) I am using the Teensy tools do not recognize the Teensy because they use a hard coded VID+PID table. TyCommander will pop up a dialog asking which CPU serial port you want to upload to. The second serial port has the Teensy CPU device name with @1 appended. For us, this is the CAT port you can enable serial monitoring for that port (a menu button) and send test CAT commands easily.

My USB Type set to our custom Dual serial + Audio giving 2 serial ports on TyCommander

An additional note. The path to the .HEX (or .ELF) file to uploads is passed to Teensyloader and TyCommander. The platforms.txt file using {builds.path} variable.

Right now that is only passing the IDE's build path, not VS Code's build path. For VS Code I have a build folder configured for caching builds. The IDE creates a GUID named folder.

The above mods allow both VS Code and Arduino IDE 2 to open TyCommander and upload firmware. They both let you choose the teensy CPU target. But only the IDE build is actually uploaded. The {build.path} needs to be reset by VS code build scripts to use its output folder vs the IDE folder.

Until that is figured out the workaround is to open the TyCommander Actions menu to load new firmware and point it to your VS Code build folder. This only needs to be done once per sketch if you only use VS Code, or after each use of the IDE to build since it resets the path back to it's GUID folder.

I will be looking into how to programmatically set the build.path in a VS code script, maybe someone has already sorted it out.

For VS Code you need to manually set the COM port in the lower right status bar pointing to your Teensy HID com port. The extra com ports are not HID and will be slower to operate. You can see which com port in the right one by looking in the IDE ports menu for the COM port listed under Teensy subsection.

I like to see more build info so have the IDE preferences set to enable that. I do not know how to do that for the VS Code output window yet. You get compiler errors shown, but not linker errors like you can see in the IDE output window. As a result, I have a small IDE window open and use it only for compiling and watching the output messages, I do all editing in VS code and leverage the Intellisense problems report before compiling and use all the Github extensions.

Eventually VS Code Arduino extension will be updated to support IDE 2, we are on the bleeding edge here.

Another key piece to get VS Code to complie with Arduino V2

Configured the Arduino:Path in Settings 
D:\ArduinoIDE\Arduino IDE\resources\app\node_modules\arduino-ide-extension\build\
then check the use Arduino CLI box.
  • Mike