Jakeler / ble-serial

"RFCOMM for BLE" a UART over Bluetooth low energy (4+) bridge for Linux, Mac and Windows
https://blog.ja-ke.tech/tags/#bluetooth
MIT License
251 stars 37 forks source link

Script fails completely #87

Closed byteptr closed 10 months ago

byteptr commented 1 year ago

I have Raspberry pi with Raspbian: Linux rpi 5.10.103-v7+ #1529 SMP Tue Mar 8 12:21:37 GMT 2022 armv7l GNU/Linux And python 3.7

I installed ble-serial trying both options: Option 1: pip3 install ble-serial Option 2: git clone https://github.com/Jakeler/ble-serial.git cd ble-serial/ pip install -r requirements.txt

On both cases If I try to launch python -m ble_serial -d XX:XX:XX:XX:XX:XX I have the followong error

Traceback (most recent call last): File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/usr/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/pi/repos/ble-serial/ble_serial/main.py", line 1, in from ble_serial.main import launch File "/home/pi/repos/ble-serial/ble_serial/main.py", line 4, in from ble_serial.ports.tcp_socket import TCP_Socket File "", line 1 (host=) ^ SyntaxError: invalid syntax

I can't understand what is going wrong here, but it seems to fails because it doesn't parse correctly the command line parameters

byteptr commented 1 year ago

I even tried directly and got same error

ble-serial -d XX:XX:XX:XX:XX:XX Traceback (most recent call last): File "/usr/local/bin/ble-serial", line 5, in <module> from ble_serial.main import launch File "/usr/local/lib/python3.7/dist-packages/ble_serial/main.py", line 4, in <module> from ble_serial.ports.tcp_socket import TCP_Socket File "<fstring>", line 1 (host=) ^ SyntaxError: invalid syntax

byteptr commented 1 year ago

Hi guys, I take a look to your code, then I commented the 5th line on your file tcp_socket.py and it seems this was the culprit of crash, I'm on python 3.7 class TCP_Socket(ISerial): def __init__(self, host: str, port: int, mtu: int): logging.debug(f'{host=}:{port=}, {mtu=}') <--- Line 5 self.host = host self.port = port self.mtu = mtu self.connected = False Now it seems to work,

Jakeler commented 10 months ago

Hi @byteptr, thanks for reporting, this is actually a valid bug. ble-serial version 2.7 broke python 3.7 compatibility with the TCP modules and I forget to specify it correctly in the metadata, will raise the min. requirements in the next release. Self-documenting expressions are a python 3.8 feature. Shouldn't be a problem with lastest Raspberry Pi OS.