AUBO SDK  0.26.0
Loading...
Searching...
No Matches
arcs::common_interface::Socket Class Reference

#include <socket.h>

Public Member Functions

 Socket ()
 
virtual ~Socket ()
 
int socketOpen (const std::string &address, int port, const std::string &socket_name="socket_0")
 Open TCP/IP ethernet communication socket
 
int socketClose (const std::string &socket_name="socket_0")
 Closes TCP/IP socket communication Closes down the socket connection to the server.
 
int socketReadAsciiFloat (int number, const std::string &variable, const std::string &socket_name="socket_0")
 Reads a number of ascii formatted floats from the socket.
 
int socketReadBinaryInteger (int number, const std::string &variable, const std::string &socket_name="socket_0")
 Reads a number of 32 bit integers from the socket.
 
int socketReadByteList (int number, const std::string &variable, const std::string &socket_name="socket_0")
 Reads a number of bytes from the socket.
 
int socketReadString (const std::string &variable, const std::string &socket_name="socket_0", const std::string &prefix="", const std::string &suffix="", bool interpret_escape=false)
 Reads all data from the socket and returns the data as a string.
 
int socketReadAllString (const std::string &variable, const std::string &socket_name="socket_0")
 Reads all data from the socket and returns the data as a vector of chars.
 
int socketSendByte (char value, const std::string &socket_name="socket_0")
 Sends a byte to the server Sends the byte through the socket.
 
int socketSendInt (int value, const std::string &socket_name="socket_0")
 Sends an int (int32_t) to the server Sends the int through the socket.
 
int socketSendLine (const std::string &str, const std::string &socket_name="socket_0")
 Sends a string with a newline character to the server Sends the string <str> through the socket in ASCII coding.
 
int socketSendString (const std::string &str, const std::string &socket_name="socket_0")
 Sends a string to the server Sends the string <str> through the socket in ASCII coding.
 
int socketSendAllString (bool is_check, const std::vector< char > &str, const std::string &socket_name="socket_0")
 Sends all data in the given vector of chars to the server.
 
bool socketHasConnected (const std::string &socket_name="socket_0")
 Check if the socket is connected.
 

Protected Attributes

void * d_
 

Detailed Description

Definition at line 16 of file socket.h.

Constructor & Destructor Documentation

◆ Socket()

arcs::common_interface::Socket::Socket ( )

◆ ~Socket()

virtual arcs::common_interface::Socket::~Socket ( )
virtual

Member Function Documentation

◆ socketClose()

int arcs::common_interface::Socket::socketClose ( const std::string &  socket_name = "socket_0")

Closes TCP/IP socket communication Closes down the socket connection to the server.

Instruction

Parameters
socket_name
Returns
Python function prototype
socketClose(self: pyaubo_sdk.Socket, arg0: str) -> int
Lua function prototype
socketClose(socket_name: string) -> nil
JSON-RPC request example
{"jsonrpc":"2.0","method":"Socket.socketClose","params":["socket_0"],"id":1}
JSON-RPC response example
{"id":1,"jsonrpc":"2.0","result":0}

◆ socketHasConnected()

bool arcs::common_interface::Socket::socketHasConnected ( const std::string &  socket_name = "socket_0")

Check if the socket is connected.

socketHasConnected

Parameters
socket_name
Returns
Python函数原型
socketHasConnected(self: pyaubo_sdk.Socket, arg0: str) -> bool
Lua函数原型
socketHasConnected(socket_name: string) -> boolean

◆ socketOpen()

int arcs::common_interface::Socket::socketOpen ( const std::string &  address,
int  port,
const std::string &  socket_name = "socket_0" 
)

Open TCP/IP ethernet communication socket

Instruction

Parameters
address
port
socket_name
Returns
Python function prototype
socketOpen(self: pyaubo_sdk.Socket, arg0: str, arg1: int, arg2: str) -> int
Lua function prototype
socketOpen(address: string, port: number, socket_name: string) -> nil
JSON-RPC request example
{"jsonrpc":"2.0","method":"Socket.socketOpen","params":["172.16.26.248",8000,"socket_0"],"id":1}
JSON-RPC response example
{"id":1,"jsonrpc":"2.0","result":0}

◆ socketReadAllString()

int arcs::common_interface::Socket::socketReadAllString ( const std::string &  variable,
const std::string &  socket_name = "socket_0" 
)

Reads all data from the socket and returns the data as a vector of chars.

Instruction std::vector<char>

Parameters
variable
socket_name
Returns
Python function prototype
socketReadAllString(self: pyaubo_sdk.Socket, arg0: str, arg1: str) -> int
Lua function prototype
socketReadAllString(variable: string, socket_name: string) -> number
JSON-RPC request example
{"jsonrpc":"2.0","method":"Socket.socketReadAllString","params":["camera","socket_0"],"id":1}
JSON-RPC response example
{"id":1,"jsonrpc":"2.0","result":0}

◆ socketReadAsciiFloat()

int arcs::common_interface::Socket::socketReadAsciiFloat ( int  number,
const std::string &  variable,
const std::string &  socket_name = "socket_0" 
)

Reads a number of ascii formatted floats from the socket.

A maximum of 30 values can be read in one command. A list of numbers read (list of floats, length=number+1)

Result will be stored in a register named reg_key. Use getFloatVec to retrieve data

Parameters
number
variable
socket_name
Returns
Python function prototype
socketReadAsciiFloat(self: pyaubo_sdk.Socket, arg0: int, arg1: str, arg2: str) -> int
Lua function prototype
socketReadAsciiFloat(number: number, variable: string, socket_name: string) -> number

◆ socketReadBinaryInteger()

int arcs::common_interface::Socket::socketReadBinaryInteger ( int  number,
const std::string &  variable,
const std::string &  socket_name = "socket_0" 
)

Reads a number of 32 bit integers from the socket.

Bytes are in network byte order. A maximum of 30 values can be read in one command. A list of numbers read (list of ints, length=number+1)

Instruction

std::vector<int>

Parameters
number
variable
socket_name
Returns
Python function prototype
socketReadBinaryInteger(self: pyaubo_sdk.Socket, arg0: int, arg1: str, arg2: str) -> int
Lua function prototype
socketReadBinaryInteger(number: number, variable: string, socket_name: string) -> number

◆ socketReadByteList()

int arcs::common_interface::Socket::socketReadByteList ( int  number,
const std::string &  variable,
const std::string &  socket_name = "socket_0" 
)

Reads a number of bytes from the socket.

Bytes are in network byte order. A maximum of 30 values can be read in one command. A list of numbers read (list of ints, length=number+1)

Instruction

std::vector<char>

Parameters
number
variable
socket_name
Returns
Python function prototype
socketReadByteList(self: pyaubo_sdk.Socket, arg0: int, arg1: str, arg2: str) -> int
Lua function prototype
socketReadByteList(number: number, variable: string, socket_name: string) -> number

◆ socketReadString()

int arcs::common_interface::Socket::socketReadString ( const std::string &  variable,
const std::string &  socket_name = "socket_0",
const std::string &  prefix = "",
const std::string &  suffix = "",
bool  interpret_escape = false 
)

Reads all data from the socket and returns the data as a string.

Bytes are in network byte order.

The optional parameters "prefix" and "suffix", can be used to express what is extracted from the socket. The "prefix" specifies the start of the substring (message) extracted from the socket. The data up to the end of the "prefix" will be ignored and removed from the socket. The "suffix" specifies the end of the substring (message) extracted from the socket. Any remaining data on the socket, after the "suffix", will be preserved. E.g. if the socket server sends a string "noise>hello<", the controller can receive the "hello" by calling this script function with the prefix=">" and suffix="<". By using the "prefix" and "suffix" it is also possible send multiple string to the controller at once, because the suffix defines where the message ends. E.g. sending ">hello<>world<"

Instruction

std::string

Parameters
variable
socket_name
prefix
suffix
interpret_escape
Returns
Python function prototype
socketReadString(self: pyaubo_sdk.Socket, arg0: str, arg1: str, arg2: str, arg3: str, arg4: bool) -> int
Lua function prototype
socketReadString(variable: string, socket_name: string, prefix: string, suffix: string, interpret_escape: boolean) -> number
JSON-RPC request example
{"jsonrpc":"2.0","method":"Socket.socketReadString","params":["camera","socket_0","","",false],"id":1}
JSON-RPC response example
{"id":1,"jsonrpc":"2.0","result":0}

◆ socketSendAllString()

int arcs::common_interface::Socket::socketSendAllString ( bool  is_check,
const std::vector< char > &  str,
const std::string &  socket_name = "socket_0" 
)

Sends all data in the given vector of chars to the server.

Parameters
is_checkWhether to check the sending status
strThe data to send as a vector of chars
socket_nameThe name of the socket
Returns
Status code
Python function prototype
socketSendAllString(self: pyaubo_sdk.Socket, arg0: bool, arg1: List[str], arg2: str) -> int
Lua function prototype
socketSendAllString(is_check: boolean, str: table, socket_name: string) -> nil

◆ socketSendByte()

int arcs::common_interface::Socket::socketSendByte ( char  value,
const std::string &  socket_name = "socket_0" 
)

Sends a byte to the server Sends the byte through the socket.

Expects no response. Can be used to send special ASCII characters; 10 is newline, 2 is start of text, 3 is end of text.

Instruction

Parameters
value
socket_name
Returns
Python function prototype
socketSendByte(self: pyaubo_sdk.Socket, arg0: str, arg1: str) -> int
Lua function prototype
socketSendByte(value: string, socket_name: string) -> nil

◆ socketSendInt()

int arcs::common_interface::Socket::socketSendInt ( int  value,
const std::string &  socket_name = "socket_0" 
)

Sends an int (int32_t) to the server Sends the int through the socket.

Send in network byte order. Expects no response

Instruction

Parameters
value
socket_name
Returns
Python function prototype
socketSendInt(self: pyaubo_sdk.Socket, arg0: int, arg1: str) -> int
Lua function prototype
socketSendInt(value: number, socket_name: string) -> nil

◆ socketSendLine()

int arcs::common_interface::Socket::socketSendLine ( const std::string &  str,
const std::string &  socket_name = "socket_0" 
)

Sends a string with a newline character to the server Sends the string <str> through the socket in ASCII coding.

Expects no response.

Instruction

Parameters
str
socket_name
Returns
Python function prototype
socketSendLine(self: pyaubo_sdk.Socket, arg0: str, arg1: str) -> int
Lua function prototype
socketSendLine(str: string, socket_name: string) -> nil
JSON-RPC request example
{"jsonrpc":"2.0","method":"Socket.socketSendLine","params":["abcd","socket_0"],"id":1}
JSON-RPC response example
{"id":1,"jsonrpc":"2.0","result":0}

◆ socketSendString()

int arcs::common_interface::Socket::socketSendString ( const std::string &  str,
const std::string &  socket_name = "socket_0" 
)

Sends a string to the server Sends the string <str> through the socket in ASCII coding.

Expects no response.

Instruction

Parameters
str
socket_name
Returns
Python function prototype
socketSendString(self: pyaubo_sdk.Socket, arg0: str, arg1: str) -> int
Lua function prototype
socketSendString(str: string, socket_name: string) -> nil
JSON-RPC request example
{"jsonrpc":"2.0","method":"Socket.socketSendString","params":["abcd","socket_0"],"id":1}
JSON-RPC response example
{"id":1,"jsonrpc":"2.0","result":0}

Member Data Documentation

◆ d_

void* arcs::common_interface::Socket::d_
protected

Definition at line 621 of file socket.h.


The documentation for this class was generated from the following file: