mirror of
https://gitlab.com/obbart/universal_robots_ros_driver.git
synced 2026-04-10 10:00:48 +02:00
doxygen documentation for comm finished
This commit is contained in:
@@ -34,6 +34,10 @@ namespace comm
|
|||||||
{
|
{
|
||||||
#define MAX_SERVER_BUF_LEN 50
|
#define MAX_SERVER_BUF_LEN 50
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief The URServer class abstracts communication with the robot. It opens a socket on a given
|
||||||
|
* port and waits for a robot to connect, at which point two way communication can be established.
|
||||||
|
*/
|
||||||
class URServer : private comm::TCPSocket
|
class URServer : private comm::TCPSocket
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -44,13 +48,56 @@ protected:
|
|||||||
virtual bool open(int socket_fd, struct sockaddr* address, size_t address_len);
|
virtual bool open(int socket_fd, struct sockaddr* address, size_t address_len);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/*!
|
||||||
|
* \brief Creates a URServer object with a given port.
|
||||||
|
*
|
||||||
|
* \param port The port to open a socket on
|
||||||
|
*/
|
||||||
URServer(int port);
|
URServer(int port);
|
||||||
|
/*!
|
||||||
|
* \brief Closes the socket to allow for destruction of the object.
|
||||||
|
*/
|
||||||
~URServer();
|
~URServer();
|
||||||
|
/*!
|
||||||
|
* \brief Getter for the server IP.
|
||||||
|
*
|
||||||
|
* \returns The IP of the server
|
||||||
|
*/
|
||||||
std::string getIP();
|
std::string getIP();
|
||||||
|
/*!
|
||||||
|
* \brief Binds to server's port, setting up a socket if possible.
|
||||||
|
*
|
||||||
|
* \returns Success of setting up the socket
|
||||||
|
*/
|
||||||
bool bind();
|
bool bind();
|
||||||
|
/*!
|
||||||
|
* \brief Waits for a robot to connect to the socket.
|
||||||
|
*
|
||||||
|
* \returns True, if a robot successfully connected, false otherwise.
|
||||||
|
*/
|
||||||
bool accept();
|
bool accept();
|
||||||
|
/*!
|
||||||
|
* \brief Triggers a disconnect of the currently connected robot.
|
||||||
|
*/
|
||||||
void disconnectClient();
|
void disconnectClient();
|
||||||
|
/*!
|
||||||
|
* \brief Reads the byte-stream from the robot to the next linebreak.
|
||||||
|
*
|
||||||
|
* \param buffer The buffer to write the received bytes to
|
||||||
|
* \param buf_len Size of the buffer
|
||||||
|
*
|
||||||
|
* \returns True if a successful read occurred, false otherwise
|
||||||
|
*/
|
||||||
bool readLine(char* buffer, size_t buf_len);
|
bool readLine(char* buffer, size_t buf_len);
|
||||||
|
/*!
|
||||||
|
* \brief Writes a buffer to the robot.
|
||||||
|
*
|
||||||
|
* \param buf The buffer to write from
|
||||||
|
* \param buf_len The length to write
|
||||||
|
* \param written A reference used to indicate how many bytes were written
|
||||||
|
*
|
||||||
|
* \returns Success of the write
|
||||||
|
*/
|
||||||
bool write(const uint8_t* buf, size_t buf_len, size_t& written);
|
bool write(const uint8_t* buf, size_t buf_len, size_t& written);
|
||||||
};
|
};
|
||||||
} // namespace comm
|
} // namespace comm
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ namespace ur_driver
|
|||||||
{
|
{
|
||||||
namespace comm
|
namespace comm
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief The ShellConsumer class is a simple consumer that writes a readable representation to
|
||||||
|
* the logging info channel.
|
||||||
|
*
|
||||||
|
* @tparam HeaderT Header type of the packages to consume
|
||||||
|
*/
|
||||||
template <typename HeaderT>
|
template <typename HeaderT>
|
||||||
class ShellConsumer : public IConsumer<URPackage<HeaderT>>
|
class ShellConsumer : public IConsumer<URPackage<HeaderT>>
|
||||||
{
|
{
|
||||||
@@ -43,6 +49,13 @@ public:
|
|||||||
ShellConsumer() = default;
|
ShellConsumer() = default;
|
||||||
virtual ~ShellConsumer() = default;
|
virtual ~ShellConsumer() = default;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Consumes a package, writing a human readable representation to the logging.
|
||||||
|
*
|
||||||
|
* \param product The package to consume
|
||||||
|
*
|
||||||
|
* \returns True if the output was successful
|
||||||
|
*/
|
||||||
virtual bool consume(std::shared_ptr<URPackage<HeaderT>> product)
|
virtual bool consume(std::shared_ptr<URPackage<HeaderT>> product)
|
||||||
{
|
{
|
||||||
LOG_INFO("%s", product->toString().c_str());
|
LOG_INFO("%s", product->toString().c_str());
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
* \brief Connects to the configured socket.
|
* \brief Connects to the configured socket.
|
||||||
*
|
*
|
||||||
* \returns True on success, false if connection could not be established.
|
* \returns True on success, false if connection could not be established
|
||||||
*/
|
*/
|
||||||
bool connect()
|
bool connect()
|
||||||
{
|
{
|
||||||
@@ -89,7 +89,7 @@ public:
|
|||||||
* \param[in] buf_len Number of bytes allocated for the buffer
|
* \param[in] buf_len Number of bytes allocated for the buffer
|
||||||
* \param[out] read Number of bytes actually read from the socket
|
* \param[out] read Number of bytes actually read from the socket
|
||||||
*
|
*
|
||||||
* \returns True on success, false on error, e.g. the buffer is smaller than the package size.
|
* \returns True on success, false on error, e.g. the buffer is smaller than the package size
|
||||||
*/
|
*/
|
||||||
bool read(uint8_t* buf, const size_t buf_len, size_t& read);
|
bool read(uint8_t* buf, const size_t buf_len, size_t& read);
|
||||||
|
|
||||||
@@ -98,9 +98,9 @@ public:
|
|||||||
*
|
*
|
||||||
* \param[in] buf Byte stream that should be sent
|
* \param[in] buf Byte stream that should be sent
|
||||||
* \param[in] buf_len Number of bytes in buffer
|
* \param[in] buf_len Number of bytes in buffer
|
||||||
* \param[out] written Number of bytes actually written to the socket.
|
* \param[out] written Number of bytes actually written to the socket
|
||||||
*
|
*
|
||||||
* \returns false if sending went wrong
|
* \returns False if sending went wrong
|
||||||
*/
|
*/
|
||||||
bool write(const uint8_t* buf, const size_t buf_len, size_t& written);
|
bool write(const uint8_t* buf, const size_t buf_len, size_t& written);
|
||||||
|
|
||||||
|
|||||||
@@ -59,18 +59,38 @@ protected:
|
|||||||
bool setup(std::string& host, int port);
|
bool setup(std::string& host, int port);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/*!
|
||||||
|
* \brief Creates a TCPSocket object
|
||||||
|
*/
|
||||||
TCPSocket();
|
TCPSocket();
|
||||||
virtual ~TCPSocket();
|
virtual ~TCPSocket();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Getter for the state of the socket.
|
||||||
|
*
|
||||||
|
* \returns Returns the current state of the socket
|
||||||
|
*/
|
||||||
SocketState getState()
|
SocketState getState()
|
||||||
{
|
{
|
||||||
return state_;
|
return state_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Getter for the file descriptor of the socket.
|
||||||
|
*
|
||||||
|
* \returns The file descriptor of the socket
|
||||||
|
*/
|
||||||
int getSocketFD()
|
int getSocketFD()
|
||||||
{
|
{
|
||||||
return socket_fd_;
|
return socket_fd_;
|
||||||
}
|
}
|
||||||
|
/*!
|
||||||
|
* \brief Setter for the file descriptor of the socket.
|
||||||
|
*
|
||||||
|
* \param socket_fd The new value
|
||||||
|
*
|
||||||
|
* \returns False, if the socket is in state connected
|
||||||
|
*/
|
||||||
bool setSocketFD(int socket_fd);
|
bool setSocketFD(int socket_fd);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
Reference in New Issue
Block a user