40 #include <px4_platform_common/log.h> 41 #include <px4_platform_common/shmem.h> 48 #define MUORB_KRAIT_FASTRPC_MEM_FLAGS 0 52 #define MUORB_KRAIT_FASTRPC_HEAP_ID 22 73 #define DSP_TIMER_FILE "/sys/kernel/boot_adsp/qdsp_qtimer" 88 #if defined(__PX4_POSIX_EXCELSIOR) 100 int bytes_read =
read(fd, buffer,
sizeof(buffer));
102 if (bytes_read < 0) {
110 clock_gettime(CLOCK_MONOTONIC, &ts);
111 uint64_t time_appsproc = ((uint64_t) ts.tv_sec) * 1000000llu
112 + (ts.tv_nsec / 1000);
117 int ret = sscanf(buffer,
"%llx", &time_dsp);
120 PX4_ERR(
"Could not parse DSP timer.");
130 (time_appsproc > time_dsp) ?
131 (time_appsproc - time_dsp) : (time_dsp - time_appsproc);
133 if (abs_diff > INT32_MAX) {
134 PX4_ERR(
"Timer difference too big");
138 *time_diff_us = time_appsproc - time_dsp;
140 PX4_DEBUG(
"found time_dsp: %llu us, time_appsproc: %llu us",
141 time_dsp, time_appsproc);
142 PX4_DEBUG(
"found time_diff: %li us, %.6f s",
143 *time_diff_us, ((
double)*time_diff_us) / 1e6);
152 PX4_DEBUG(
"%s Now calling rpcmem_init...", __FUNCTION__);
155 PX4_DEBUG(
"%s Now calling rpcmem_alloc...", __FUNCTION__);
163 PX4_ERR(
"%s rpcmem_alloc failed! for bulk transfer buffers",
169 "%s rpcmem_alloc passed for Bulk transfer buffers buffer_size: %d addr: %p",
180 PX4_ERR(
"%s rpcmem_alloc failed! for topic_name_buffer", __FUNCTION__);
185 PX4_DEBUG(
"%s rpcmem_alloc passed for topic_name_buffer", __FUNCTION__);
196 PX4_ERR(
"%s rpcmem_alloc failed! for DataBuffer", __FUNCTION__);
204 PX4_DEBUG(
"%s rpcmem_alloc passed for data_buffer", __FUNCTION__);
213 PX4_ERR(
"%s rpcmem_alloc failed! for adsp_changed_index", __FUNCTION__);
219 int32_t time_diff_us;
228 PX4_ERR(
"%s Error calling the uorb fastrpc initalize method..",
242 int diff = (time_dsp - time_appsproc);
244 PX4_DEBUG(
"time_dsp: %llu us, time appsproc: %llu us, diff: %d us",
245 time_dsp, time_appsproc, diff);
304 int32_t length_in_bytes,
const uint8_t *
data)
311 int32_t *length_in_bytes, uint8_t **
data)
325 PX4_ERR(
"ERROR: Getting data from fastRPC link");
329 PX4_ERR(
"ERROR: FastRpcWrapper Not Initialized");
336 int32_t *length_in_bytes, int32_t *topic_count)
349 PX4_ERR(
"ERROR: Getting Bulk data from fastRPC link");
353 PX4_ERR(
"ERROR: FastRpcWrapper Not Initialized");
bool Initialize()
Initiatizes the rpc channel px4 muorb.
static struct vehicle_status_s status
int px4muorb_add_subscriber(const char *name)
int px4muorb_receive_bulk_data(uint8_t *bulk_transfer_buffer, int max_size_in_bytes, int *returned_length_in_bytes, int *topic_count)
int px4muorb_topic_advertised(const char *topic_name)
int32_t AddSubscriber(const char *topic)
High-resolution timer with callouts and timekeeping.
bool Terminate()
Terminate to clean up the resources.
int px4muorb_is_subscriber_present(const char *topic_name, int *status)
int32_t TopicAdvertised(const char *topic)
Muorb related functions to pub/sub of orb topic from krait to adsp.
static void read(bootloader_app_shared_t *pshared)
int calc_timer_diff_to_dsp_us(int32_t *time_diff_us)
Helper function to get timer difference between time on DSP and appsproc side.
int32_t UnblockReceiveData()
int px4muorb_get_absolute_time(uint64_t *time_us)
int px4muorb_topic_unadvertised(const char *topic_name)
#define MUORB_KRAIT_FASTRPC_MEM_FLAGS
__END_DECLS int px4muorb_orb_initialize()
int px4muorb_unblock_recieve_msg(void)
static uint8_t * _DataBuffer
#define MUORB_KRAIT_FASTRPC_HEAP_ID
int32_t TopicUnadvertised(const char *topic)
int px4muorb_send_topic_data(const char *name, const uint8_t *data, int data_len_in_bytes)
int px4muorb_remove_subscriber(const char *name)
int px4muorb_set_absolute_time_offset(int32_t time_diff_us)
int px4muorb_receive_msg(int *msg_type, char *topic_name, int topic_name_len, uint8_t *data, int data_len_in_bytes, int *bytes_returned)
static const uint32_t _MAX_TOPIC_DATA_BUFFER_SIZE
static const int32_t _MAX_TOPIC_NAME_BUFFER
unsigned char * adsp_changed_index
static char * _TopicNameBuffer
int32_t RemoveSubscriber(const char *topic)
int32_t IsSubscriberPresent(const char *topic, int32_t *status)
int32_t ReceiveBulkData(uint8_t **bulk_data, int32_t *length_in_bytes, int32_t *topic_count)
static uint8_t * _BulkTransferBuffer
int32_t SendData(const char *topic, int32_t length_in_bytes, const uint8_t *data)
int32_t ReceiveData(int32_t *msg_type, char **topic, int32_t *length_in_bytes, uint8_t **data)
static const uint32_t _MAX_TOPICS
static const uint32_t _MAX_DATA_BUFFER_SIZE
static const uint32_t _MAX_BULK_TRANSFER_BUFFER_SIZE
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).