hvl_ccb.comm.tcp

Inheritance diagram of hvl_ccb.comm.tcp

TCP communication protocol. Makes use of the socket library.

class Tcp(configuration)[source]

Bases: CommunicationProtocol

Tcp Communication Protocol.

close() None[source]

Close TCP connection.

static config_cls() type[TcpCommunicationConfig][source]

Return the default configdataclass class.

Returns:

a reference to the default configdataclass class

open() None[source]

Open TCP connection.

read() str[source]

TCP read function :return: information read from TCP buffer formatted as string

write(command: str = '') None[source]

TCP write function :param command: command string to be sent :return: none

class TcpCommunicationConfig(host: str | IPv4Address | IPv6Address, port: int = 54321, bufsize: int = 1024)[source]

Bases: object

Configuration dataclass for TcpCommunication.

bufsize: int = 1024
clean_values()[source]
force_value(fieldname, value)

Forces a value to a dataclass field despite the class being frozen.

NOTE: you can define post_force_value method with same signature as this method to do extra processing after value has been forced on fieldname.

Parameters:
  • fieldname – name of the field

  • value – value to assign

host: str | IPv4Address | IPv6Address
is_configdataclass = True
classmethod keys() Sequence[str]

Returns a list of all configdataclass fields key-names.

Returns:

a list of strings containing all keys.

classmethod optional_defaults() dict[str, object]

Returns a list of all configdataclass fields, that have a default value assigned and may be optionally specified on instantiation.

Returns:

a list of strings containing all optional keys.

port: int = 54321
classmethod required_keys() Sequence[str]

Returns a list of all configdataclass fields, that have no default value assigned and need to be specified on instantiation.

Returns:

a list of strings containing all required keys.