![]() |
AUBO SDK
0.26.0
|
#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_ |
| arcs::common_interface::Socket::Socket | ( | ) |
|
virtual |
| 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
| socket_name |
| bool arcs::common_interface::Socket::socketHasConnected | ( | const std::string & | socket_name = "socket_0" | ) |
Check if the socket is connected.
socketHasConnected
| socket_name |
| 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
| address | |
| port | |
| socket_name |
| 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>
| variable | |
| socket_name |
| 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
| number | |
| variable | |
| socket_name |
| 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>
| number | |
| variable | |
| socket_name |
| 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>
| number | |
| variable | |
| socket_name |
| 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
| variable | |
| socket_name | |
| prefix | |
| suffix | |
| interpret_escape |
| 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.
| is_check | Whether to check the sending status |
| str | The data to send as a vector of chars |
| socket_name | The name of the socket |
| 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
| value | |
| socket_name |
| 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
| value | |
| socket_name |
| 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
| str | |
| socket_name |
| 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
| str | |
| socket_name |