parent
3f267f5c34
commit
13abcb5b8d
@ -0,0 +1,65 @@
|
||||
# Unit-Data Slot Hold
|
||||
|
||||
Unit-data slot protection is enabled by default for every `MODE: MASTER`
|
||||
section. It can also be set explicitly in the FreeDMR configuration:
|
||||
|
||||
```ini
|
||||
UNIT_DATA_HOLD: True
|
||||
```
|
||||
|
||||
Existing configurations that omit this setting enable the hold on upgrade.
|
||||
Set `UNIT_DATA_HOLD: False` to restore the previous admission behaviour.
|
||||
The setting applies independently to both slots of that master, not to the
|
||||
whole server or mesh. In a worker deployment, configure the receiving HBP
|
||||
worker's master section.
|
||||
|
||||
Existing voice activity and voice hangtime checks still determine whether unit
|
||||
data may start. An admitted outbound unit-data burst, including a preamble,
|
||||
holds its destination slot for its ordered source/destination DMR-ID pair for
|
||||
five seconds. Each further admitted burst for that pair refreshes the hold.
|
||||
Stream IDs do not identify ownership, and packet contents are not reassembled
|
||||
or changed by the hold. This applies to unit data generally, including SMS,
|
||||
not exclusively to IP service 5005.
|
||||
|
||||
During the hold, competing network voice, generated prompts/beacons and unit
|
||||
data for other pairs are suppressed on that slot. An already-active generated
|
||||
prompt prevents a new data hold. Suppressed prompts are cancelled, not queued
|
||||
for replay. After five seconds without admitted data, normal admission resumes
|
||||
without waiting for a background cleanup task. Continuous data can retain the
|
||||
slot indefinitely; there is no fairness or packet-count limit in this version.
|
||||
|
||||
This is server-side outbound protection, not an RF reservation or a
|
||||
bidirectional session lock. It does not stop an RF station transmitting, measure
|
||||
modem buffering, queue busy-dropped packets, add
|
||||
retries, or contain IP traffic to the local server. The hold expires from the
|
||||
last network submission, not measured RF completion. Disable it where these
|
||||
trade-offs are inappropriate for the particular access master.
|
||||
|
||||
## Gateway Request To Send
|
||||
|
||||
The enabled, authenticated `DATA-GATEWAY` FBP5 relationship can request a
|
||||
provisional hold using `BCRQ`; `BCTS` replies with granted, busy, no local route
|
||||
or denied. Ordinary mesh relationships cannot request holds. The new controls
|
||||
use a 16-byte keyed BLAKE2b tag; existing FBCP controls are unchanged.
|
||||
|
||||
The worker resolves the local destination through its subscriber map or an
|
||||
unambiguous connected-hotspot match. A grant reserves that slot for 500ms for
|
||||
the requesting relationship and ordered source/destination pair. The first
|
||||
matching admitted burst promotes it to the five-second hold above. With no
|
||||
packet, it expires automatically. Existing voice/hangtime and prompt checks
|
||||
still apply, and `UNIT_DATA_HOLD: False` denies requests for that master.
|
||||
|
||||
Duplicate request IDs return the original result and remaining window, not a
|
||||
renewed hold. Changed addresses under the same ID are denied. New request IDs
|
||||
also cannot prolong an unused hold. The cache holds at most 256 requests for
|
||||
30 seconds per Gateway relationship. It is a bounded duplicate cache, not
|
||||
cryptographic replay protection across that window or a process restart.
|
||||
|
||||
The sender must correlate the reply, allow for round-trip latency, and start
|
||||
within its remaining budget. A grant is not an RF lock or delivery receipt:
|
||||
new RF activity or a changed route can still prevent admission. There is no
|
||||
cancel, packet-count fairness, new DMR field or mesh-wide reservation. Ordinary
|
||||
unreserved SMS/data remains supported. The experimental Gateway IP sender uses
|
||||
the new exchange. Gateway SMS can opt in with `FREEDMR_GATEWAY_SMS_ADMISSION=true`;
|
||||
its default remains off for compatibility with older workers. Opt-in clients
|
||||
must understand the Gateway API's `queued` state before transport submission.
|
||||
@ -0,0 +1,140 @@
|
||||
"""Dedicated-link admission controls through real receive/routing handlers."""
|
||||
from hashlib import blake2b
|
||||
from dataclasses import replace
|
||||
import unittest
|
||||
|
||||
from tests.harness.deterministic import (
|
||||
DeterministicScenario, PacketSpec, minimal_config, add_openbridge_system,
|
||||
active_bridge, bytes_3, HBPF_DATA_SYNC, HBPF_VOICE,
|
||||
)
|
||||
|
||||
|
||||
class GatewayAdmissionTests(unittest.TestCase):
|
||||
def scenario(self, slot=2):
|
||||
config = minimal_config(("MASTER-A", "MASTER-B"))
|
||||
config['GLOBAL']['DATA_GATEWAY'] = True
|
||||
for name in ('DATA-GATEWAY', 'OBP-1'):
|
||||
add_openbridge_system(config, name, network_id=3001)
|
||||
config['SYSTEMS'][name]['ENHANCED_OBP'] = True
|
||||
return DeterministicScenario(config=config, bridges=active_bridge(
|
||||
'91', 91, (('MASTER-A', slot), ('MASTER-B', slot), ('OBP-1', 1))))
|
||||
|
||||
def prepare(self, s, slot=2):
|
||||
s.clock.advance(10)
|
||||
s.register_peer('MASTER-B', 123456701)
|
||||
s.bm.SUB_MAP[bytes_3(1234567)] = ('MASTER-B', slot, s.clock.time())
|
||||
|
||||
def wire(self, s, request=1, source=5005, destination=1234567, system='DATA-GATEWAY'):
|
||||
body = b'BCRQ' + request.to_bytes(4, 'big') + bytes_3(source) + bytes_3(destination)
|
||||
return body + blake2b(body, key=s.config['SYSTEMS'][system]['PASSPHRASE'], digest_size=16).digest()
|
||||
|
||||
def request(self, s, **kwargs):
|
||||
config = s.config['SYSTEMS']['DATA-GATEWAY']
|
||||
s.inject_datagram('DATA-GATEWAY', self.wire(s, **kwargs), config['TARGET_SOCK'])
|
||||
packet, address = s.transports['DATA-GATEWAY'].writes[-1]
|
||||
self.assertEqual(address, config['TARGET_SOCK'])
|
||||
self.assertEqual(len(packet), 27)
|
||||
self.assertEqual(packet[:4], b'BCTS')
|
||||
self.assertEqual(packet[-16:], blake2b(packet[:-16], key=config['PASSPHRASE'], digest_size=16).digest())
|
||||
return packet[8], int.from_bytes(packet[9:11], 'big')
|
||||
|
||||
def test_grant_holds_voice_and_expires_without_a_packet(self):
|
||||
for slot in (1, 2):
|
||||
with self.subTest(slot=slot), self.scenario(slot) as s:
|
||||
self.prepare(s, slot)
|
||||
self.assertEqual(self.request(s), (0, 500))
|
||||
voice = PacketSpec(rf_src=3120001, dst_id=91, slot=1,
|
||||
stream_id=100, frame_type=HBPF_VOICE, dtype_vseq=1)
|
||||
s.inject_obp('OBP-1', voice)
|
||||
self.assertFalse(s.capture.for_system('MASTER-B'))
|
||||
s.clock.advance(.5)
|
||||
s.inject_obp('OBP-1', replace(voice, seq=2, stream_id=101))
|
||||
self.assertEqual(len(s.capture.for_system('MASTER-B')), 1)
|
||||
|
||||
def test_duplicate_and_new_requests_cannot_renew_unused_hold(self):
|
||||
with self.scenario() as s:
|
||||
self.prepare(s)
|
||||
self.assertEqual(self.request(s), (0, 500))
|
||||
slot = s.systems['MASTER-B'].STATUS[2]
|
||||
expiry = slot['TX_UNIT_DATA_HOLD'][2]
|
||||
s.clock.advance(.25)
|
||||
self.assertEqual(self.request(s), (0, 250))
|
||||
self.assertEqual(self.request(s, request=2), (0, 250))
|
||||
self.assertEqual(slot['TX_UNIT_DATA_HOLD'][2], expiry)
|
||||
self.assertEqual(self.request(s, source=5006), (3, 0))
|
||||
self.assertEqual(self.request(s, request=3, source=5006), (1, 0))
|
||||
s.clock.advance(.25)
|
||||
self.assertEqual(self.request(s), (0, 0))
|
||||
self.assertEqual(self.request(s, request=4), (0, 500))
|
||||
|
||||
def test_matching_data_promotes_hold_but_other_relationship_cannot(self):
|
||||
with self.scenario() as s:
|
||||
self.prepare(s)
|
||||
self.request(s)
|
||||
packet = PacketSpec(rf_src=5005, dst_id=1234567, slot=1,
|
||||
call_type='unit', frame_type=HBPF_DATA_SYNC, dtype_vseq=6)
|
||||
s.inject_obp('OBP-1', packet)
|
||||
self.assertFalse(s.capture.for_system('MASTER-B'))
|
||||
s.clock.advance(.2)
|
||||
s.inject_obp('DATA-GATEWAY', replace(packet, seq=2, stream_id=102))
|
||||
self.assertEqual(len(s.capture.for_system('MASTER-B')), 1)
|
||||
slot = s.systems['MASTER-B'].STATUS[2]
|
||||
self.assertAlmostEqual(slot['TX_UNIT_DATA_HOLD'][2], s.clock.time() + 5)
|
||||
s.inject_obp('OBP-1', replace(packet, seq=3, stream_id=103))
|
||||
self.assertEqual(len(s.capture.for_system('MASTER-B')), 1)
|
||||
|
||||
def test_busy_disabled_denied_and_missing_routes(self):
|
||||
for reason in ('rx', 'tx', 'hangtime', 'prompt', 'disabled', 'acl', 'route', 'peer'):
|
||||
with self.subTest(reason=reason), self.scenario() as s:
|
||||
self.prepare(s)
|
||||
status = s.systems['MASTER-B'].STATUS[2]
|
||||
expected = 1
|
||||
if reason == 'rx': status['RX_TYPE'] = 1
|
||||
if reason == 'tx': status['TX_TYPE'] = 1
|
||||
if reason == 'hangtime': status['TX_TIME'] = s.clock.time()
|
||||
if reason == 'prompt': status['TX_PROMPT_ACTIVE'] = True
|
||||
if reason == 'disabled':
|
||||
s.config['SYSTEMS']['MASTER-B']['UNIT_DATA_HOLD'] = False
|
||||
expected = 3
|
||||
if reason == 'acl':
|
||||
s.config['GLOBAL']['USE_ACL'] = True
|
||||
s.config['GLOBAL']['SUB_ACL'] = (False, [(5005, 5005)])
|
||||
expected = 3
|
||||
if reason == 'route':
|
||||
s.bm.SUB_MAP.clear()
|
||||
s.config['SYSTEMS']['MASTER-B']['PEERS'].clear()
|
||||
expected = 2
|
||||
if reason == 'peer':
|
||||
s.config['SYSTEMS']['MASTER-B']['PEERS'].clear()
|
||||
expected = 2
|
||||
self.assertEqual(self.request(s), (expected, 0))
|
||||
self.assertNotIn('TX_UNIT_DATA_HOLD', status)
|
||||
|
||||
def test_untrusted_controls_are_silent_and_do_not_reserve(self):
|
||||
for reason in ('mesh', 'endpoint', 'digest', 'short', 'long', 'zero', 'version', 'disabled'):
|
||||
with self.subTest(reason=reason), self.scenario() as s:
|
||||
self.prepare(s)
|
||||
system = 'OBP-1' if reason == 'mesh' else 'DATA-GATEWAY'
|
||||
config = s.config['SYSTEMS'][system]
|
||||
address = config['TARGET_SOCK']
|
||||
wire = self.wire(s, source=0 if reason == 'zero' else 5005, system=system)
|
||||
if reason == 'endpoint': address = ('192.0.2.3', 62031)
|
||||
if reason == 'digest': wire = wire[:-1] + bytes((wire[-1] ^ 1,))
|
||||
if reason == 'short': wire = wire[:-1]
|
||||
if reason == 'long': wire += b'\0'
|
||||
if reason == 'version': config['VER'] = 1
|
||||
if reason == 'disabled': config['ENABLED'] = False
|
||||
s.inject_datagram(system, wire, address)
|
||||
self.assertFalse(s.transports[system].writes)
|
||||
self.assertNotIn('TX_UNIT_DATA_HOLD', s.systems['MASTER-B'].STATUS[2])
|
||||
|
||||
def test_cache_is_bounded_and_ages_out(self):
|
||||
with self.scenario() as s:
|
||||
self.prepare(s)
|
||||
for request in range(256):
|
||||
self.request(s, request=request)
|
||||
self.assertEqual(self.request(s, request=256), (1, 0))
|
||||
self.assertEqual(len(s.systems['DATA-GATEWAY']._admission_requests), 256)
|
||||
s.clock.advance(30)
|
||||
self.assertEqual(self.request(s, request=256), (0, 500))
|
||||
self.assertEqual(len(s.systems['DATA-GATEWAY']._admission_requests), 1)
|
||||
@ -0,0 +1,219 @@
|
||||
"""Slot-local unit-data holds through the real routing handlers."""
|
||||
import os
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
import config as freedmr_config
|
||||
from tests.harness.deterministic import (
|
||||
DeterministicScenario, PacketSpec, minimal_config, add_openbridge_system,
|
||||
active_bridge, bytes_3, HBPF_DATA_SYNC, HBPF_VOICE, HBPF_SLT_VTERM,
|
||||
)
|
||||
|
||||
|
||||
class UnitDataHoldTests(unittest.TestCase):
|
||||
def scenario(self, enabled=True, slot=2):
|
||||
config = minimal_config(("MASTER-A", "MASTER-B"))
|
||||
config["SYSTEMS"]["MASTER-B"]["UNIT_DATA_HOLD"] = enabled
|
||||
add_openbridge_system(config, "OBP-1", network_id=3001)
|
||||
bridges = active_bridge("91", 91, (
|
||||
("MASTER-A", slot), ("MASTER-B", slot), ("OBP-1", 1),
|
||||
))
|
||||
return DeterministicScenario(config=config, bridges=bridges)
|
||||
|
||||
def prepare(self, scenario, slot=2):
|
||||
scenario.clock.advance(10)
|
||||
scenario.bm.SUB_MAP[bytes_3(1234567)] = ("MASTER-B", slot, scenario.clock.time())
|
||||
scenario.bm.SUB_MAP[bytes_3(1234568)] = ("MASTER-B", slot, scenario.clock.time())
|
||||
|
||||
def data(self, scenario, source="OBP-1", seq=1, src=5005, dst=1234567, dtype=7):
|
||||
packet = PacketSpec(rf_src=src, dst_id=dst, slot=1, seq=seq,
|
||||
stream_id=0x10000000+seq, call_type="unit",
|
||||
frame_type=HBPF_DATA_SYNC, dtype_vseq=dtype)
|
||||
inject = scenario.inject_obp if source.startswith("OBP") else scenario.inject_hbp
|
||||
inject(source, packet)
|
||||
return packet
|
||||
|
||||
def voice(self, scenario, source="OBP-1", slot=2, seq=1):
|
||||
packet = PacketSpec(rf_src=3120001, dst_id=91,
|
||||
slot=1 if source.startswith("OBP") else slot, seq=seq,
|
||||
stream_id=0x20000000+seq, frame_type=HBPF_VOICE, dtype_vseq=1)
|
||||
inject = scenario.inject_obp if source.startswith("OBP") else scenario.inject_hbp
|
||||
inject(source, packet)
|
||||
|
||||
def test_hold_blocks_both_voice_paths_on_either_slot(self):
|
||||
for slot in (1, 2):
|
||||
for data_source in ("MASTER-A", "OBP-1"):
|
||||
for voice_source in ("MASTER-A", "OBP-1"):
|
||||
with self.subTest(slot=slot, data=data_source, voice=voice_source):
|
||||
with self.scenario(slot=slot) as s:
|
||||
self.prepare(s, slot)
|
||||
self.data(s, data_source, dtype=6)
|
||||
self.voice(s, voice_source, slot)
|
||||
self.assertEqual(len(s.capture.for_system("MASTER-B")), 1)
|
||||
|
||||
def test_continuation_refreshes_without_stream_id_dependency(self):
|
||||
with self.scenario() as s:
|
||||
self.prepare(s)
|
||||
for seq, dtype in enumerate((3, 3, 6, 7), 1):
|
||||
self.data(s, seq=seq, dtype=dtype)
|
||||
s.clock.advance(4)
|
||||
self.voice(s)
|
||||
captured = s.capture.for_system("MASTER-B")
|
||||
self.assertEqual(len(captured), 4)
|
||||
self.assertEqual([p.fields["dtype_vseq"] for p in captured], [3, 3, 6, 7])
|
||||
self.assertEqual(s.systems["MASTER-B"].STATUS[2]["TX_TYPE"], HBPF_SLT_VTERM)
|
||||
|
||||
def test_other_pairs_are_rejected_without_refreshing_expiry(self):
|
||||
with self.scenario() as s:
|
||||
self.prepare(s)
|
||||
self.data(s)
|
||||
s.clock.advance(4)
|
||||
self.data(s, seq=2, src=5006)
|
||||
self.data(s, seq=3, dst=1234568)
|
||||
self.assertEqual(len(s.capture.for_system("MASTER-B")), 1)
|
||||
s.clock.advance(1)
|
||||
self.data(s, seq=4, src=5006)
|
||||
self.assertEqual(len(s.capture.for_system("MASTER-B")), 2)
|
||||
|
||||
def test_voice_resumes_at_expiry_without_trimmer(self):
|
||||
with self.scenario() as s:
|
||||
self.prepare(s)
|
||||
self.data(s)
|
||||
s.clock.advance(4.99)
|
||||
self.voice(s)
|
||||
self.assertEqual(len(s.capture.for_system("MASTER-B")), 1)
|
||||
s.clock.advance(.01)
|
||||
self.voice(s, seq=2)
|
||||
self.assertEqual(len(s.capture.for_system("MASTER-B")), 2)
|
||||
|
||||
def test_disabled_preserves_voice_interruption(self):
|
||||
with self.scenario(enabled=False) as s:
|
||||
self.prepare(s)
|
||||
self.data(s)
|
||||
self.voice(s)
|
||||
self.assertEqual(len(s.capture.for_system("MASTER-B")), 2)
|
||||
self.assertNotIn("TX_UNIT_DATA_HOLD", s.systems["MASTER-B"].STATUS[2])
|
||||
|
||||
def test_missing_runtime_setting_enables_hold(self):
|
||||
for source in ("MASTER-A", "OBP-1"):
|
||||
with self.subTest(source=source), self.scenario() as s:
|
||||
del s.config["SYSTEMS"]["MASTER-B"]["UNIT_DATA_HOLD"]
|
||||
self.prepare(s)
|
||||
self.data(s, source)
|
||||
self.voice(s, source)
|
||||
self.assertEqual(len(s.capture.for_system("MASTER-B")), 1)
|
||||
self.assertIn("TX_UNIT_DATA_HOLD", s.systems["MASTER-B"].STATUS[2])
|
||||
|
||||
def test_ongoing_voice_can_enter_after_hold_without_stale_target_lc(self):
|
||||
for source in ("MASTER-A", "OBP-1"):
|
||||
with self.subTest(source=source), self.scenario() as s:
|
||||
self.prepare(s)
|
||||
self.data(s)
|
||||
self.voice(s, source)
|
||||
s.clock.advance(5)
|
||||
inject = s.inject_obp if source.startswith("OBP") else s.inject_hbp
|
||||
for seq, frame, dtype in ((2, HBPF_VOICE, 1), (3, HBPF_DATA_SYNC, HBPF_SLT_VTERM)):
|
||||
inject(source, PacketSpec(rf_src=3120001, dst_id=91,
|
||||
slot=1 if source.startswith("OBP") else 2, seq=seq,
|
||||
stream_id=0x20000001, frame_type=frame, dtype_vseq=dtype))
|
||||
captured = s.capture.for_system("MASTER-B")
|
||||
self.assertEqual(len(captured), 3)
|
||||
self.assertEqual(len(captured[-1].fields["dmr_payload"]), 33)
|
||||
self.assertEqual(s.systems["MASTER-B"].STATUS[2]["TX_STREAM_ID"], (0x20000001).to_bytes(4, "big"))
|
||||
self.assertEqual(s.systems["MASTER-B"].STATUS[2]["TX_TYPE"], HBPF_SLT_VTERM)
|
||||
|
||||
def test_other_slot_not_held(self):
|
||||
with self.scenario(slot=1) as s:
|
||||
self.prepare(s, slot=2)
|
||||
self.data(s)
|
||||
self.voice(s, slot=1)
|
||||
self.assertEqual(len(s.capture.for_system("MASTER-B")), 2)
|
||||
|
||||
def test_hold_preserves_payload_and_data_reporting_not_voice_state(self):
|
||||
for source in ("MASTER-A", "OBP-1"):
|
||||
with self.subTest(source=source), self.scenario() as s:
|
||||
self.prepare(s)
|
||||
s.config["REPORTS"]["REPORT"] = True
|
||||
slot = s.systems["MASTER-B"].STATUS[2]
|
||||
original = dict(slot)
|
||||
packet = self.data(s, source, dtype=6)
|
||||
actual = s.capture.for_system("MASTER-B")[0].packet
|
||||
expected = packet.data()[:15] + bytes((packet.data()[15] | 0x80,)) + packet.data()[16:53]
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual({key: slot[key] for key in original}, original)
|
||||
self.assertTrue(s.reports["MASTER-B"].events[-1].startswith(b"UNIT DATA,DATA,TX,"))
|
||||
|
||||
def test_rejected_voice_and_prompt_do_not_extend_hold(self):
|
||||
with self.scenario() as s:
|
||||
self.prepare(s)
|
||||
self.data(s)
|
||||
slot = s.systems["MASTER-B"].STATUS[2]
|
||||
original = slot["TX_UNIT_DATA_HOLD"]
|
||||
s.clock.advance(4)
|
||||
self.voice(s)
|
||||
s.bm._beginGeneratedVoice(slot)
|
||||
s.bm.sendVoicePacket(s.systems["MASTER-B"], PacketSpec(slot=2).data(),
|
||||
bytes_3(5000), bytes_3(9), slot)
|
||||
self.assertEqual(slot["TX_UNIT_DATA_HOLD"], original)
|
||||
s.clock.advance(1)
|
||||
self.voice(s, seq=2)
|
||||
self.assertEqual(len(s.capture.for_system("MASTER-B")), 2)
|
||||
|
||||
def test_generated_voice_cannot_interrupt_hold(self):
|
||||
with self.scenario() as s:
|
||||
self.prepare(s)
|
||||
self.data(s)
|
||||
slot = s.systems["MASTER-B"].STATUS[2]
|
||||
s.bm._beginGeneratedVoice(slot)
|
||||
packet = PacketSpec(dst_id=9, slot=2).data()
|
||||
s.bm.sendVoicePacket(s.systems["MASTER-B"], packet, bytes_3(5000), bytes_3(9), slot)
|
||||
self.assertEqual(len(s.capture.for_system("MASTER-B")), 1)
|
||||
self.assertTrue(slot["TX_PROMPT_CANCEL"])
|
||||
self.data(s, seq=2)
|
||||
self.assertEqual(len(s.capture.for_system("MASTER-B")), 2)
|
||||
|
||||
def test_active_generated_voice_prevents_new_hold(self):
|
||||
with self.scenario() as s:
|
||||
self.prepare(s)
|
||||
slot = s.systems["MASTER-B"].STATUS[2]
|
||||
token = s.bm._beginGeneratedVoice(slot)
|
||||
self.data(s)
|
||||
self.assertFalse(s.capture.for_system("MASTER-B"))
|
||||
self.assertNotIn("TX_UNIT_DATA_HOLD", slot)
|
||||
s.bm._endGeneratedVoice(slot, token)
|
||||
self.data(s, seq=2)
|
||||
self.assertEqual(len(s.capture.for_system("MASTER-B")), 1)
|
||||
|
||||
def test_existing_voice_and_hangtime_still_prevent_data_start(self):
|
||||
with self.scenario() as s:
|
||||
self.prepare(s)
|
||||
s.config["SYSTEMS"]["MASTER-B"]["GROUP_HANGTIME"] = 5
|
||||
self.voice(s)
|
||||
self.data(s)
|
||||
slot = s.systems["MASTER-B"].STATUS[2]
|
||||
self.assertNotIn("TX_UNIT_DATA_HOLD", slot)
|
||||
# End the actual network call, then exercise its existing hangtime.
|
||||
s.inject_obp("OBP-1", PacketSpec(rf_src=3120001, dst_id=91, slot=1,
|
||||
seq=2, stream_id=0x20000001, frame_type=HBPF_DATA_SYNC, dtype_vseq=HBPF_SLT_VTERM))
|
||||
self.data(s, seq=3)
|
||||
self.assertNotIn("TX_UNIT_DATA_HOLD", slot)
|
||||
s.clock.advance(5.01)
|
||||
self.data(s, seq=4)
|
||||
self.assertIn("TX_UNIT_DATA_HOLD", slot)
|
||||
|
||||
def test_master_config_default_and_explicit_overrides(self):
|
||||
for setting, expected in (("", True), ("UNIT_DATA_HOLD: True", True),
|
||||
("UNIT_DATA_HOLD: False", False)):
|
||||
with self.subTest(setting=setting):
|
||||
fd, path = tempfile.mkstemp(suffix=".cfg")
|
||||
try:
|
||||
with os.fdopen(fd, "w") as handle:
|
||||
handle.write("[GLOBAL]\n[ALIASES]\n[MASTER-A]\nMODE: MASTER\nENABLED: True\n"+setting)
|
||||
parsed = freedmr_config.build_config(path)
|
||||
self.assertIs(parsed["SYSTEMS"]["MASTER-A"]["UNIT_DATA_HOLD"], expected)
|
||||
finally:
|
||||
os.unlink(path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Reference in new issue