1
0
mirror of https://gitlab.com/obbart/universal_robots_ros_driver.git synced 2026-04-09 17:40:47 +02:00

doxygen documentation for comm finished

This commit is contained in:
Tristan Schnell
2019-09-24 00:51:25 +02:00
parent 6a0ebe6b80
commit d0ce601778
4 changed files with 84 additions and 4 deletions

View File

@@ -34,6 +34,10 @@ namespace comm
{
#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
{
private:
@@ -44,13 +48,56 @@ protected:
virtual bool open(int socket_fd, struct sockaddr* address, size_t address_len);
public:
/*!
* \brief Creates a URServer object with a given port.
*
* \param port The port to open a socket on
*/
URServer(int port);
/*!
* \brief Closes the socket to allow for destruction of the object.
*/
~URServer();
/*!
* \brief Getter for the server IP.
*
* \returns The IP of the server
*/
std::string getIP();
/*!
* \brief Binds to server's port, setting up a socket if possible.
*
* \returns Success of setting up the socket
*/
bool bind();
/*!
* \brief Waits for a robot to connect to the socket.
*
* \returns True, if a robot successfully connected, false otherwise.
*/
bool accept();
/*!
* \brief Triggers a disconnect of the currently connected robot.
*/
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);
/*!
* \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);
};
} // namespace comm

View File

@@ -36,6 +36,12 @@ namespace ur_driver
{
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>
class ShellConsumer : public IConsumer<URPackage<HeaderT>>
{
@@ -43,6 +49,13 @@ public:
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)
{
LOG_INFO("%s", product->toString().c_str());

View File

@@ -56,7 +56,7 @@ public:
/*!
* \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()
{
@@ -89,7 +89,7 @@ public:
* \param[in] buf_len Number of bytes allocated for the buffer
* \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);
@@ -98,9 +98,9 @@ public:
*
* \param[in] buf Byte stream that should be sent
* \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);

View File

@@ -59,18 +59,38 @@ protected:
bool setup(std::string& host, int port);
public:
/*!
* \brief Creates a TCPSocket object
*/
TCPSocket();
virtual ~TCPSocket();
/*!
* \brief Getter for the state of the socket.
*
* \returns Returns the current state of the socket
*/
SocketState getState()
{
return state_;
}
/*!
* \brief Getter for the file descriptor of the socket.
*
* \returns The file descriptor of the socket
*/
int getSocketFD()
{
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);
/*!