From cbf6d837178ae53c06a01a55a794493e642f6574 Mon Sep 17 00:00:00 2001 From: Jeremiah K <17190268+jeremiah-k@users.noreply.github.com> Date: Thu, 3 Oct 2024 07:01:36 -0500 Subject: [PATCH 1/2] Import serial tools for port listing --- meshtastic_utils.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/meshtastic_utils.py b/meshtastic_utils.py index ec9d08d..62323aa 100644 --- a/meshtastic_utils.py +++ b/meshtastic_utils.py @@ -3,6 +3,7 @@ import threading import os import serial # For serial port exceptions +import serial.tools.list_ports # Import serial tools for port listing from typing import List import meshtastic.tcp_interface @@ -32,6 +33,19 @@ shutting_down = False reconnect_task = None # To keep track of the reconnect task +def serial_port_exists(port_name): + """ + Check if the specified serial port exists. + + Args: + port_name (str): The name of the serial port (e.g., 'COM15' or '/dev/ttyACM0'). + + Returns: + bool: True if the port exists, False otherwise. + """ + ports = [port.device for port in serial.tools.list_ports.comports()] + return port_name in ports + def connect_meshtastic(force_connect=False): """ Establish a connection to the Meshtastic device. @@ -72,7 +86,7 @@ def connect_meshtastic(force_connect=False): logger.info(f"Connecting to serial port {serial_port} ...") # Check if serial port exists - if not os.path.exists(serial_port): + if not serial_port_exists(serial_port): logger.warning(f"Serial port {serial_port} does not exist. Waiting...") time.sleep(5) attempts += 1 From 889f47cce2311add1a74e79de13a89cca3e87fb4 Mon Sep 17 00:00:00 2001 From: Jeremiah K <17190268+jeremiah-k@users.noreply.github.com> Date: Thu, 3 Oct 2024 07:19:20 -0500 Subject: [PATCH 2/2] Update main.yml to include version number in windows installer --- .github/workflows/main.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d87429a..48ea915 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,19 +22,26 @@ jobs: pip install -r requirements.txt pip install pyinstaller + - name: Get version number + id: get_version + run: echo "::set-output name=version::${GITHUB_REF##*/}" + - name: Build executable - run: pyinstaller --name=mmrelay.exe --onefile --console main.py + run: pyinstaller --name=mmrelay_${{ steps.get_version.outputs.version }}.exe --onefile --console main.py - name: Build installer uses: nadeemjazmawe/inno-setup-action-cli@v6.0.5 with: filepath: "/DAppVersion=${{ github.ref_name }} ./mmrelay.iss" + - name: Rename installer + run: ren MMRelay_setup.exe MMRelay_setup_${{ steps.get_version.outputs.version }}.exe + - name: Upload setup.exe to release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: MMRelay_setup.exe - asset_name: MMRelay_setup.exe + file: MMRelay_setup_${{ steps.get_version.outputs.version }}.exe + asset_name: MMRelay_setup_${{ steps.get_version.outputs.version }}.exe tag: ${{ github.ref }} overwrite: true