sdwire 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sdwire-0.2.0 → sdwire-0.2.2}/PKG-INFO +17 -2
- {sdwire-0.2.0 → sdwire-0.2.2}/README.md +15 -0
- {sdwire-0.2.0 → sdwire-0.2.2}/pyproject.toml +2 -2
- {sdwire-0.2.0 → sdwire-0.2.2}/sdwire/backend/detect.py +30 -9
- sdwire-0.2.2/sdwire/backend/device/sdwire.py +40 -0
- {sdwire-0.2.0 → sdwire-0.2.2}/sdwire/backend/utils.py +2 -8
- {sdwire-0.2.0 → sdwire-0.2.2}/sdwire/constants.py +2 -2
- sdwire-0.2.0/sdwire/backend/device/sdwire.py +0 -25
- {sdwire-0.2.0 → sdwire-0.2.2}/LICENSE +0 -0
- {sdwire-0.2.0 → sdwire-0.2.2}/sdwire/__init__.py +0 -0
- {sdwire-0.2.0 → sdwire-0.2.2}/sdwire/backend/__init__.py +0 -0
- {sdwire-0.2.0 → sdwire-0.2.2}/sdwire/backend/device/sdwirec.py +0 -0
- {sdwire-0.2.0 → sdwire-0.2.2}/sdwire/backend/device/usb_device.py +0 -0
- {sdwire-0.2.0 → sdwire-0.2.2}/sdwire/main.py +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: sdwire
|
3
|
-
Version: 0.2.
|
4
|
-
Summary: CLI application to interact with Badgerd SDWire
|
3
|
+
Version: 0.2.2
|
4
|
+
Summary: CLI application to interact with Badgerd SDWire devices
|
5
5
|
License: GPL-3
|
6
6
|
Author: Talha Can Havadar
|
7
7
|
Author-email: havadartalha@gmail.com
|
@@ -56,6 +56,21 @@ Commands:
|
|
56
56
|
ts ts/host => connects the sdcard interface to host machine
|
57
57
|
```
|
58
58
|
|
59
|
+
## Installing
|
60
|
+
|
61
|
+
Using pip
|
62
|
+
|
63
|
+
```
|
64
|
+
pip install sdwire
|
65
|
+
```
|
66
|
+
|
67
|
+
Using apt
|
68
|
+
|
69
|
+
```
|
70
|
+
sudo add-apt-repository ppa:tchavadar/badgerd
|
71
|
+
sudo apt install python3-sdwire
|
72
|
+
```
|
73
|
+
|
59
74
|
## Listing SDWire Devices
|
60
75
|
|
61
76
|
`sdwire list` command will search through usb devices connected to the system
|
@@ -38,6 +38,21 @@ Commands:
|
|
38
38
|
ts ts/host => connects the sdcard interface to host machine
|
39
39
|
```
|
40
40
|
|
41
|
+
## Installing
|
42
|
+
|
43
|
+
Using pip
|
44
|
+
|
45
|
+
```
|
46
|
+
pip install sdwire
|
47
|
+
```
|
48
|
+
|
49
|
+
Using apt
|
50
|
+
|
51
|
+
```
|
52
|
+
sudo add-apt-repository ppa:tchavadar/badgerd
|
53
|
+
sudo apt install python3-sdwire
|
54
|
+
```
|
55
|
+
|
41
56
|
## Listing SDWire Devices
|
42
57
|
|
43
58
|
`sdwire list` command will search through usb devices connected to the system
|
@@ -1,7 +1,7 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "sdwire"
|
3
|
-
version = "0.2.
|
4
|
-
description = "CLI application to interact with Badgerd SDWire
|
3
|
+
version = "0.2.2"
|
4
|
+
description = "CLI application to interact with Badgerd SDWire devices"
|
5
5
|
authors = ["Talha Can Havadar <havadartalha@gmail.com>"]
|
6
6
|
license = "GPL-3"
|
7
7
|
readme = "README.md"
|
@@ -4,7 +4,7 @@ from adafruit_board_toolkit import circuitpython_serial as cpserial
|
|
4
4
|
from serial.tools.list_ports_common import ListPortInfo
|
5
5
|
|
6
6
|
from sdwire import constants
|
7
|
-
from .device.sdwire import SDWire
|
7
|
+
from .device.sdwire import SDWire, SDWIRE_GENERATION_SDWIRE3
|
8
8
|
from .device.sdwirec import SDWireC
|
9
9
|
from .device.usb_device import PortInfo
|
10
10
|
|
@@ -46,20 +46,41 @@ def get_sdwirec_devices() -> List[SDWireC]:
|
|
46
46
|
|
47
47
|
|
48
48
|
def get_sdwire_devices() -> List[SDWire]:
|
49
|
-
ports = cpserial.data_comports()
|
50
49
|
|
51
|
-
# Badgerd
|
52
|
-
# VID =
|
50
|
+
# Badgerd SDWire3
|
51
|
+
# VID = 0bda PID = 0316
|
53
52
|
# Badgerd SDWireC
|
54
53
|
# VID = 0x04e8 PID = 0x6001
|
55
54
|
result = []
|
56
|
-
|
57
|
-
|
55
|
+
devices: List[Device] = usb.core.find(find_all=True)
|
56
|
+
if not devices:
|
57
|
+
log.info("no usb devices found while searching for SDWire..")
|
58
|
+
return []
|
59
|
+
|
60
|
+
device_list = []
|
61
|
+
for device in devices:
|
62
|
+
product = None
|
63
|
+
serial = None
|
64
|
+
manufacturer = None
|
65
|
+
try:
|
66
|
+
product = device.idProduct
|
67
|
+
vendor = device.idVendor
|
68
|
+
serial = (
|
69
|
+
usb.util.get_string(device, device.iSerialNumber, None)
|
70
|
+
+ f"{device.bus}{device.port_number}"
|
71
|
+
)
|
72
|
+
manufacturer = device.manufacturer
|
73
|
+
except Exception as e:
|
74
|
+
log.debug(
|
75
|
+
"not able to get usb product, serial_number and manufacturer information, err: %s",
|
76
|
+
e,
|
77
|
+
)
|
78
|
+
|
79
|
+
if product == constants.SDWIRE3_PID and vendor == constants.SDWIRE3_VID:
|
58
80
|
result.append(
|
59
81
|
SDWire(
|
60
|
-
port_info=PortInfo(
|
61
|
-
|
62
|
-
)
|
82
|
+
port_info=PortInfo(device, product, vendor, serial, device),
|
83
|
+
generation=SDWIRE_GENERATION_SDWIRE3,
|
63
84
|
)
|
64
85
|
)
|
65
86
|
# Search for legacy SDWireC devices
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import logging
|
2
|
+
from serial import Serial
|
3
|
+
from .usb_device import USBDevice, PortInfo
|
4
|
+
|
5
|
+
log = logging.getLogger(__name__)
|
6
|
+
|
7
|
+
SDWIRE_GENERATION_SDWIRE3 = 2
|
8
|
+
|
9
|
+
|
10
|
+
class SDWire(USBDevice):
|
11
|
+
|
12
|
+
def __init__(self, port_info: PortInfo, generation: int):
|
13
|
+
super().__init__(port_info)
|
14
|
+
self.generation = generation
|
15
|
+
|
16
|
+
def switch_ts(self):
|
17
|
+
try:
|
18
|
+
self.usb_device.attach_kernel_driver(0)
|
19
|
+
self.usb_device.reset()
|
20
|
+
except Exception as e:
|
21
|
+
log.debug(
|
22
|
+
"not able to switch to ts mode. Device might be already in ts mode, err: %s",
|
23
|
+
e,
|
24
|
+
)
|
25
|
+
|
26
|
+
def switch_dut(self):
|
27
|
+
try:
|
28
|
+
self.usb_device.detach_kernel_driver(0)
|
29
|
+
self.usb_device.reset()
|
30
|
+
except Exception as e:
|
31
|
+
log.debug(
|
32
|
+
"not able to switch to dut mode. Device might be already in dut mode, err: %s",
|
33
|
+
e,
|
34
|
+
)
|
35
|
+
|
36
|
+
def __str__(self):
|
37
|
+
return f"{self.serial_string}\t[{int(self.manufacturer_string):04x}::{int(self.product_string):04x}]"
|
38
|
+
|
39
|
+
def __repr__(self):
|
40
|
+
return self.__str__()
|
@@ -10,14 +10,12 @@ log = logging.getLogger(__name__)
|
|
10
10
|
|
11
11
|
def handle_switch_host_command(ctx):
|
12
12
|
device = ctx.obj["device"]
|
13
|
-
|
14
|
-
device.switch_ts()
|
13
|
+
device.switch_ts()
|
15
14
|
|
16
15
|
|
17
16
|
def handle_switch_target_command(ctx):
|
18
17
|
device = ctx.obj["device"]
|
19
|
-
|
20
|
-
device.switch_dut()
|
18
|
+
device.switch_dut()
|
21
19
|
|
22
20
|
|
23
21
|
def handle_switch_off_command(ctx):
|
@@ -50,7 +48,3 @@ def handle_switch_command(ctx, serial):
|
|
50
48
|
raise click.UsageError(
|
51
49
|
f"There is no such sdwire device connected with serial={serial}"
|
52
50
|
)
|
53
|
-
|
54
|
-
device = ctx.obj["device"]
|
55
|
-
if isinstance(device, SDWire):
|
56
|
-
device.invoke(" ".join(sys.argv[1:]))
|
@@ -1,25 +0,0 @@
|
|
1
|
-
from serial import Serial
|
2
|
-
from .usb_device import USBDevice, PortInfo
|
3
|
-
|
4
|
-
|
5
|
-
class SDWire(USBDevice):
|
6
|
-
|
7
|
-
def __init__(self, port_info: PortInfo):
|
8
|
-
super().__init__(port_info)
|
9
|
-
|
10
|
-
@property
|
11
|
-
def serial_string(self) -> str:
|
12
|
-
return "sdwire_gen2_101"
|
13
|
-
|
14
|
-
def invoke(self, command: str) -> None:
|
15
|
-
with Serial(self.dev_string) as channel:
|
16
|
-
channel.timeout = 0.05
|
17
|
-
data = command.encode() + b"\n"
|
18
|
-
print(f"data={data}")
|
19
|
-
channel.write(data)
|
20
|
-
|
21
|
-
def __str__(self):
|
22
|
-
return f"{self.serial_string}\t\t[{self.product_string}::{self.manufacturer_string}]"
|
23
|
-
|
24
|
-
def __repr__(self):
|
25
|
-
return self.__str__()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|