Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
import contextlib
import re
from asyncio import StreamReader, StreamReaderProtocol, StreamWriter
from typing import cast

import serial
import serial_asyncio
import serialx

from custom_components.meshtastic.aiomeshtastic.connection import (
ClientApiConnectionError,
Expand Down Expand Up @@ -38,7 +36,7 @@ async def _connect(self) -> None:
loop = asyncio.get_running_loop()
reader = StreamReader(loop=loop)
protocol = StreamReaderProtocol(reader, loop=loop)
transport, _ = await serial_asyncio.create_serial_connection(
transport, _ = await serialx.create_serial_connection(
loop,
lambda: protocol,
self._device,
Expand Down Expand Up @@ -86,7 +84,6 @@ async def read_log(reader: StreamReader) -> None:
async def _disconnect(self) -> None:
if self._writer:
self._writer.close()
cast("serial_asyncio.SerialTransport", self._writer.transport).serial.close()
self._writer = None
self._reader = None

Expand Down Expand Up @@ -124,7 +121,7 @@ async def _read_bytes(self, n: int = -1, *, exactly: int | None = None) -> bytes
if exactly is not None:
return await self._reader.readexactly(exactly)
return await self._reader.read(n=n)
except serial.serialutil.SerialException as e:
except (serialx.SerialException, OSError) as e:
raise SerialConnectionError from e

async def _write_bytes(self, data: bytes) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/meshtastic/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/meshtastic/home-assistant/issues",
"requirements": [
"pyserial-asyncio==0.6",
"serialx",
"aiomqtt"
],
"usb": [
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ pip>=21.3.1
ruff==0.11.8

bleak~=0.22.3
pyserial-asyncio~=0.6
serialx==1.8.0

aiomqtt>=1.2.0