Skip to content

Commit

Permalink
Merge pull request #1 from paparazzi/master
Browse files Browse the repository at this point in the history
Update messages
  • Loading branch information
spacewolfXfr authored Oct 30, 2023
2 parents f7b5dc9 + d4bfd94 commit 3a756f7
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 82 deletions.
6 changes: 3 additions & 3 deletions lib/v1.0/C/pprzlog_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static void start_message(struct pprzlog_transport *trans, struct link_device *d
trans->ck = 0;
uint8_t buf[] = { msg_len, 0 }; // TODO use correct source ID
put_bytes(trans, dev, fd, DL_TYPE_UINT8, DL_FORMAT_SCALAR, buf, 2);
uint32_t ts = trans->get_time_usec() / 100;
uint32_t ts = trans->get_time_usec100();
put_bytes(trans, dev, fd, DL_TYPE_TIMESTAMP, DL_FORMAT_SCALAR, (uint8_t *)(&ts), 4);
}

Expand All @@ -110,7 +110,7 @@ static int check_available_space(struct pprzlog_transport *trans __attribute__((
return dev->check_free_space(dev->periph, fd, bytes);
}

void pprzlog_transport_init(struct pprzlog_transport *t, get_time_usec_t get_time_usec)
void pprzlog_transport_init(struct pprzlog_transport *t, get_time_usec100_t get_time_usec100)
{
t->trans_tx.size_of = (size_of_t) size_of;
t->trans_tx.check_available_space = (check_available_space_t) check_available_space;
Expand All @@ -121,6 +121,6 @@ void pprzlog_transport_init(struct pprzlog_transport *t, get_time_usec_t get_tim
t->trans_tx.overrun = (overrun_t) overrun;
t->trans_tx.count_bytes = (count_bytes_t) count_bytes;
t->trans_tx.impl = (void *)(t);
t->get_time_usec = get_time_usec;
t->get_time_usec100 = get_time_usec100;
}

6 changes: 3 additions & 3 deletions lib/v1.0/C/pprzlog_transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ extern "C" {

#include "pprzlink/pprzlink_transport.h"

typedef uint32_t (*get_time_usec_t)(void);
typedef uint32_t (*get_time_usec100_t)(void);

struct pprzlog_transport {
// generic transmission interface
struct transport_tx trans_tx;
// specific pprz transport_tx variables
uint8_t ck;
// get current time function pointer
get_time_usec_t get_time_usec;
get_time_usec100_t get_time_usec100;
};

// Init function
extern void pprzlog_transport_init(struct pprzlog_transport *t, uint32_t (*get_time_usec_t)(void));
extern void pprzlog_transport_init(struct pprzlog_transport *t, uint32_t (*get_time_usec100_t)(void));

#ifdef __cplusplus
} /* extern "C" */
Expand Down
6 changes: 3 additions & 3 deletions lib/v2.0/C/pprzlog_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static void start_message(struct pprzlink_msg *msg, long fd, uint8_t payload_len
get_pprzlog_trans(msg)->ck = 0;
uint8_t buf[] = { msg_len, 0 }; // TODO use correct source ID
put_bytes(msg, fd, DL_TYPE_UINT8, DL_FORMAT_SCALAR, buf, 2);
uint32_t ts = get_pprzlog_trans(msg)->get_time_usec() / 100;
uint32_t ts = get_pprzlog_trans(msg)->get_time_usec100();
put_bytes(msg, fd, DL_TYPE_TIMESTAMP, DL_FORMAT_SCALAR, (uint8_t *)(&ts), 4);
}

Expand All @@ -112,7 +112,7 @@ static int check_available_space(struct pprzlink_msg *msg, long *fd, uint16_t by
return msg->dev->check_free_space(msg->dev->periph, fd, bytes);
}

void pprzlog_transport_init(struct pprzlog_transport *t, get_time_usec_t get_time_usec)
void pprzlog_transport_init(struct pprzlog_transport *t, get_time_usec100_t get_time_usec100)
{
t->trans_tx.size_of = (size_of_t) size_of;
t->trans_tx.check_available_space = (check_available_space_t) check_available_space;
Expand All @@ -123,6 +123,6 @@ void pprzlog_transport_init(struct pprzlog_transport *t, get_time_usec_t get_tim
t->trans_tx.overrun = (overrun_t) overrun;
t->trans_tx.count_bytes = (count_bytes_t) count_bytes;
t->trans_tx.impl = (void *)(t);
t->get_time_usec = get_time_usec;
t->get_time_usec100 = get_time_usec100;
}

6 changes: 3 additions & 3 deletions lib/v2.0/C/pprzlog_transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ extern "C" {

#include "pprzlink/pprzlink_transport.h"

typedef uint32_t (*get_time_usec_t)(void);
typedef uint32_t (*get_time_usec100_t)(void);

struct pprzlog_transport {
// generic transmission interface
struct transport_tx trans_tx;
// specific pprz transport_tx variables
uint8_t ck;
// get current time function pointer
get_time_usec_t get_time_usec;
get_time_usec100_t get_time_usec100;
};

// Init function
extern void pprzlog_transport_init(struct pprzlog_transport *t, uint32_t (*get_time_usec_t)(void));
extern void pprzlog_transport_init(struct pprzlog_transport *t, uint32_t (*get_time_usec100_t)(void));

#ifdef __cplusplus
} /* extern "C" */
Expand Down
2 changes: 2 additions & 0 deletions message_definitions/common/units.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@
<unit from="rad" to="deg" coef="57.2957795131" auto="display"/>
<unit from="deg/s" to="rad/s" coef="0.0174532925" auto="code"/>
<unit from="rad/s" to="deg/s" coef="57.2957795131" auto="display"/>
<unit from="deg/s2" to="rad/s2" coef="0.0174532925" auto="code"/>
<unit from="rad/s2" to="deg/s2" coef="57.2957795131" auto="display"/>
</units>
Loading

0 comments on commit 3a756f7

Please sign in to comment.