Skip to content

Commit

Permalink
AP_HAL_Linux: renamed TCPServerDevice
Browse files Browse the repository at this point in the history
A more appropriate name for the class.
  • Loading branch information
staroselskii authored and tridge committed Jul 28, 2015
1 parent a3f4787 commit 211acbe
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,30 @@
#include <sys/socket.h>
#include <netdb.h>

#include "TCPServerDevice.h"
#include "TCPBlockingServerDevice.h"

TCPServerDevice::TCPServerDevice(const char *ip, uint16_t port):
TCPBlockingServerDevice::TCPBlockingServerDevice(const char *ip, uint16_t port):
_ip(ip),
_port(port)
{
}

TCPServerDevice::~TCPServerDevice()
TCPBlockingServerDevice::~TCPBlockingServerDevice()
{

}

ssize_t TCPServerDevice::write(const uint8_t *buf, uint16_t n)
ssize_t TCPBlockingServerDevice::write(const uint8_t *buf, uint16_t n)
{
return ::send(_net_fd, buf, n, 0);
}

ssize_t TCPServerDevice::read(uint8_t *buf, uint16_t n)
ssize_t TCPBlockingServerDevice::read(uint8_t *buf, uint16_t n)
{
return ::recv(_net_fd, buf, n, 0);
}

bool TCPServerDevice::open()
bool TCPBlockingServerDevice::open()
{
int one=1;
struct sockaddr_in sockaddr;
Expand Down Expand Up @@ -87,7 +87,7 @@ bool TCPServerDevice::open()
::fflush(stdout);

struct sockaddr_storage client_addr;
socklen_t addr_size;
socklen_t addr_size = sizeof(client_addr);

client_fd = accept(_listen_fd, (struct sockaddr *) &client_addr, &addr_size);

Expand All @@ -111,7 +111,7 @@ bool TCPServerDevice::open()
return true;
}

bool TCPServerDevice::close()
bool TCPBlockingServerDevice::close()
{
if (::close(_listen_fd) < 0) {
perror("close");
Expand All @@ -126,11 +126,11 @@ bool TCPServerDevice::close()
return true;
}

void TCPServerDevice::set_blocking(bool blocking)
void TCPBlockingServerDevice::set_blocking(bool blocking)
{
}

void TCPServerDevice::set_speed(uint32_t speed)
void TCPBlockingServerDevice::set_speed(uint32_t speed)
{

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#include "SerialDevice.h"
#include "../AP_HAL/utility/Socket.h"

class TCPServerDevice: public SerialDevice {
class TCPBlockingServerDevice: public SerialDevice {
public:
TCPServerDevice(const char *ip, uint16_t port);
virtual ~TCPServerDevice();
TCPBlockingServerDevice(const char *ip, uint16_t port);
virtual ~TCPBlockingServerDevice();

virtual bool open() override;
virtual bool close() override;
Expand Down
4 changes: 2 additions & 2 deletions libraries/AP_HAL_Linux/UARTDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "UDPDevice.h"
#include "ConsoleDevice.h"
#include "TCPClientDevice.h"
#include "TCPServerDevice.h"
#include "TCPBlockingServerDevice.h"

extern const AP_HAL::HAL& hal;

Expand Down Expand Up @@ -258,7 +258,7 @@ void LinuxUARTDriver::_tcp_start_connection(void)
{
if (_flag != NULL) {
if (!strcmp(_flag, "wait")) {
_device = new TCPServerDevice(_ip, _base_port);
_device = new TCPBlockingServerDevice(_ip, _base_port);
} else {
_device = new TCPClientDevice(_ip, _base_port);
}
Expand Down

0 comments on commit 211acbe

Please sign in to comment.