mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-25 09:03:34 +08:00
uxrce_dds_client: refactor init to retry indefinitely
- move init from UxrceddsClient to init() method so that retry is possible for both serial and UDP init
This commit is contained in:
@@ -44,6 +44,10 @@
|
||||
|
||||
#include <lib/timesync/Timesync.hpp>
|
||||
|
||||
#if defined(CONFIG_NET) || defined(__PX4_POSIX)
|
||||
# define UXRCE_DDS_CLIENT_UDP 1
|
||||
#endif
|
||||
|
||||
#include "srv_base.h"
|
||||
|
||||
#define MAX_NUM_REPLIERS 5
|
||||
@@ -108,7 +112,11 @@ public:
|
||||
void delete_repliers();
|
||||
|
||||
private:
|
||||
int setBaudrate(int fd, unsigned baud);
|
||||
|
||||
bool init();
|
||||
void deinit();
|
||||
|
||||
bool setBaudrate(int fd, unsigned baud);
|
||||
|
||||
void handleMessageFormatRequest();
|
||||
|
||||
@@ -118,6 +126,12 @@ private:
|
||||
/** Synchronizes the system clock if the time is off by more than 5 seconds */
|
||||
void syncSystemClock(uxrSession *session);
|
||||
|
||||
Transport _transport{};
|
||||
|
||||
uxrSerialTransport *_transport_serial{nullptr};
|
||||
char _device[32] {};
|
||||
int _baudrate{};
|
||||
|
||||
const char *_client_namespace;
|
||||
|
||||
enum class ParticipantConfig {
|
||||
@@ -130,13 +144,15 @@ private:
|
||||
|
||||
// max port characters (5+'\0')
|
||||
static const uint8_t PORT_MAX_LENGTH = 6;
|
||||
|
||||
// max agent ip characters (15+'\0')
|
||||
static const uint8_t AGENT_IP_MAX_LENGTH = 16;
|
||||
|
||||
#if defined(CONFIG_NET) || defined(__PX4_POSIX)
|
||||
char _port[PORT_MAX_LENGTH];
|
||||
char _agent_ip[AGENT_IP_MAX_LENGTH];
|
||||
#endif
|
||||
#if defined(UXRCE_DDS_CLIENT_UDP)
|
||||
char _port[PORT_MAX_LENGTH] {};
|
||||
char _agent_ip[AGENT_IP_MAX_LENGTH] {};
|
||||
uxrUDPTransport *_transport_udp{nullptr};
|
||||
#endif // UXRCE_DDS_CLIENT_UDP
|
||||
|
||||
SendTopicsSubs *_subs{nullptr};
|
||||
RcvTopicsPubs *_pubs{nullptr};
|
||||
@@ -144,8 +160,6 @@ private:
|
||||
SrvBase *repliers_[MAX_NUM_REPLIERS];
|
||||
uint8_t num_of_repliers{0};
|
||||
|
||||
uxrSerialTransport *_transport_serial{nullptr};
|
||||
uxrUDPTransport *_transport_udp{nullptr};
|
||||
uxrCommunication *_comm{nullptr};
|
||||
int _fd{-1};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user