mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 09:22:18 +00:00
simulator udp port from command line
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
#include <systemlib/err.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <drivers/drv_led.h>
|
||||
@@ -124,21 +125,25 @@ void Simulator::write_airspeed_data(void *buf)
|
||||
int Simulator::start(int argc, char *argv[])
|
||||
{
|
||||
int ret = 0;
|
||||
int udp_port = 0;
|
||||
_instance = new Simulator();
|
||||
|
||||
if (_instance) {
|
||||
drv_led_start();
|
||||
|
||||
if (argc == 5 && strcmp(argv[3], "-u") == 0)
|
||||
udp_port = atoi(argv[4]);
|
||||
|
||||
if (argv[2][1] == 's') {
|
||||
_instance->initializeSensorData();
|
||||
#ifndef __PX4_QURT
|
||||
// Update sensor data
|
||||
_instance->pollForMAVLinkMessages(false);
|
||||
_instance->pollForMAVLinkMessages(false,udp_port);
|
||||
#endif
|
||||
|
||||
} else if (argv[2][1] == 'p') {
|
||||
// Update sensor data
|
||||
_instance->pollForMAVLinkMessages(true);
|
||||
_instance->pollForMAVLinkMessages(true,udp_port);
|
||||
|
||||
} else {
|
||||
_instance->initializeSensorData();
|
||||
@@ -155,7 +160,7 @@ int Simulator::start(int argc, char *argv[])
|
||||
|
||||
static void usage()
|
||||
{
|
||||
PX4_WARN("Usage: simulator {start -[spt] |stop}");
|
||||
PX4_WARN("Usage: simulator {start -[spt] [-u udp_port] |stop}");
|
||||
PX4_WARN("Simulate raw sensors: simulator start -s");
|
||||
PX4_WARN("Publish sensors combined: simulator start -p");
|
||||
PX4_WARN("Dummy unit test data: simulator start -t");
|
||||
@@ -171,7 +176,7 @@ extern "C" {
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (argc == 3 && strcmp(argv[1], "start") == 0) {
|
||||
if (argc > 2 && strcmp(argv[1], "start") == 0) {
|
||||
if (strcmp(argv[2], "-s") == 0 ||
|
||||
strcmp(argv[2], "-p") == 0 ||
|
||||
strcmp(argv[2], "-t") == 0) {
|
||||
|
||||
Reference in New Issue
Block a user