pycertifspec.SpecSocket #
SpecMessage #
NamedTuple representing a response from SPEC. Fields are named the same as in the server documentation: https://www.certif.com/spec_help/server.html#protocol
Properties:
magic- Spec magic number (4277009102)vers- Protocol version numbersize- Size of the headersn- Serial number (same as request if response)sec- Time when sentusec- Time when sentcmd- Command code (One of pycertifspec.EventTypes)type- Type of body data (One of pycertifspec.DataTypes)rows- Number of rows if body data is arraycols- Number of columns if body data is arraylen- Length of bodyerr- Error code (0 if none)flags- Flags (combination of pycertifspec.Flags)name- Name of propertybody- Body of the message (string when DataTypes.SV_STRING, else raw bytes)
SpecSocket Objects #
class SpecSocket(socket.socket)
Socket like a regular socket.socket, but with extra methods for sending and receiving data from a SPEC server.
connect_spec #
| connect_spec(host: str, port: int = None, port_range: Tuple[int, int] = (6510, 6530), ports: List[int] = [], timeout: float = 0.5)
Scan ports for a SPEC server and connect when found. If port is already known .connect() can be used instead
Attributes:
hoststring - The address of the host computerportint - If exact port is known, the port to connect toport_rangetuple - Range of ports to scan (end is inclusive)portslist - List of ports to scantimeoutfloat - Time to wait for answer before trying the next port
Returns:
(int)- The port connected to
send_spec #
| send_spec(serial_number: int, command: int, data_type: int, property_name: str = "", body: bytes = b'', error: bool = False, flags: List[int] = [], rows: int = 0, cols: int = 0)
Send a message to the SPEC server
Attributes:
serial_numberint - Serial number of message. Will be the same in server replycommandint - The command/event from EventTypes to executedata_typeint - The data type of the body. One of DataTypesproperty_namestring - The name of the property to do work onbodybytes - The body of the messageerrorint - Error if != 0flagsint - Set a flag (isn’t used yet)rowsint - The number of rows of the body (if array)colsint - The number of cols of the body (if array)
recv_spec #
| recv_spec() -> SpecMessage
Receive a SPEC message
Returns:
(SpecMessage)- The message from the SPEC server