Skip to content

Commit

Permalink
core: renamed ubx_node_info_t to ubx_node_t
Browse files Browse the repository at this point in the history
Also renamed all instances of "ni" to "nd"

Signed-off-by: Markus Klotzbuecher <mk@mkio.de>
  • Loading branch information
kmarkus committed Jun 11, 2020
1 parent ccc2057 commit b869ee6
Show file tree
Hide file tree
Showing 48 changed files with 613 additions and 611 deletions.
9 changes: 6 additions & 3 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ This file tracks user visible API changes

## 0.9.0

- `ubx-genblock` updated
- `ubx_node_info_t` renamed to `ubx_node_t` for
consistency. `ubx_node_t` variables renamed from `ni` to `nd`.

- `ubx-genblock` updated to generate state of the art blocks

- `ubx_ports_connect_uni`/`ubx_ports_disconnect_uni`/
- removed `_uni` suffix
- renamed: dropped `_uni` suffix
- made iblock parameter `const`

- `ubx_block_`: store `ports` and `configs` in a `utlist.h` double
Expand All @@ -17,7 +20,7 @@ This file tracks user visible API changes

- registration of static blocks has changed. Use the types
`ubx_proto_block_t`, `ubx_proto_port_t` and `ubx_proto_config_t` to
define blocks definition and `ubx_block_register(ubx_node_info_t*,
define blocks definition and `ubx_block_register(ubx_node_t*,
ubx_block_proto_t* bt)` to register them. Note that this **only**
changed for the static definition/registration of blocks. At runtime
(i.e. in hooks etc) the non-`_proto_` versions are used as before
Expand Down
14 changes: 7 additions & 7 deletions docs/user/developing_blocks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,10 @@ which is called when a module is loaded:

.. code:: c
1: static int rnd_module_init(ubx_node_info_t* ni)
1: static int rnd_module_init(ubx_node_t* ni)
2: {
3: ubx_type_register(ni, &random_config_type);
4: return ubx_block_register(ni, &random_comp);
3: ubx_type_register(nd, &random_config_type);
4: return ubx_block_register(nd, &random_comp);
5: }
6: UBX_MODULE_INIT(rnd_module_init)
Expand All @@ -442,10 +442,10 @@ blocks registered in init:

.. code:: c
static void rnd_module_cleanup(ubx_node_info_t *ni)
static void rnd_module_cleanup(ubx_node_t *nd)
{
ubx_type_unregister(ni, "struct random_config");
ubx_block_unregister(ni, "random/random");
ubx_type_unregister(nd, "struct random_config");
ubx_block_unregister(nd, "random/random");
}
UBX_MODULE_CLEANUP(rnd_module_cleanup)
Expand Down Expand Up @@ -502,7 +502,7 @@ Outside of the block context, (e.g. in ``module_init`` or

.. code:: c
ubx_log(int level, ubx_node_info_t *ni, const char* src, const char* fmt, ...)
ubx_log(int level, ubx_node_t *nd, const char* src, const char* fmt, ...)
/* for example */
ubx_log(UBX_LOGLEVEL_ERROR, ni, __FUNCTION__, "error %u", x);
Expand Down
2 changes: 1 addition & 1 deletion docs/user/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ the libraries
int main()
{
int len, ret=EXIT_FAILURE;
ubx_node_info_t ni;
ubx_node_t ni;
ubx_block_t *plat1, *control1, *logger1, *ptrig1, *webif, *fifo_vel, *fifo_pos;
ubx_data_t *d;
Expand Down
2 changes: 1 addition & 1 deletion examples/C-examples/c-only.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
int main(int argc, char **argv)
{
int len, ret=EXIT_FAILURE;
ubx_node_info_t ni;
ubx_node_t ni;
ubx_block_t *webif;
ubx_data_t *d;

Expand Down
2 changes: 1 addition & 1 deletion examples/platform/platform_launch/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
int main()
{
int len, ret=EXIT_FAILURE;
ubx_node_info_t ni;
ubx_node_t ni;
ubx_block_t *plat1, *control1, *logger1, *ptrig1, *webif, *fifo_vel, *fifo_pos;
ubx_data_t *d;

Expand Down
34 changes: 17 additions & 17 deletions libubx/rtlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const char *loglevel_str[] = {
#define CONFIG_LOGGING_SHM

/* basic logging function */
void __ubx_log(const int level, const ubx_node_info_t *ni, const char *src, const char *fmt, ...)
void __ubx_log(const int level, const ubx_node_t *nd, const char *src, const char *fmt, ...)
{
va_list args;
struct ubx_log_msg msg;
Expand All @@ -41,21 +41,21 @@ void __ubx_log(const int level, const ubx_node_info_t *ni, const char *src, cons
vsnprintf(msg.msg, UBX_LOG_MSG_MAXLEN, fmt, args);
va_end(args);

if (!ni->log) {
if (!nd->log) {
fprintf(stderr,
"ERROR: rtlog: node->log is NULL (msg: %s: %s)\n",
msg.src, msg.msg);
return;
}

ni->log(ni, &msg);
nd->log(nd, &msg);

return;

}

#ifdef CONFIG_SIMPLE_LOGGING
static void ubx_log_simple(const struct ubx_node_info *ni, const struct ubx_log_msg *msg)
static void ubx_log_simple(const struct ubx_node *nd, const struct ubx_log_msg *msg)
{
FILE *stream;
const char *level_str;
Expand All @@ -68,19 +68,19 @@ static void ubx_log_simple(const struct ubx_node_info *ni, const struct ubx_log_

fprintf(stream, "[%li.%06li] %s %s.%s: %s\n",
msg->ts.sec, msg->ts.nsec / NSEC_PER_USEC,
level_str, ni->name, msg->src, msg->msg);
level_str, nd->name, msg->src, msg->msg);
}

int ubx_log_init(struct ubx_node_info *ni)
int ubx_log_init(struct ubx_node *nd)
{
ni->log = ubx_log_simple;
ni->log_data = NULL;
nd->log = ubx_log_simple;
nd->log_data = NULL;
return 0;
}

void ubx_log_cleanup(struct ubx_node_info *ni)
void ubx_log_cleanup(struct ubx_node *nd)
{
ni->log = NULL;
nd->log = NULL;
}
#endif

Expand Down Expand Up @@ -130,10 +130,10 @@ static void log_inc_woff(uint32_t inc)
inf.buf_ptr->w = next;
}

static void ubx_log_shm(const struct ubx_node_info *ni, const struct ubx_log_msg *msg)
static void ubx_log_shm(const struct ubx_node *nd, const struct ubx_log_msg *msg)
{
struct ubx_log_msg *frame;
(void)(ni);
(void)(nd);

pthread_spin_lock(&inf.loglock);
frame = (struct ubx_log_msg *)&inf.buf_ptr->data[inf.buf_ptr->w.off];
Expand All @@ -143,13 +143,13 @@ static void ubx_log_shm(const struct ubx_node_info *ni, const struct ubx_log_msg
pthread_spin_unlock(&inf.loglock);
}

int ubx_log_init(struct ubx_node_info *ni)
int ubx_log_init(struct ubx_node *nd)
{
int ret = -1;

pthread_spin_init(&inf.loglock, PTHREAD_PROCESS_PRIVATE);
ni->log = ubx_log_shm;
ni->log_data = NULL;
nd->log = ubx_log_shm;
nd->log_data = NULL;

inf.shm_size = sizeof(log_wrap_off_t) + sizeof(struct ubx_log_msg) *
LOG_BUFFER_DEPTH;
Expand Down Expand Up @@ -195,10 +195,10 @@ int ubx_log_init(struct ubx_node_info *ni)
return ret;
}

void ubx_log_cleanup(struct ubx_node_info *ni)
void ubx_log_cleanup(struct ubx_node *nd)
{
pthread_spin_destroy(&inf.loglock);
ni->log = NULL;
nd->log = NULL;

/* clean up shm */
munmap((void *) inf.buf_ptr, inf.shm_size);
Expand Down
18 changes: 9 additions & 9 deletions libubx/rtlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

#define UBX_LOGLEVEL_DEFAULT UBX_LOGLEVEL_INFO

#define ubx_log(level, ni, src, fmt, ...) \
#define ubx_log(level, nd, src, fmt, ...) \
do { \
if (level <= (ni)->loglevel) \
__ubx_log(level, ni, src, fmt, ##__VA_ARGS__); \
if (level <= (nd)->loglevel) \
__ubx_log(level, nd, src, fmt, ##__VA_ARGS__); \
} while (0)

#ifdef UBX_DEBUG
Expand All @@ -36,24 +36,24 @@ do { \
do { \
if (b->loglevel) { \
if (level <= *b->loglevel) { \
__ubx_log(level, b->ni, b->name, fmt, ##__VA_ARGS__); \
__ubx_log(level, b->nd, b->name, fmt, ##__VA_ARGS__); \
} \
} else { \
if (level <= b->ni->loglevel) { \
__ubx_log(level, b->ni, b->name, fmt, ##__VA_ARGS__); \
if (level <= b->nd->loglevel) { \
__ubx_log(level, b->nd, b->name, fmt, ##__VA_ARGS__); \
} \
} \
} while (0)

/* hooks for setting up logging infrastructure */
int ubx_log_init(ubx_node_info_t *ni);
void ubx_log_cleanup(ubx_node_info_t *ni);
int ubx_log_init(ubx_node_t *nd);
void ubx_log_cleanup(ubx_node_t *nd);

/*
* generic, low-level logging function. blocks should prefer the
* standard ubx_* functions
*/
void __ubx_log(const int level, const ubx_node_info_t *ni, const char *src, const char *fmt, ...)
void __ubx_log(const int level, const ubx_node_t *nd, const char *src, const char *fmt, ...)
__attribute__((format(printf, 4, 5)));

#endif /* _UBX_RTLOG_H */
6 changes: 3 additions & 3 deletions libubx/typemacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ long FUNCNAME ## _array(const ubx_port_t* p, TYPENAME* val, const int len) \
/* lookup port in_type on first call or when different
* (could be due to type module reload */ \
if (p->in_type != type) { \
type = ubx_type_get(p->block->ni, QUOTE(TYPENAME)); \
type = ubx_type_get(p->block->nd, QUOTE(TYPENAME)); \
\
if (type == NULL) { \
ubx_err(p->block, "%s: unregistered type " QUOTE(TYPENAME), __func__); \
Expand Down Expand Up @@ -85,7 +85,7 @@ int FUNCNAME ## _array(const ubx_port_t *p, const TYPENAME *val, const int len)
/* lookup port in_type on first call or when different
* (could be due to type module reload */ \
if (p->out_type != type) { \
type = ubx_type_get(p->block->ni, QUOTE(TYPENAME)); \
type = ubx_type_get(p->block->nd, QUOTE(TYPENAME)); \
\
if (type == NULL) { \
ubx_err(p->block, "%s: unregistered type " QUOTE(TYPENAME), __func__); \
Expand Down Expand Up @@ -131,7 +131,7 @@ long FUNCNAME(const ubx_block_t *b, \
/* lookup config type on first call or when different
* (could be due to type module reload */ \
if (c->type != type) { \
type = ubx_type_get(b->ni, QUOTE(TYPENAME)); \
type = ubx_type_get(b->nd, QUOTE(TYPENAME)); \
\
if (type == NULL) { \
ubx_err(b, "%s: unregistered type " QUOTE(TYPENAME), __func__); \
Expand Down

0 comments on commit b869ee6

Please sign in to comment.