Skip to content

Commit

Permalink
support for mulitple device numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
wilderk committed Oct 7, 2024
1 parent b07d70e commit 6f9a3c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pyinstaller ./hdzero_programmer.py --onefile
#### Install the ch341 kernel driver

```
# might need to install gcc-12
# sudo apt install gcc-12
unzip ch341par_linux_V1.4_20230524.zip
cd ch341par_linux/driver
make
Expand All @@ -35,15 +37,17 @@ cd -
- Note: something similar could potentially be perform with udev rules as well.
- Plugin the hdzero-programmer dongle first (ID 1a86:5512 QinHeng Electronics CH341 in EPP/MEM/I2C mode, EPP/I2C adapter), then
```
sudo chmod 777 /dev/ch34x_pis0
# sometimes the device shows up as 0, 1, or some othter number. Chmod all of them.
sudo chmod 777 /dev/ch34x_pis*
```


#### Install python pre-requisites
```
sudo apt-get install python3 python3-tk python3-pil.imagetk python3-wget
```

#### Connect programmer to hdzero vtx

#### Linux execute
```
python3 ./hdzero_programmer.py
Expand Down
6 changes: 4 additions & 2 deletions ch341.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ctypes
import glob
import zlib
import time
import sys
Expand Down Expand Up @@ -87,8 +88,9 @@ def load(self):
print("Please check ch341 driver")

def open_device(self):
self.dll.CH34xCloseDevice(self.iIndex)
self.iIndex = self.dll.CH34xOpenDevice("/dev/ch34x_pis0".encode())
# Return first entry. The device number could be different on various systems.
device = glob.glob('/dev/ch34x_pis[0-9]*')[0]
self.iIndex = self.dll.CH34xOpenDevice(device.encode())
return self.iIndex

def close_device(self):
Expand Down

0 comments on commit 6f9a3c4

Please sign in to comment.