File: serial_mult.py

package info (click to toggle)
gtk-meshtastic-client 1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,040 kB
  • sloc: python: 4,759; xml: 58; makefile: 3
file content (33 lines) | stat: -rw-r--r-- 905 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""Simple program to demo how to use meshtastic library.
   To run: python examples/info.py
"""

import meshtastic
import meshtastic.serial_interface
import json
import base64



ports = meshtastic.util.findPorts(True)
#print(f"ports:{ports}")
#print(f"ports:{ports.vid}")
if len(ports) == 0:
    print("No Serial Meshtastic device detected, attempting TCP connection on localhost.")
elif len(ports) > 1:
    message = "Warning: Multiple serial ports were detected so one serial port must be specified with the '--port'.\n"
    message += f"  Ports detected:{ports}"


for port in ports:
    print(port)

interface = meshtastic.serial_interface.SerialInterface(ports[0])


# call showInfo() just to ensure values are populated
print(interface.myInfo)
print(interface.metadata)
#print(json.dumps(interface.nodesByNum, indent=2))
#interface = meshtastic.serial_interface.SerialInterface()
interface.close()