ardupilot/libraries/AP_HAL_Linux/UDPDevice.cpp

51 lines
659 B
C++
Raw Normal View History

2015-06-15 18:01:14 -03:00
#include <AP_HAL.h>
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
#include <stdio.h>
#include "UDPDevice.h"
UDPDevice::UDPDevice(const char *ip, uint16_t port):
_ip(ip),
_port(port)
{
}
UDPDevice::~UDPDevice()
{
}
ssize_t UDPDevice::write(const uint8_t *buf, uint16_t n)
{
return socket.send(buf, n);
2015-06-15 18:01:14 -03:00
}
ssize_t UDPDevice::read(uint8_t *buf, uint16_t n)
{
2015-07-28 19:39:29 -03:00
return socket.recv(buf, n, 0);
2015-06-15 18:01:14 -03:00
}
bool UDPDevice::open()
{
return socket.connect(_ip, _port);
2015-06-15 18:01:14 -03:00
}
bool UDPDevice::close()
{
return true;
}
void UDPDevice::set_blocking(bool blocking)
{
socket.set_blocking(blocking);
}
void UDPDevice::set_speed(uint32_t speed)
{
}
#endif