From f66f5838436bb0c05c8353172ab240854279880b Mon Sep 17 00:00:00 2001 From: Staroselskii Georgii Date: Wed, 8 Jul 2015 20:27:21 +0300 Subject: [PATCH] AP_HAL_Linux: renamed TCPClientDevice --- ...TCPClientDevice.cpp => TCPServerDevice.cpp} | 18 +++++++++--------- .../{TCPClientDevice.h => TCPServerDevice.h} | 6 +++--- libraries/AP_HAL_Linux/UARTDriver.cpp | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) rename libraries/AP_HAL_Linux/{TCPClientDevice.cpp => TCPServerDevice.cpp} (60%) rename libraries/AP_HAL_Linux/{TCPClientDevice.h => TCPServerDevice.h} (81%) diff --git a/libraries/AP_HAL_Linux/TCPClientDevice.cpp b/libraries/AP_HAL_Linux/TCPServerDevice.cpp similarity index 60% rename from libraries/AP_HAL_Linux/TCPClientDevice.cpp rename to libraries/AP_HAL_Linux/TCPServerDevice.cpp index f16bad7ecd..19d5ff3733 100644 --- a/libraries/AP_HAL_Linux/TCPClientDevice.cpp +++ b/libraries/AP_HAL_Linux/TCPServerDevice.cpp @@ -7,30 +7,30 @@ #include #include -#include "TCPClientDevice.h" +#include "TCPServerDevice.h" -TCPClientDevice::TCPClientDevice(const char *ip, uint16_t port): +TCPServerDevice::TCPServerDevice(const char *ip, uint16_t port): _ip(ip), _port(port) { } -TCPClientDevice::~TCPClientDevice() +TCPServerDevice::~TCPServerDevice() { } -ssize_t TCPClientDevice::write(const uint8_t *buf, uint16_t n) +ssize_t TCPServerDevice::write(const uint8_t *buf, uint16_t n) { return listener.send(buf, n); } -ssize_t TCPClientDevice::read(uint8_t *buf, uint16_t n) +ssize_t TCPServerDevice::read(uint8_t *buf, uint16_t n) { return listener.recv(buf, n, 1); } -bool TCPClientDevice::open() +bool TCPServerDevice::open() { listener.reuseaddress(); @@ -47,17 +47,17 @@ bool TCPClientDevice::open() return true; } -bool TCPClientDevice::close() +bool TCPServerDevice::close() { return true; } -void TCPClientDevice::set_blocking(bool blocking) +void TCPServerDevice::set_blocking(bool blocking) { listener.set_blocking(blocking); } -void TCPClientDevice::set_speed(uint32_t speed) +void TCPServerDevice::set_speed(uint32_t speed) { } diff --git a/libraries/AP_HAL_Linux/TCPClientDevice.h b/libraries/AP_HAL_Linux/TCPServerDevice.h similarity index 81% rename from libraries/AP_HAL_Linux/TCPClientDevice.h rename to libraries/AP_HAL_Linux/TCPServerDevice.h index 97449484f8..240bccec8f 100644 --- a/libraries/AP_HAL_Linux/TCPClientDevice.h +++ b/libraries/AP_HAL_Linux/TCPServerDevice.h @@ -4,10 +4,10 @@ #include "SerialDevice.h" #include "../AP_HAL/utility/Socket.h" -class TCPClientDevice: public SerialDevice { +class TCPServerDevice: public SerialDevice { public: - TCPClientDevice(const char *ip, uint16_t port); - virtual ~TCPClientDevice(); + TCPServerDevice(const char *ip, uint16_t port); + virtual ~TCPServerDevice(); virtual bool open() override; virtual bool close() override; diff --git a/libraries/AP_HAL_Linux/UARTDriver.cpp b/libraries/AP_HAL_Linux/UARTDriver.cpp index 35395dca9b..6d8b00bad2 100644 --- a/libraries/AP_HAL_Linux/UARTDriver.cpp +++ b/libraries/AP_HAL_Linux/UARTDriver.cpp @@ -27,7 +27,7 @@ #include "UARTDevice.h" #include "UDPDevice.h" #include "ConsoleDevice.h" -#include "TCPClientDevice.h" +#include "TCPServerDevice.h" #include "TCPBlockingServerDevice.h" extern const AP_HAL::HAL& hal; @@ -260,10 +260,10 @@ void LinuxUARTDriver::_tcp_start_connection(void) if (!strcmp(_flag, "wait")) { _device = new TCPBlockingServerDevice(_ip, _base_port); } else { - _device = new TCPClientDevice(_ip, _base_port); + _device = new TCPServerDevice(_ip, _base_port); } } else { - _device = new TCPClientDevice(_ip, _base_port); + _device = new TCPServerDevice(_ip, _base_port); } if (_device->open()) {