36 #include <px4_platform_common/px4_config.h> 45 #include <uavcan/node/sub_node.hpp> 46 #include <uavcan/protocol/node_status_monitor.hpp> 47 #include <uavcan/protocol/param/GetSet.hpp> 48 #include <uavcan/protocol/param/ExecuteOpcode.hpp> 50 #include <uavcan/protocol/dynamic_node_id_server/centralized.hpp> 51 #include <uavcan/protocol/node_info_retriever.hpp> 52 #include <uavcan_posix/basic_file_server_backend.hpp> 53 #include <uavcan/protocol/firmware_update_trigger.hpp> 54 #include <uavcan/protocol/file_server.hpp> 55 #include <uavcan_posix/dynamic_node_id_server/file_event_tracer.hpp> 56 #include <uavcan_posix/dynamic_node_id_server/file_storage_backend.hpp> 57 #include <uavcan_posix/firmware_version_checker.hpp> 58 #include <uavcan/equipment/esc/RawCommand.hpp> 59 #include <uavcan/equipment/indication/BeepCommand.hpp> 60 #include <uavcan/protocol/enumeration/Begin.hpp> 61 #include <uavcan/protocol/enumeration/Indication.hpp> 80 static constexpr
unsigned NumIfaces = 1;
82 static constexpr
unsigned StackSize = 6000;
83 static constexpr
unsigned Priority = 120;
85 static constexpr
unsigned VirtualIfaceBlockAllocationQuota = 80;
87 static constexpr
float BeepFrequencyGenericIndication = 1000.0F;
88 static constexpr
float BeepFrequencySuccess = 2000.0F;
89 static constexpr
float BeepFrequencyError = 100.0F;
96 static int start(uavcan::INode &main_node);
99 uavcan::SubNode<> &
get_node() {
return _subnode; }
115 pthread_t _subnode_thread{-1};
116 pthread_mutex_t _subnode_mutex{};
117 volatile bool _subnode_thread_should_exit{
false};
121 pthread_addr_t run(pthread_addr_t);
130 uavcan_posix::dynamic_node_id_server::FileEventTracer
_tracer;
150 uint8_t _param_counts[128] = {};
151 bool _count_in_progress =
false;
152 uint8_t _count_index = 0;
154 bool _param_in_progress =
false;
155 uint8_t _param_index = 0;
156 bool _param_list_in_progress =
false;
157 bool _param_list_all_nodes =
false;
158 uint8_t _param_list_node_id = 1;
160 uint32_t _param_dirty_bitmap[4] = {};
161 uint8_t _param_save_opcode = 0;
163 bool _cmd_in_progress =
false;
170 void (UavcanServers::*)(
const uavcan::ServiceCallResult<uavcan::protocol::param::GetSet> &)>
GetSetCallback;
171 typedef uavcan::MethodBinder<UavcanServers *,
172 void (UavcanServers::*)(
const uavcan::ServiceCallResult<uavcan::protocol::param::ExecuteOpcode> &)>
174 typedef uavcan::MethodBinder<UavcanServers *,
175 void (UavcanServers::*)(
const uavcan::ServiceCallResult<uavcan::protocol::RestartNode> &)>
RestartNodeCallback;
177 void cb_getset(
const uavcan::ServiceCallResult<uavcan::protocol::param::GetSet> &result);
178 void cb_count(
const uavcan::ServiceCallResult<uavcan::protocol::param::GetSet> &result);
179 void cb_opcode(
const uavcan::ServiceCallResult<uavcan::protocol::param::ExecuteOpcode> &result);
180 void cb_restart(
const uavcan::ServiceCallResult<uavcan::protocol::RestartNode> &result);
186 void param_opcode(uavcan::NodeID node_id);
188 uint8_t get_next_active_node_id(uint8_t base);
189 uint8_t get_next_dirty_node_id(uint8_t base);
192 bool are_node_params_dirty(uint8_t node_id)
const {
return bool((_param_dirty_bitmap[node_id >> 5] >> (node_id & 31)) & 1); }
194 void beep(
float frequency);
196 bool _mutex_inited =
false;
197 volatile bool _check_fw =
false;
200 bool _esc_enumeration_active =
false;
201 uint8_t _esc_enumeration_ids[uavcan::equipment::esc::RawCommand::FieldTypes::cmd::MaxSize];
202 uint8_t _esc_enumeration_index = 0;
203 uint8_t _esc_count = 0;
205 typedef uavcan::MethodBinder<UavcanServers *,
206 void (UavcanServers::*)(
const uavcan::ServiceCallResult<uavcan::protocol::enumeration::Begin> &)>
208 typedef uavcan::MethodBinder<UavcanServers *,
209 void (UavcanServers::*)(
const uavcan::ReceivedDataStructure<uavcan::protocol::enumeration::Indication>&)>
211 void cb_enumeration_begin(
const uavcan::ServiceCallResult<uavcan::protocol::enumeration::Begin> &result);
212 void cb_enumeration_indication(
const uavcan::ReceivedDataStructure<uavcan::protocol::enumeration::Indication> &
msg);
213 void cb_enumeration_getset(
const uavcan::ServiceCallResult<uavcan::protocol::param::GetSet> &result);
214 void cb_enumeration_save(
const uavcan::ServiceCallResult<uavcan::protocol::param::ExecuteOpcode> &result);
216 uavcan::Publisher<uavcan::equipment::indication::BeepCommand>
_beep_pub;
217 uavcan::Subscriber<uavcan::protocol::enumeration::Indication, EnumerationIndicationCallback>
219 uavcan::ServiceClient<uavcan::protocol::enumeration::Begin, EnumerationBeginCallback>
_enumeration_client;
223 void unpackFwFromROMFS(
const char *sd_path,
const char *romfs_path);
224 int copyFw(
const char *dst,
const char *src);
void clear_node_params_dirty(uint8_t node_id)
uavcan::ServiceClient< uavcan::protocol::param::ExecuteOpcode, ExecuteOpcodeCallback > _param_opcode_client
uavcan::ServiceClient< uavcan::protocol::param::GetSet, GetSetCallback > _enumeration_getset_client
uavcan::ServiceClient< uavcan::protocol::param::GetSet, GetSetCallback > _param_getset_client
VirtualCanDriver _vdriver
void set_node_params_dirty(uint8_t node_id)
uavcan::FirmwareUpdateTrigger _fw_upgrade_trigger
bool guessIfAllDynamicNodesAreAllocated()
uavcan::INode & _main_node
uavcan::NodeInfoRetriever _node_info_retriever
uavcan::MethodBinder< UavcanServers *, void(UavcanServers::*)(const uavcan::ServiceCallResult< uavcan::protocol::param::ExecuteOpcode > &)> ExecuteOpcodeCallback
void attachITxQueueInjector(ITxQueueInjector **injector)
__EXPORT unsigned param_count(void)
Return the total number of parameters.
uavcan::MethodBinder< UavcanServers *, void(UavcanServers::*)(const uavcan::ReceivedDataStructure< uavcan::protocol::enumeration::Indication > &)> EnumerationIndicationCallback
bool are_node_params_dirty(uint8_t node_id) const
uavcan::MethodBinder< UavcanServers *, void(UavcanServers::*)(const uavcan::ServiceCallResult< uavcan::protocol::RestartNode > &)> RestartNodeCallback
static char msg[NUM_MSG][CONFIG_USART1_TXBUFSIZE]
Definitions for the generic base classes in the device framework.
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
uavcan_posix::dynamic_node_id_server::FileStorageBackend _storage_backend
void init()
Activates/configures the hardware registers.
static UavcanServers * _instance
singleton pointer
uavcan_posix::dynamic_node_id_server::FileEventTracer _tracer
A UAVCAN Server Sub node.
uavcan_posix::BasicFileServerBackend _fileserver_backend
uavcan::dynamic_node_id_server::CentralizedServer _server_instance
server singleton pointer
void requestCheckAllNodesFirmwareAndUpdate()
uavcan::SubNode & get_node()
uavcan::ServiceClient< uavcan::protocol::enumeration::Begin, EnumerationBeginCallback > _enumeration_client
uavcan::ServiceClient< uavcan::protocol::param::ExecuteOpcode, ExecuteOpcodeCallback > _enumeration_save_client
uavcan::ServiceClient< uavcan::protocol::RestartNode, RestartNodeCallback > _param_restartnode_client
uavcan::BasicFileServer _fw_server
uavcan::MethodBinder< UavcanServers *, void(UavcanServers::*)(const uavcan::ServiceCallResult< uavcan::protocol::enumeration::Begin > &)> EnumerationBeginCallback
uavcan_posix::FirmwareVersionChecker _fw_version_checker
Objects of this class are owned by the sub-node thread.
static UavcanServers * instance()
uavcan::MethodBinder< UavcanServers *, void(UavcanServers::*)(const uavcan::ServiceCallResult< uavcan::protocol::param::GetSet > &)> GetSetCallback
Performance measuring tools.
uavcan::Subscriber< uavcan::protocol::enumeration::Indication, EnumerationIndicationCallback > _enumeration_indication_sub
uavcan::Publisher< uavcan::equipment::indication::BeepCommand > _beep_pub
This interface defines one method that will be called by the main node thread periodically in order t...