Skip to content

Commit cf0f1db

Browse files
committed
Show an error when libusb cannot be loaded
1 parent cb7a42e commit cf0f1db

File tree

8 files changed

+525
-9
lines changed

8 files changed

+525
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Supported operating systems : macOS, Windows, Linux (incl. Raspberry Pi), basica
1919
| ✅ Turing Smart Screen / TURZX |
2020
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
2121
| <img src="res/docs/turing.webp" width="30%" height="30%"/> <img src="res/docs/turing46inch.png" width="30%" height="30%"/> <img src="res/docs/turing5inch.png" width="30%" height="30%"/> <br/> <img src="res/docs/turing2inch.webp" width="30%" height="30%"/> <img src="res/docs/turing8inch.png" width="30%" height="30%"/> <img src="res/docs/turing8inch.webp" width="30%" height="30%"/> |
22-
| All available sizes and hardware revisions supported: **2.1" / 2.8" / 3.5" / 4.6" / 5" / 5.2" / 8.0" / 8.8" / 9.2" / 12.3"** <br/>UART and WinUSB protocols supported. Note: no video or storage support for now |
22+
| All available sizes and hardware revisions supported: **2.1" / 2.8" / 3.5" / 4.6" / 5" / 5.2" / 8.0" / 8.8" / 9.2" / 12.3"** <br/>UART and USB protocols supported. Note: no video or storage support for now |
2323

2424
| ✅ XuanFang 3.5" |[UsbPCMonitor 3.5" / 5"](https://aliexpress.com/item/1005003931363455.html) | ✅ Kipye Qiye Smart Display 3.5" |
2525
|---------------------------------------------------|-----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|

external/libusb-1.0/COPYING

Lines changed: 504 additions & 0 deletions
Large diffs are not rendered by default.

external/libusb-1.0/libusb-1.0.dll

155 KB
Binary file not shown.

library/lcd/lcd_comm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ def DisplayText(
257257
font_color = parse_color(font_color)
258258
background_color = parse_color(background_color)
259259

260-
assert x <= self.get_width(), 'Text X coordinate ' + str(x) + ' must be <= display width ' + str(
260+
assert x <= self.get_width(), 'Text "' + text + '" X coordinate ' + str(x) + ' must be <= display width ' + str(
261261
self.get_width())
262-
assert y <= self.get_height(), 'Text Y coordinate ' + str(y) + ' must be <= display height ' + str(
262+
assert y <= self.get_height(), 'Text "' + text + '" Y coordinate ' + str(y) + ' must be <= display height ' + str(
263263
self.get_height())
264264
assert len(text) > 0, 'Text must not be empty'
265265
assert font_size > 0, "Font size must be > 0"

library/lcd/lcd_comm_turing_usb.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import shutil
2525
import struct
2626
import subprocess
27+
import sys
2728
import time
2829
from io import BytesIO
2930
from pathlib import Path
@@ -41,7 +42,7 @@
4142

4243
# Map of display supported product IDs and their respective resolution in portrait mode
4344
PRODUCT_ID = {0x0046: (320, 960), # Turing 4.6"
44-
0x0052: (720, 1280), # Turing 5.2"
45+
0x0050: (720, 1280), # Turing 5.2"
4546
0x0080: (800, 1280), # Turing 8.0"
4647
0x0088: (480, 1920), # Turing 8.8"
4748
0x0092: (462, 1920), # Turing 9.2"
@@ -461,7 +462,19 @@ def find_usb_device():
461462
dev = None
462463
dev_pid = None
463464
for pid in PRODUCT_ID.keys():
464-
dev = usb.core.find(idVendor=VENDOR_ID, idProduct=pid)
465+
try:
466+
dev = usb.core.find(idVendor=VENDOR_ID, idProduct=pid)
467+
except usb.core.NoBackendError as e:
468+
print("""[ERROR] %s: libusb could not be loaded from your system. Make sure it is installed.
469+
On Linux and BSD, these will generally be available on the distribution's official repositories.
470+
On macOS, libusb 1.0 can easily be installed through Homebrew: brew install libusb
471+
On Windows, manually copy 'external/libusb-1.0/libusb-1.0.dll' to C:\\Windows\\System32""" % str(
472+
e))
473+
try:
474+
sys.exit(0)
475+
except:
476+
os._exit(0)
477+
465478
dev_pid = pid
466479
if dev is not None:
467480
break

main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from library.pythoncheck import check_python_version
3030
check_python_version()
3131

32-
import glob
3332
import os
3433
import sys
3534

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ tkinter-tooltip~=3.1.2 # Tooltips for configuration editor
1010
uptime~=3.0.1 # For System Uptime
1111
ping3~=5.1.5 # ICMP ping implementation using raw socket
1212
pyinstaller~=6.19.0 # bundles a Python application and all its dependencies into a single package
13-
pyusb~=1.3.1
14-
pycryptodome~=3.23.0
13+
pyusb~=1.3.1 # For TURZX USB models: communicate directly through USB
14+
pycryptodome~=3.23.0 # For TURZX USB models: decrypt/encrypt frames using DES
1515

1616
# HTTP library
1717
requests~=2.32.5; python_version < "3.10"

tools/windows-installer/turing-system-monitor.iss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ begin
127127
'If you do not install it, some hardware metrics such as clocks, temperatures, etc. will be limited or unavailable.' + #13#10 +
128128
'More information: https://pawnio.eu/';
129129
130-
{ Création de la case à cocher }
130+
{ Checkbox creation }
131131
InstallPawnIOCheckBox := TNewCheckBox.Create(PagePawnIO);
132132
InstallPawnIOCheckBox.Parent := PagePawnIO.Surface;
133133
InstallPawnIOCheckBox.Caption := 'Install / update PawnIO driver (admin. rights needed)';

0 commit comments

Comments
 (0)