maodevice.core module¶
-
class
maodevice.core.
BaseCommunicator
(*args)[source]¶ Bases:
object
Communicate with a device.
This is the base class of device communicators.
Note
This class itself is not used, but it is inherited by child classes and used.
Parameters: *args – Variable length argument list. -
METHOD
¶ Communication method.
Type: str
-
connection
¶ Connection indicator. If it is true, the connection has been established.
Type: bool
-
terminator
¶ Termination character.
Type: str
-
METHOD
= ''
-
close
()[source]¶ Close the connection to the device.
Note
This method must be overridden in the child class.
-
connection
= False
-
open
()[source]¶ Open the connection to the device.
Note
This method must be overridden in the child class.
-
query
(msg, byte=4096)[source]¶ Query a message to the device.
Parameters: msg (str) – A message to query the device. Returns: The response of the device. Return type: ret (bytes)
-
recv
(byte)[source]¶ Receive the response of the device.
Note
This method must be overridden in the child class.
Parameters: byte (int) – Bytes to read.
-
send
(msg)[source]¶ Send a message to the device.
Note
This method must be overridden in the child class.
Parameters: msg (str) – A message to send the device.
-
classmethod
set_terminator
(term_char)[source]¶ Set the termination character.
Parameters: term_char (str) – Termination character. Returns: None
-
terminator
= '\n'
-
-
exception
maodevice.core.
BaseDeviceError
[source]¶ Bases:
Exception
Base exception class of “maodevice” package.
Note
This class itself is not used, but it is inherited by child classes and used.
-
class
maodevice.core.
BaseDeviceHandler
(com)[source]¶ Bases:
object
Control a device.
This is the base class of device handler.
Note
This class itself is not used, but it is inherited by child classes and used.
Parameters: com (maodevice.communicator) – Communicator instance to control the device. -
MANUFACTURER
¶ Manufacturer of the device.
Type: str
-
PRODUCT_NAME
¶ Name of the device.
Type: str
-
CLASSIFICATION
¶ Classification of the device.
Type: str
-
CLASSIFICATION
= ''
-
MANUFACTURER
= ''
-
PRODUCT_NAME
= ''
-