maodevice.communicator module¶
-
class
maodevice.communicator.
SocketCom
(host, port, timeout=1.0, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, proto=0, fileno=None)[source]¶ Bases:
maodevice.core.BaseCommunicator
Communicate with the device via “Socket”.
This is a child class of the base class “maodevice.core.BaseCommunicator”.
Parameters: - host (str) – IP Address of a device.
- port (int) – Port of a device.
- timeout (float) – A read timeout values. Defaults to 1.0.
- family (socket.AddressFamily) – A constant indicating the address (and protocol) family. Defaults to socket.AF_INET.
- type (socket.SocketKind) – A Constant indicating the socket type. Defaults to socket.SOCK_STREAM.
- proto (int) – Protocol number. If family=socket.AF_CAN, either socket.CAN_RAW or socket.CAN_BCM should be specified. Defaults to 0.
- fileno (None or int) – File descriptor. If it is specified, the other arguments are ignored, causing the socket with the specified file descriptor to return. Unlike socket.fromfd(), fileno will return the same socket and not a duplicate. This may help close a detached socket using socket.close(). Defaults to None.
-
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
= 'Socket'
-
close
()[source]¶ Close the connection to the device.
Note
This method override the “close” in the base class.
Returns: None
-
open
()[source]¶ Open the connection to the device.
Note
This method override the “open” in the base class.
Returns: None
-
class
maodevice.communicator.
SerialCom
(port, baudrate=9600, bytesize=8, parity='N', stopbits=1, timeout=1.0, xonxoff=False, rtscts=False, dsrdtr=False, write_timeout=None, inter_byte_timeout=None, exclusive=None)[source]¶ Bases:
maodevice.core.BaseCommunicator
Communicate with the device via “Serial”.
This is a child class of the base class “maodevice.core.BaseCommunicator”.
Parameters: - port (str) – Device name.
- baudrate (int) – Baud rate. Defaults to 9600.
- byteize (int) – Number of data bits. Defaults to serial.EIGHTBITS.
- parity (str) – Enable parity checking. Defaults to serial.PARITY_NONE.
- stopbits (float) – Number of stop bits. Defaults to serial.STOPBITS_ONE.
- timeout (float) – A read timeout values. Defaults to 1.0.
- xonxoff (bool) – Enable software flow control. Defaults to False.
- rtscts (bool) – Enable hardware (RTS/CTS) flow control. Defaults to False.
- dsrdtr (bool) – Enable hardware (DSR/DTR) flow control. Defaults to False.
- write_timeout (float or None) – Set a write timeout value. Defaults to None.
- inter_byte_timeout (float or None) – Inter-character timeout. Defaults to None (None to disable).
- exclusive (bool) – Set exclusive access mode (POSIX only). A port cannot be opened in exclusive access mode if it is already open in exclusive access mode. Defaults to None.
-
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
= 'Serial'
-
close
()[source]¶ Close the connection to the device.
Note
This method is override the “close” in the base class.
Returns: None
-
open
()[source]¶ Open the connection to the device.
Note
This method override the “open” in the base class.
Returns: None