mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-10 15:03:43 +08:00
HAL_Linux: UART-like TCP sockets impl. on AP_HAL_Linux
This commit is contained in:
committed by
Andrew Tridgell
parent
b0742fbb5b
commit
be68de20f1
@@ -46,6 +46,16 @@ HAL_Linux::HAL_Linux() :
|
||||
&utilInstance)
|
||||
{}
|
||||
|
||||
void _usage(void)
|
||||
{
|
||||
printf("Usage: -A uartAPath -B uartBPath -C uartCPath\n");
|
||||
printf("Options:\n");
|
||||
printf("\t-serial: -A /dev/ttyO4\n");
|
||||
printf("\t -B /dev/ttyS1\n");
|
||||
printf("\t-tcp: -C tcp:192.168.2.15:1243:wait\n");
|
||||
printf("\t -A tcp:11.0.0.2:5678\n");
|
||||
}
|
||||
|
||||
void HAL_Linux::init(int argc,char* const argv[]) const
|
||||
{
|
||||
int opt;
|
||||
@@ -64,7 +74,7 @@ void HAL_Linux::init(int argc,char* const argv[]) const
|
||||
uartCDriver.set_device_path(optarg);
|
||||
break;
|
||||
case 'h':
|
||||
printf("Usage: -A uartAPath -B uartBPath -C uartCPath\n");
|
||||
_usage();
|
||||
exit(0);
|
||||
default:
|
||||
printf("Unknown option '%c'\n", (char)opt);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -25,18 +25,22 @@ public:
|
||||
size_t write(uint8_t c);
|
||||
size_t write(const uint8_t *buffer, size_t size);
|
||||
|
||||
void set_device_path(const char *path);
|
||||
void set_device_path(char *path);
|
||||
|
||||
void _timer_tick(void);
|
||||
|
||||
private:
|
||||
const char *device_path;
|
||||
char *device_path;
|
||||
int _rd_fd;
|
||||
int _wr_fd;
|
||||
bool _nonblocking_writes;
|
||||
bool _console;
|
||||
volatile bool _initialised;
|
||||
volatile bool _in_timer;
|
||||
uint16_t _base_port;
|
||||
char *_ip;
|
||||
char *_flag;
|
||||
bool _connected; // true if a client has connected
|
||||
|
||||
// we use in-task ring buffers to reduce the system call cost
|
||||
// of ::read() and ::write() in the main loop
|
||||
@@ -55,7 +59,9 @@ private:
|
||||
|
||||
int _write_fd(const uint8_t *buf, uint16_t n);
|
||||
int _read_fd(uint8_t *buf, uint16_t n);
|
||||
uint64_t _last_write_time;
|
||||
void _tcp_start_connection(bool wait_for_connection);
|
||||
int _parseDevicePath(char* arg);
|
||||
uint64_t _last_write_time;
|
||||
};
|
||||
|
||||
#endif // __AP_HAL_LINUX_UARTDRIVER_H__
|
||||
|
||||
Reference in New Issue
Block a user