Changeset 178 in flair-src
- Timestamp:
- May 19, 2017, 4:15:52 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/demos/SimpleFleet/uav/src/SimpleFleet.cpp
r167 r178 37 37 #include <Tab.h> 38 38 #include <Pid.h> 39 #include < Socket.h>39 #include <UdpSocket.h> 40 40 #include <string.h> 41 41 … … 76 76 u_y->UseDefaultPlot(graphLawTab->LastRowLastCol()); 77 77 78 message=new Socket(uav,"Message",broadcast,true);78 message=new UdpSocket(uav,"Message",broadcast,true); 79 79 80 80 customReferenceOrientation= new AhrsData(this,"reference"); -
trunk/demos/SimpleFleet/uav/src/SimpleFleet.h
r167 r178 20 20 namespace core { 21 21 class FrameworkManager; 22 class Socket;22 class UdpSocket; 23 23 class AhrsData; 24 24 } … … 72 72 flair::core::Vector2Df posHold; 73 73 float yawHold; 74 flair::core:: Socket *message;74 flair::core::UdpSocket *message; 75 75 flair::core::Time posWait; 76 76 -
trunk/lib/FlairCore/src/UdpSocket.cpp
r177 r178 4 4 // %flair:license} 5 5 // created: 2013/11/17 6 // filename: Socket.cpp6 // filename: UdpSocket.cpp 7 7 // 8 8 // author: Guillaume Sanahuja … … 15 15 // 16 16 /*********************************************************************/ 17 #include " Socket.h"18 #include " Socket_impl.h"17 #include "UdpSocket.h" 18 #include "UdpSocket_impl.h" 19 19 #include <FrameworkManager.h> 20 20 #include <string.h> … … 26 26 namespace core { 27 27 28 Socket::Socket(const Object *parent, string name, uint16_t port)28 UdpSocket::UdpSocket(const Object *parent, string name, uint16_t port) 29 29 : Object(parent, name) { 30 pimpl_ = new Socket_impl(this, name, port);30 pimpl_ = new UdpSocket_impl(this, name, port); 31 31 } 32 32 33 Socket::Socket(const Object *parent, string name, string address,33 UdpSocket::UdpSocket(const Object *parent, string name, string address, 34 34 bool broadcast) 35 35 : Object(parent, name) { 36 pimpl_ = new Socket_impl(this, name, address, broadcast);36 pimpl_ = new UdpSocket_impl(this, name, address, broadcast); 37 37 } 38 38 39 Socket::~Socket() { delete pimpl_; }39 UdpSocket::~UdpSocket() { delete pimpl_; } 40 40 41 void Socket::SendMessage(const char *message, size_t message_len) {41 void UdpSocket::SendMessage(const char *message, size_t message_len) { 42 42 pimpl_->SendMessage(message, message_len); 43 43 } 44 44 45 void Socket::SendMessage(string message) { pimpl_->SendMessage(message); }45 void UdpSocket::SendMessage(string message) { pimpl_->SendMessage(message); } 46 46 47 ssize_t Socket::RecvMessage(char *buf, size_t buf_len, Time timeout, char *src,47 ssize_t UdpSocket::RecvMessage(char *buf, size_t buf_len, Time timeout, char *src, 48 48 size_t *src_len) { 49 49 return pimpl_->RecvMessage(buf, buf_len, timeout, src, src_len); 50 50 } 51 51 52 void Socket::NetworkToHost(char *data, size_t dataSize) {52 void UdpSocket::NetworkToHost(char *data, size_t dataSize) { 53 53 if (core::IsBigEndian()) 54 54 return; … … 69 69 } 70 70 71 void Socket::HostToNetwork(char *data, size_t dataSize) {71 void UdpSocket::HostToNetwork(char *data, size_t dataSize) { 72 72 if (IsBigEndian()) 73 73 return; -
trunk/lib/FlairCore/src/UdpSocket.h
r177 r178 11 11 */ 12 12 13 #ifndef SOCKET_H14 #define SOCKET_H13 #ifndef UDPSOCKET_H 14 #define UDPSOCKET_H 15 15 16 16 #include <unistd.h> … … 18 18 #include <Object.h> 19 19 20 class Socket_impl;20 class UdpSocket_impl; 21 21 22 22 namespace flair { 23 23 namespace core { 24 24 25 /*! \class Socket25 /*! \class UdpSocket 26 26 * 27 27 * \brief Class encapsulating a UDP socket. It assumes packets are coming from … … 29 29 * 30 30 */ 31 class Socket : public Object {31 class UdpSocket : public Object { 32 32 public: 33 33 /*! … … 41 41 * \param broadcast true if address is a broadcast address 42 42 */ 43 Socket(const Object *parent, std::string name, std::string address,43 UdpSocket(const Object *parent, std::string name, std::string address, 44 44 bool broadcast = false); 45 45 … … 53 53 * \param port listening port 54 54 */ 55 Socket(const Object *parent, std::string name, uint16_t port);55 UdpSocket(const Object *parent, std::string name, uint16_t port); 56 56 57 57 /*! … … 59 59 * 60 60 */ 61 ~ Socket();61 ~UdpSocket(); 62 62 63 63 /*! … … 103 103 104 104 private: 105 class Socket_impl *pimpl_;105 class UdpSocket_impl *pimpl_; 106 106 }; 107 107 … … 109 109 } // end namespace flair 110 110 111 #endif // SOCKET_H111 #endif // UDPSOCKET_H -
trunk/lib/FlairCore/src/UdpSocket_impl.cpp
r177 r178 15 15 // 16 16 /*********************************************************************/ 17 #include " Socket_impl.h"18 #include " Socket.h"17 #include "UdpSocket_impl.h" 18 #include "UdpSocket.h" 19 19 #include "FrameworkManager.h" 20 20 #include <fcntl.h> … … 29 29 using namespace flair::core; 30 30 31 Socket_impl::Socket_impl(constSocket *self, string name, uint16_t port) {31 UdpSocket_impl::UdpSocket_impl(const UdpSocket *self, string name, uint16_t port) { 32 32 this->self = self; 33 33 this->port = port; … … 37 37 } 38 38 39 Socket_impl::Socket_impl(constSocket *self, string name, string address,39 UdpSocket_impl::UdpSocket_impl(const UdpSocket *self, string name, string address, 40 40 bool broadcast) { 41 41 this->self = self; … … 51 51 } 52 52 53 void Socket_impl::Init(void) {53 void UdpSocket_impl::Init(void) { 54 54 int yes = 1; 55 55 … … 143 143 } 144 144 145 Socket_impl::~Socket_impl() {145 UdpSocket_impl::~UdpSocket_impl() { 146 146 #ifdef __XENO__ 147 147 is_running = false; … … 157 157 } 158 158 159 void Socket_impl::SendMessage(const char *src, size_t src_len) {159 void UdpSocket_impl::SendMessage(const char *src, size_t src_len) { 160 160 ssize_t written; 161 161 string to_send; … … 189 189 } 190 190 191 void Socket_impl::SendMessage(string message) {191 void UdpSocket_impl::SendMessage(string message) { 192 192 ssize_t written; 193 193 … … 214 214 } 215 215 216 ssize_t Socket_impl::RecvMessage(char *msg, size_t msg_len, Time timeout,216 ssize_t UdpSocket_impl::RecvMessage(char *msg, size_t msg_len, Time timeout, 217 217 char *src, size_t *src_len) { 218 218 ssize_t nb_read; … … 291 291 292 292 #ifdef __XENO__ 293 void * Socket_impl::user(void *arg) {294 Socket_impl *caller = (Socket_impl *)arg;293 void *UdpSocket_impl::user(void *arg) { 294 UdpSocket_impl *caller = (UdpSocket_impl *)arg; 295 295 int pipe_fd = -1; 296 296 string devname; -
trunk/lib/FlairCore/src/unexported/UdpSocket_impl.h
r177 r178 4 4 // %flair:license} 5 5 /*! 6 * \file Socket_impl.h6 * \file UdpSocket_impl.h 7 7 * \brief Classe creant une socket 8 8 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253 … … 11 11 */ 12 12 13 #ifndef SOCKET_IMPL_H14 #define SOCKET_IMPL_H13 #ifndef UDPSOCKET_IMPL_H 14 #define UDPSOCKET_IMPL_H 15 15 16 16 #include <sys/socket.h> … … 21 21 #endif 22 22 23 namespace flair { 24 namespace core { 25 class Socket; 26 } 27 } 23 namespace flair { namespace core { 24 class UdpSocket; 25 } } 28 26 29 class Socket_impl {27 class UdpSocket_impl { 30 28 public: 31 Socket_impl(const flair::core::Socket *self, std::string name,29 UdpSocket_impl(const flair::core::UdpSocket *self, std::string name, 32 30 std::string address, bool broadcast = false); 33 Socket_impl(const flair::core::Socket *self, std::string name, uint16_t port);34 ~ Socket_impl();31 UdpSocket_impl(const flair::core::UdpSocket *self, std::string name, uint16_t port); 32 ~UdpSocket_impl(); 35 33 36 34 void SendMessage(std::string message); … … 45 43 bool broadcast; 46 44 void Init(void); 47 const flair::core:: Socket *self;45 const flair::core::UdpSocket *self; 48 46 struct sockaddr_in sock_in; 49 47 #ifdef __XENO__ … … 55 53 }; 56 54 57 #endif // SOCKET_IMPL_H55 #endif // UDPSOCKET_IMPL_H -
trunk/lib/FlairSensorActuator/src/EmulatedController.cpp
r157 r178 14 14 #include <Controller.h> 15 15 #include <TcpSocket.h> 16 #include < Socket.h>16 #include <UdpSocket.h> 17 17 #include <cstring> 18 18 #include <string> -
trunk/lib/FlairSensorActuator/src/HostEthController.cpp
r137 r178 26 26 #include <TargetController.h> 27 27 #include <TcpSocket.h> 28 #include < Socket.h>28 #include <UdpSocket.h> 29 29 #include <cstring> 30 30 #include <string> … … 54 54 controlSocket = new TcpSocket((Thread *)this, "eth controller control socket", 55 55 blocking, !blocking); 56 dataSocket = new Socket((Thread *)this, "eth controller data socket",56 dataSocket = new UdpSocket((Thread *)this, "eth controller data socket", 57 57 _address + ":" + std::to_string(_port + 1)); 58 58 dataSender = -
trunk/lib/FlairSensorActuator/src/HostEthController.h
r137 r178 28 28 class cvmatrix; 29 29 class TcpSocket; 30 class Socket;30 class UdpSocket; 31 31 class Mutex; 32 32 } … … 64 64 std::string controllerName; 65 65 core::TcpSocket *controlSocket; // connection to the target 66 core:: Socket *dataSocket;66 core::UdpSocket *dataSocket; 67 67 std::string targetAddress; 68 68 int targetPort; -
trunk/lib/FlairSensorActuator/src/TargetEthController.cpp
r137 r178 21 21 #include <FrameworkManager.h> 22 22 #include <TcpSocket.h> 23 #include < Socket.h>23 #include <UdpSocket.h> 24 24 #include <cstring> 25 25 #include <string> … … 44 44 new TcpSocket(getFrameworkManager(), "TEC_listening_socket", blocking, blocking); 45 45 dataSocket = 46 new Socket(getFrameworkManager(), "TEC_data_socket", _port + 1); // receiving side46 new UdpSocket(getFrameworkManager(), "TEC_data_socket", _port + 1); // receiving side 47 47 } 48 48 -
trunk/lib/FlairSensorActuator/src/TargetEthController.h
r137 r178 29 29 class cvmatrix; 30 30 class TcpSocket; 31 class Socket;31 class UdpSocket; 32 32 } 33 33 namespace gui { … … 78 78 int listeningPort; 79 79 core::TcpSocket *controlSocket = NULL; 80 core:: Socket *dataSocket;80 core::UdpSocket *dataSocket; 81 81 std::string *axisName = NULL; 82 82 std::string *buttonName = NULL; -
trunk/tools/Controller/Mavlink/src/Forwarder.cpp
r137 r178 18 18 #include "Forwarder.h" 19 19 20 #include < Socket.h>20 #include <UdpSocket.h> 21 21 #include <Thread.h> 22 22 #include <FrameworkManager.h> … … 41 41 // cout << "output socket : " << outputAddress + ":" + to_string(outputPort) << endl; 42 42 43 inputSocket = new Socket((Thread *)this, "input socket", inputPort);44 outputSocket = new Socket((Thread *)this, "output socket", outputAddress + ":" + to_string(outputPort));43 inputSocket = new UdpSocket((Thread *)this, "input socket", inputPort); 44 outputSocket = new UdpSocket((Thread *)this, "output socket", outputAddress + ":" + to_string(outputPort)); 45 45 } 46 46 -
trunk/tools/Controller/Mavlink/src/Forwarder.h
r137 r178 23 23 #include <Thread.h> 24 24 25 namespace flair { 26 namespace core { 27 class Socket; 28 } 29 } 25 namespace flair { namespace core { 26 class UdpSocket; 27 } } 30 28 31 29 class Forwarder : public flair::core::Thread { … … 41 39 void Run(); 42 40 43 flair::core:: Socket *inputSocket;41 flair::core::UdpSocket *inputSocket; 44 42 std::string inputAddress; 45 43 int inputPort; … … 47 45 const int inputBufferSize = 200; 48 46 49 flair::core:: Socket *outputSocket;47 flair::core::UdpSocket *outputSocket; 50 48 std::string outputAddress; 51 49 int outputPort; -
trunk/tools/Controller/Mavlink/src/GuiFlair.cpp
r137 r178 20 20 #include "GuiInterface.h" 21 21 22 #include < Socket.h>22 #include <UdpSocket.h> 23 23 24 24 //todo remove for tests … … 34 34 cout << "MavPlanner GuiFlair constructor" << endl; 35 35 36 outputSocket = new Socket((Thread *)this, "output socket", "127.0.0.1:5036");36 outputSocket = new UdpSocket((Thread *)this, "output socket", "127.0.0.1:5036"); 37 37 38 38 // outputSocket = new Socket(parent, "output socket", "127.255.255.255:9001", true); 39 inputSocket = new Socket((Thread *)this, "input socket", 9001);39 inputSocket = new UdpSocket((Thread *)this, "input socket", 9001); 40 40 } 41 41 -
trunk/tools/Controller/Mavlink/src/GuiFlair.h
r137 r178 24 24 #include "GuiInterface.h" 25 25 26 namespace flair { 27 namespace core { 28 class Socket; 29 } 30 } 26 namespace flair { namespace core { 27 class UdpSocket; 28 } } 31 29 32 30 class GuiFlair : public GuiInterface { … … 44 42 45 43 private: 46 flair::core:: Socket *inputSocket;47 flair::core:: Socket *outputSocket;44 flair::core::UdpSocket *inputSocket; 45 flair::core::UdpSocket *outputSocket; 48 46 std::string outputAddress; 49 47 int outputPort;
Note:
See TracChangeset
for help on using the changeset viewer.