thorlabs_apt_device.protocol.unpacker module¶
- class thorlabs_apt_device.protocol.unpacker.Unpacker(file_like=None, on_error='continue')[source]¶
Bases:
objectCreate an Unpacker to decode a byte stream into Thorlabs APT protocol messages.
The
file_likeparameter should be an object which data can be sourced from. It should support theread()method.The
on_errorparameter selects the action to take if invalid data is detected. If set to"continue"(the default), bytes will be discarded if the byte sequence does not appear to be a valid message. If set to"warn", the behaviour is identical, but a warning message will be emitted. To instead immediately abort the stream decoding and raise aRuntimeError, set to"raise".- Parameters:
file_like – A file-like object which data can be read() from.
on_error – Action to take if invalid data is detected.