Can not run python scripts when multiple T-beams are connected to a laptop

Hello everyone,
I am trying to get a hang of the python API. For this I am trying to run a simple python script to send a message from one T-Beam V1.1 to another T-Beam V1.1. However, when I run the script I get a warning.

Warning: Multiple serial ports were detected so one serial port must be specified with the ‘–port’.
Ports detected:[‘COM3’, ‘COM4’]

I get this because both the T-beams are connected to the same laptop. So I run the script with the argument “–port COM3” but I get the same message again.

This is the code I am trying to run.

#pylint: skip-file
import meshtastic.serial_interface
interface = (
meshtastic.serial_interface.SerialInterface()
)
interface.sendText(“hello from a202”)
interface.close()

Is there a way to circumvent this obstacle?
One thing that I have tried is to add a “devPath” “interface”

I’d expect this to work:

import meshtastic.serial_interface;
# Change COM3 to COM4 for your second instance
interface = meshtastic.serial_interface.SerialInterface(devPath="COM3");
interface.sendText("hello from a202");
interface.close()

The --port switch is intended for the meshtastic command; the warning message should probably be moved to __main__.py as part of refactoring, as it is misleading when it’s inside serial_interface.py.

Thanks! That actually worked. I stupidly added the devPath as /tty/USB0 instead of COM ports.

Glad I could help! :slight_smile: