33if not hasattr(serial,
"Serial"):
34 if hasattr(serial,
"marshall"):
36 "incorrect imported package serial. It appears that the serial"
37 " package from the distribution serial, instead of pyserial, was"
38 " imported. Consider uninstalling serial and installing pySerial."
42 "imported package serial does not have Serial class"
47 """Utility mixin for devices that only trigger "once" with software.
49 This mixin avoids code duplication for the many devices whose only
50 supported trigger type and trigger mode are `TriggerType.SOFTWARE`
51 and `TriggerMode.ONCE`.
57 return microscope.TriggerType.SOFTWARE
61 return microscope.TriggerMode.ONCE
66 if ttype
is not microscope.TriggerType.SOFTWARE:
68 "the only trigger type supported is software"
70 if tmode
is not microscope.TriggerMode.ONCE:
72 "the only trigger mode supported is 'once'"
77 """Utility mixin for devices that only trigger "bulb" with software.
79 This mixin avoids code duplication for the many devices whose only
80 supported trigger type and trigger mode are `TriggerType.SOFTWARE`
81 and `TriggerMode.BULB`.
87 return microscope.TriggerType.SOFTWARE
91 return microscope.TriggerMode.BULB
96 if ttype
is not microscope.TriggerType.SOFTWARE:
98 "the only trigger type supported is software"
100 if tmode
is not microscope.TriggerMode.BULB:
102 "the only trigger mode supported is 'bulb'"
107 "trigger does not make sense in trigger mode bulb, only enable"
112 """Wraps a `Serial` instance with a lock for synchronization."""
119 def lock(self) -> threading.RLock:
126 def readlines(self, hint: int = -1) -> typing.List[bytes]:
133 self, terminator: bytes = b
"\n", size: typing.Optional[int] =
None
138 def write(self, data: bytes) -> int:
microscope.TriggerType trigger_type(self)
None set_trigger(self, microscope.TriggerType ttype, microscope.TriggerMode tmode)
microscope.TriggerMode trigger_mode(self)
microscope.TriggerMode trigger_mode(self)
None set_trigger(self, microscope.TriggerType ttype, microscope.TriggerMode tmode)
microscope.TriggerType trigger_type(self)
threading.RLock lock(self)
int write(self, bytes data)
None __init__(self, serial.Serial serial)
bytes read_until(self, bytes terminator=b"\n", typing.Optional[int] size=None)
typing.List[bytes] readlines(self, int hint=-1)