Teensy40 - run serial monitor on "USB_RAWHID" port

I’m build an USB raw hid application for my Teensy 4.0 board and want to read my debug output via the serial monitor on a Ubuntu machine running Visual Code and, of course, PIO. The serial monitor is working on my Ubuntu machine with the Arduino IDE using the port /dev/hidraw3, but while starting the Serial Monitor in Visual Code, i get the following error:

could not open port '/dev/hidraw3': Could not configure port: (22, 'Invalid argument')

My platformio.ini looks like this:
[env:teensy40]
platform = teensy
board = teensy40
framework = arduino
build_flags = -D USB_RAWHID
monitor_speed = 9600
monitor_port = /dev/hidraw3
monitor_filters = default

Can you give me a hint, how to adapt the platformio.ini?

PlatformIO’s serial monitor program is miniterm.py, which is not capable of decoding the HID serial console opened by the teensy. Giving miniterm.py the port argument /dev/hidraw3 won’t work.

See e.g. Make Serial Monitor work with USB Type: "MIDI" · Issue #6 · platformio/platform-teensy · GitHub and Support for `teensy_ports` tool · Issue #36 · platformio/platform-teensy · GitHub on how to invoke teensy_serialmon from the Arduino IDE.

Alternatively, use the regular USB serial (CDC), USB_SERIAL, per docs (this is already the default), or USB_SERIAL_HID to get Serial + HID.

Thanks for the links and the explanation. I use now the following commands to get a serial monitor for my USB raw HID Teensy program.

List Teensy ports:

teensy_ports -L
-->
/sys/devices/pci0000:00/0000:00:08.1/0000:07:00.3/usb3/3-2/3-2.3/3-2.3.3 /dev/hidraw3 (Teensy 4.0) RawHID

Run serial monitor:

teensy_serialmon /sys/devices/pci0000:00/0000:00:08.1/0000:07:00.3/usb3/3-2/3-2.3/3-2.3.3