feetech-cli 0.1.7__tar.gz → 0.1.8__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.
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/PKG-INFO +1 -1
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/feetech_cli/__init__.py +1 -1
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/feetech_cli/controller.py +5 -1
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/feetech_cli.egg-info/PKG-INFO +1 -1
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/pyproject.toml +1 -1
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/tests/test_cli.py +2 -1
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/tests/test_controller.py +30 -0
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/tests/test_devices.py +2 -1
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/LICENSE +0 -0
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/README.md +0 -0
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/feetech_cli/cli.py +0 -0
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/feetech_cli/devices.py +0 -0
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/feetech_cli/protocol.py +0 -0
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/feetech_cli/registers.py +0 -0
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/feetech_cli/simulator.py +0 -0
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/feetech_cli/tui.py +0 -0
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/feetech_cli.egg-info/SOURCES.txt +0 -0
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/feetech_cli.egg-info/dependency_links.txt +0 -0
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/feetech_cli.egg-info/entry_points.txt +0 -0
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/feetech_cli.egg-info/requires.txt +0 -0
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/feetech_cli.egg-info/top_level.txt +0 -0
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/setup.cfg +0 -0
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/tests/test_protocol.py +0 -0
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/tests/test_registers.py +0 -0
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/tests/test_terminal.py +0 -0
- {feetech_cli-0.1.7 → feetech_cli-0.1.8}/tests/test_tui.py +0 -0
|
@@ -240,7 +240,11 @@ class FeetechServoController:
|
|
|
240
240
|
Bus speed.
|
|
241
241
|
"""
|
|
242
242
|
self.close()
|
|
243
|
-
|
|
243
|
+
# Two processes on one bus steal each other's replies; refuse to share
|
|
244
|
+
# the port (a flock on POSIX, which is what a second open hits).
|
|
245
|
+
self.serial = serial.Serial(
|
|
246
|
+
device, baudrate, timeout=self.timeout, exclusive=True
|
|
247
|
+
)
|
|
244
248
|
self.baudrate = baudrate
|
|
245
249
|
self.packet_handler = PacketHandler(
|
|
246
250
|
self.serial, little_endian=self.little_endian
|
|
@@ -22,11 +22,12 @@ def bus(monkeypatch):
|
|
|
22
22
|
servos = [FakeServo(1), FakeServo(4)]
|
|
23
23
|
fake = FakeBus(servos)
|
|
24
24
|
|
|
25
|
-
def fake_serial(device, baudrate, timeout=None):
|
|
25
|
+
def fake_serial(device, baudrate, timeout=None, exclusive=None):
|
|
26
26
|
"""Hand back the same bus whatever device is opened."""
|
|
27
27
|
fake.port = device
|
|
28
28
|
fake.baudrate = baudrate
|
|
29
29
|
fake.timeout = timeout
|
|
30
|
+
fake.exclusive = exclusive
|
|
30
31
|
fake.is_open = True
|
|
31
32
|
fake.rx = bytearray()
|
|
32
33
|
return fake
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"""Tests for the high level controller against a simulated bus."""
|
|
2
2
|
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
|
|
3
6
|
import pytest
|
|
4
7
|
from fake_servo import FakeBus
|
|
5
8
|
from fake_servo import FakeServo
|
|
6
9
|
|
|
7
10
|
from feetech_cli.controller import FeetechServoController
|
|
11
|
+
from feetech_cli.controller import PortNotFoundError
|
|
8
12
|
from feetech_cli.protocol import FeetechError
|
|
9
13
|
from feetech_cli.registers import BAUDRATE_INDEX
|
|
10
14
|
|
|
@@ -360,3 +364,29 @@ def test_sync_write_rejects_ragged_entries():
|
|
|
360
364
|
controller, _ = make_controller([FakeServo(1)])
|
|
361
365
|
with pytest.raises(ValueError, match="same length"):
|
|
362
366
|
controller.packet_handler.sync_write(42, [(1, [0, 0]), (2, [0])])
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
@pytest.mark.skipif(sys.platform == "win32", reason="needs a POSIX pty")
|
|
370
|
+
def test_open_refuses_a_port_another_controller_holds():
|
|
371
|
+
master, slave = os.openpty()
|
|
372
|
+
device = os.ttyname(slave)
|
|
373
|
+
# A standard speed: macOS sets others through an ioctl a pty refuses.
|
|
374
|
+
first = FeetechServoController(port=device, baudrate=115200, max_id=1)
|
|
375
|
+
second = FeetechServoController(port=device, baudrate=115200, max_id=1)
|
|
376
|
+
try:
|
|
377
|
+
# Open without scanning: nothing written to the pty, so closing it
|
|
378
|
+
# never waits on output no one reads.
|
|
379
|
+
first._open_port(device, 115200)
|
|
380
|
+
# A refused open sends nothing before it fails.
|
|
381
|
+
with pytest.raises(PortNotFoundError, match="could not open"):
|
|
382
|
+
second.open(require_servo=False)
|
|
383
|
+
assert not second.is_open
|
|
384
|
+
first.close()
|
|
385
|
+
# Released on close, so the next process gets the port.
|
|
386
|
+
second._open_port(device, 115200)
|
|
387
|
+
assert second.is_open
|
|
388
|
+
finally:
|
|
389
|
+
first.close()
|
|
390
|
+
second.close()
|
|
391
|
+
os.close(master)
|
|
392
|
+
os.close(slave)
|
|
@@ -349,11 +349,12 @@ def mixed_bus(monkeypatch, profile):
|
|
|
349
349
|
"""A servo and the example board behind a patched :class:`serial.Serial`."""
|
|
350
350
|
fake = FakeBus([FakeServo(1), make_board(profile)])
|
|
351
351
|
|
|
352
|
-
def fake_serial(device, baudrate, timeout=None):
|
|
352
|
+
def fake_serial(device, baudrate, timeout=None, exclusive=None):
|
|
353
353
|
"""Hand back the same bus whatever device is opened."""
|
|
354
354
|
fake.port = device
|
|
355
355
|
fake.baudrate = baudrate
|
|
356
356
|
fake.timeout = timeout
|
|
357
|
+
fake.exclusive = exclusive
|
|
357
358
|
fake.is_open = True
|
|
358
359
|
fake.rx = bytearray()
|
|
359
360
|
return fake
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|