ardupilot/libraries/AP_HAL_Linux/UDPDevice.cpp
Andrew Tridgell a5c7aa1b19 HAL_Linux: allow startup before network bringup
this makes it possible to bootup ardupilot before the desired network
interface is available. This is very useful for when using 3G dongles
in aircraft
2015-07-29 09:55:47 +10:00

51 lines
659 B
C++

#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);
}
ssize_t UDPDevice::read(uint8_t *buf, uint16_t n)
{
return socket.recv(buf, n, 0);
}
bool UDPDevice::open()
{
return socket.connect(_ip, _port);
}
bool UDPDevice::close()
{
return true;
}
void UDPDevice::set_blocking(bool blocking)
{
socket.set_blocking(blocking);
}
void UDPDevice::set_speed(uint32_t speed)
{
}
#endif