SerialPort Class

class ekmmeters.SerialPort(ttyport, baudrate=9600, force_wait=0.1)

Wrapper for serial port commands.

It should only be necessary to create one SerialPort per real port.

Object construction sets the class variables. The port is opened with initPort(), and any serial exceptions will thrown at that point.

The standard serial settings for v3 and v4 EKM meters are 9600 baud, 7 bits, 1 stop bit, no parity. The baud rate may be reset but all timings and test in this library are at 9600 baud. Bits, stop and parity may not be changed.

initPort()

Required initialization call, wraps pyserial constructor.

getName()

Getter for serial port name

Returns:name of serial port (ex: ‘COM3’, ‘/dev/ttyS0’)
Return type:string
closePort()

Passthrough for pyserial port close().

write(output)

Passthrough for pyserial Serial.write().

Parameters:output (str) – Block to write to port
setPollingValues(max_waits, wait_sleep)

Optional polling loop control

Parameters:
  • max_waits (int) – waits
  • wait_sleep (int) – ms per wait
getResponse(context='')

Poll for finished block or first byte ACK. :param context: internal serial call context.

Returns:Response, implict cast from byte array.
Return type:string