diff --git a/ebpfcat/devices.py b/ebpfcat/devices.py index 38af1e7f262aba687cd5ff3ee40bacaee06dc50a..11a3340ae369f0c08e576925cd963465c44712e2 100644 --- a/ebpfcat/devices.py +++ b/ebpfcat/devices.py @@ -15,7 +15,7 @@ class AnalogInput(Device): It will read from there and return the result in its parameter `value`. """ - value = DeviceVar() + value = DeviceVar(write=False) data = TerminalVar() def __init__(self, data): @@ -34,7 +34,7 @@ class AnalogOutput(Device): This device can be linked to an analog output of a terminal. It will write the `value` to that terminal. """ - value = DeviceVar() + value = DeviceVar(write=True) data = TerminalVar() def __init__(self, data): @@ -54,7 +54,7 @@ class DigitalInput(Device): It will read from there and return the result in its parameter `value`. """ - value = DeviceVar() + value = DeviceVar(write=False) data = TerminalVar() def __init__(self, data): @@ -73,7 +73,7 @@ class DigitalOutput(Device): This device can be linked to an analog output of a terminal. It will write the `value` to that terminal. """ - value = DeviceVar() + value = DeviceVar(write=True) data = TerminalVar() def __init__(self, data): @@ -92,8 +92,8 @@ class PWM(Device): This device can be linked to an analog output of a terminal. It will write the `value` to that terminal. """ - seed = DeviceVar("I") - value = DeviceVar("I") + seed = DeviceVar("I", write=True) + value = DeviceVar("I", write=True) data = TerminalVar() def __init__(self, data): @@ -110,7 +110,7 @@ class PWM(Device): class Counter(Device): """A fake device counting the loops""" - count = DeviceVar("I") + count = DeviceVar("I", write=False) def program(self): self.count += 1 @@ -127,12 +127,12 @@ class Motor(Device): enable = TerminalVar() current_position = DeviceVar() - set_velocity = DeviceVar() - set_enable = DeviceVar() - max_velocity = DeviceVar() - max_acceleration = DeviceVar() - target = DeviceVar() - proportional = DeviceVar() + set_velocity = DeviceVar(write=True) + set_enable = DeviceVar(write=True) + max_velocity = DeviceVar(write=True) + max_acceleration = DeviceVar(write=True) + target = DeviceVar(write=True) + proportional = DeviceVar(write=True) def update(self): velocity = self.proportional * (self.target - self.encoder) diff --git a/ebpfcat/ebpfcat.py b/ebpfcat/ebpfcat.py index d15a98227cbeae2441f7118214ae372b2ec36637..d10ca31ca581a085d5a12c27dbbb8ad1d9c1f7af 100644 --- a/ebpfcat/ebpfcat.py +++ b/ebpfcat/ebpfcat.py @@ -158,8 +158,8 @@ class TerminalVar: class DeviceVar(ArrayGlobalVarDesc): - def __init__(self, size="I"): - super().__init__(FastSyncGroup.properties, size) + def __init__(self, size="I", write=False): + super().__init__(FastSyncGroup.properties, size, write) def __get__(self, instance, owner): if instance is None: