mirror of
https://gitlab.com/obbart/universal_robots_ros_driver.git
synced 2026-04-10 10:00:48 +02:00
Implemented URStream
This commit is contained in:
30
include/ur_modern_driver/ur/stream.h
Normal file
30
include/ur_modern_driver/ur/stream.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <atomic>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
|
||||
/// Encapsulates a TCP socket
|
||||
class URStream {
|
||||
private:
|
||||
int _socket_fd = -1;
|
||||
std::string _host;
|
||||
int _port;
|
||||
|
||||
std::atomic<bool> _initialized;
|
||||
std::atomic<bool> _stopping;
|
||||
|
||||
public:
|
||||
URStream(std::string &host, int port)
|
||||
: _host(host),
|
||||
_port(port),
|
||||
_initialized(false),
|
||||
_stopping(false) {}
|
||||
|
||||
bool connect();
|
||||
void disconnect();
|
||||
|
||||
ssize_t send(uint8_t *buf, size_t buf_len);
|
||||
ssize_t receive(uint8_t *buf, size_t buf_len);
|
||||
};
|
||||
Reference in New Issue
Block a user