mirror of
https://github.com/lowobservable/coax.git
synced 2026-03-06 11:34:29 +00:00
Implement LOAD_SECONDARY_CONTROL
This commit is contained in:
@@ -8,6 +8,7 @@ from .protocol import (
|
||||
PowerOnResetCompletePollResponse,
|
||||
KeystrokePollResponse,
|
||||
Control,
|
||||
SecondaryControl,
|
||||
poll,
|
||||
poll_ack,
|
||||
read_status,
|
||||
|
||||
@@ -152,6 +152,19 @@ class Control:
|
||||
f'cursor_reverse={self.cursor_reverse}, '
|
||||
f'cursor_blink={self.cursor_blink}>')
|
||||
|
||||
class SecondaryControl:
|
||||
"""Terminal secondary control register."""
|
||||
|
||||
def __init__(self, big=False):
|
||||
self.big = big
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
return bool(self.big) | 0
|
||||
|
||||
def __repr__(self):
|
||||
return f'<SecondaryControl big={self.big}>'
|
||||
|
||||
def poll(interface, action=PollAction.NONE, **kwargs):
|
||||
"""Execute a POLL command."""
|
||||
command_word = (action.value << 8) | _pack_command_word(Command.POLL)
|
||||
@@ -233,9 +246,11 @@ def load_control_register(interface, control, **kwargs):
|
||||
|
||||
_execute_write_command(interface, command_word, bytes([control.value]), **kwargs)
|
||||
|
||||
def load_secondary_control(interface):
|
||||
def load_secondary_control(interface, control, **kwargs):
|
||||
"""Execute a LOAD_SECONDARY_CONTROL command."""
|
||||
raise NotImplementedError
|
||||
command_word = _pack_command_word(Command.LOAD_SECONDARY_CONTROL)
|
||||
|
||||
_execute_write_command(interface, command_word, bytes([control.value]), **kwargs)
|
||||
|
||||
def load_mask(interface):
|
||||
"""Execute a LOAD_MASK command."""
|
||||
|
||||
@@ -4,7 +4,7 @@ from unittest.mock import Mock
|
||||
import context
|
||||
|
||||
from coax import PollResponse, KeystrokePollResponse, ProtocolError
|
||||
from coax.protocol import Command, Status, TerminalId, Control, _execute_read_command, _execute_write_command, _pack_command_word, _unpack_command_word, _unpack_data_words, _unpack_data_word
|
||||
from coax.protocol import Command, Status, TerminalId, Control, SecondaryControl, _execute_read_command, _execute_write_command, _pack_command_word, _unpack_command_word, _unpack_data_words, _unpack_data_word
|
||||
|
||||
class PollResponseTestCase(unittest.TestCase):
|
||||
def test_is_power_on_reset_complete(self):
|
||||
@@ -89,6 +89,12 @@ class ControlTestCase(unittest.TestCase):
|
||||
|
||||
self.assertEqual(control.value, 0b00000001)
|
||||
|
||||
class SecondaryControlTestCase(unittest.TestCase):
|
||||
def test_big(self):
|
||||
control = SecondaryControl(big=True)
|
||||
|
||||
self.assertEqual(control.value, 0b00000001)
|
||||
|
||||
class ExecuteReadCommandTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.interface = Mock()
|
||||
|
||||
Reference in New Issue
Block a user