Communication

ComBase

class Communication.ComBase.ComBase[source]
Inherit

QThread

Description

Base communication class used as inheritance class for other more complex com classes.

Implement signal communication with superior task and start, close methods.

close()[source]
Description

Emit status change as “Offline”.

Self Destroy.

connect_to_device()[source]
Raises

NotImplementedError – Python way of saying this method is virtual.

get_data()[source]
Raises

NotImplementedError – Python way of saying this method is virtual.

run()[source]
Description

This method is called when thread is started with start() method.

Main communication loop

stop_com()[source]
Description

Stop main communication loop and self destroy.

SerialCom

class Communication.SerialCom.SerialCom(port, bauds=921600)[source]
Inherit

ComBase

Description

Handle communication with device via serial port (COM).

Parameters
  • port (str) – COM port on which to communicate.

  • bauds (int, optional) – Baud speed of serial communication

Raises
  • OSError – COM port does not exist.

  • TypeError

    – COM port is not a str.

    – Baud rate is not a int.

  • ValueError – Baud rate is not in range 300 - 921600.

static check_baud_rate(bauds)[source]
Description

Check if baud is an int in range of 300 - 921600.

Parameters

bauds (int) – Baud rate.

Raises
  • ValueError – Baud rate is not in range 300 - 921600.

  • TypeError – Baud rate is not an integer.

static check_com_port(port)[source]
Description

Check if port is a str and can be found on the system.

Parameters

port (str) – Com port name.

Raises
  • TypeError – Port is not a str.

  • OSError – Port cannot be find on the system.

close()[source]
Description

Close communication and self destroy.

connect_to_device()[source]
Description

Establish serial communication with via USB COM.

Send information about connection status.

Raises

SerialException – Port cannot be opened. Usually because port is already opened.

get_data()[source]
Description

Receive data from device and send signal containing data as a byte array.

Raises

If any error occurs try to solve problem by reconnecting to device.

SocketClient

class Communication.SocketClient.SocketClient(address='192.168.1.100', port=80)[source]
Inherit

ComBase

Description

Handle direct communication with car via Wi-Fi.

Parameters
  • address (str, optional) – address of socket server

  • port (int, optional) – port for socket server

Raises
static check_address(address)[source]
Description

Check if IP address is in a valid format.

Parameters

address (str) – IP address.

Raises

OSError – IP address is not in a valid format.

static check_port(port)[source]
Description

Check if port is int in range 1 - 65535.

Parameters

port (int) – Communication port.

Raises
close()[source]
Description

Close communication and self destroy.

connect_to_device()[source]
Description

Establish serial communication with server via Wi-Fi.

Send information about connection status.

Raises

WindowsError – A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

get_data()[source]
Description

Receive data from device and send signal containing data as a byte array.

Whenever one of the following errors raise, method will try to resolve problem by reconnecting.

Raises