basic_robotics.interfaces.udp_bridge module

Handle UDP Communications as a CommsObject.

class basic_robotics.interfaces.udp_bridge.UDPObject(name, ip: str = '192.168.1.1', rx_port: int = 8000, tx_port: int = 9000, timeout: float = 0.1)[source]

Bases: CommsObject

Create a new CommsObject that handles UDP Communication.

__init__(name, ip: str = '192.168.1.1', rx_port: int = 8000, tx_port: int = 9000, timeout: float = 0.1) → UDPObject[source]

Create a new UDP CommsObject.

Parameters:
  • name (str) – name of the object

  • ip (str, optional) – port to select. Defaults to “192.168.1.1”.

  • rx_port (int, optional) – Network Receive. Defaults to 8000.

  • tx_port (int, optional) – Network Transmit. Defaults to 9000.

  • timeout (float, optional) – Network timeout. Defaults to 0.1

Returns:

CommsObject instance

sendData(message: str, port: int = None) → None[source]

Send a message.

Parameters:
  • message (Str) – data to be sent along the connection

  • port (int, Optional) – port to transmit. Defaults to None.

getData()[source]

Receive a message.

Returns:

msg – data retrieved, if any success: boolean for whether or not data was retrieved

setIP(ip: str) → None[source]

Set the IP address of the comms handle.

Parameters:

ip – String - ip to bind to

setRxPort(port: int) → None[source]

Set the Rx port of the comms handle.

Parameters:

port – Int - port to bind to

setTxPort(port: int) → None[source]

Set the Tx port of the comms handle.

Parameters:

port – Int - port to bind to

openCom() → bool[source]

Open a Communications Channel.

Returns:

bool – Success of Opening the Channel

closeCom() → bool[source]

Close a Communications Channel.

Returns:

bool – Success of Closing the Channel

setBufferLen(bufferLen: int) → None[source]

Set the buffer length.

Parameters:

bufferLen (int) – length of the buffer in bytes

getIP() → str[source]

Return the bound IP Address.

Returns:

String – ip

getRxPort() → int[source]

Return the bound rx port number.

Returns:

Int – port

getTxPort() → int[source]

Return the bound tx port number.

Returns:

Int – port

getBufferLen() → int[source]

Return the buffer length.

Returns:

Int – Buffer length