Skip to content

Commit

Permalink
Merge branch 'main' into tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
milyin committed Mar 6, 2024
2 parents 3d91614 + 9c2cf4c commit 3913d15
Show file tree
Hide file tree
Showing 125 changed files with 1,382 additions and 1,206 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ target_include_directories(${Libname} PUBLIC ${PROJECT_SOURCE_DIR}/include)
file(GLOB_RECURSE Sources
"src/api/*.c"
"src/collections/*.c"
"src/deprecated/*.c"
"src/link/*.c"
"src/net/*.c"
"src/protocol/*.c"
Expand Down
8 changes: 4 additions & 4 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sphinx==4.5.0
sphinx_c_autodoc
sphinx_rtd_theme
clang==14
sphinx==7.2.6
sphinx_c_autodoc==1.3.0
sphinx_rtd_theme==2.0.0
clang==14.0
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void app_main(void) {
}

while (1) {
zp_sleep_s(5);
z_sleep_s(5);
printf("Sending Query '%s'...\n", KEYEXPR);
z_get_options_t opts = z_get_options_default();
if (strcmp(VALUE, "") != 0) {
Expand Down
6 changes: 3 additions & 3 deletions examples/freertos_plus_tcp/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void app_main(void) {
static StackType_t read_task_stack[1000];
static StaticTask_t read_task_buffer;

zp_task_attr_t read_task_attr = {
z_task_attr_t read_task_attr = {
.name = "ZenohReadTask",
.priority = 10,
.stack_depth = 1000,
Expand All @@ -62,7 +62,7 @@ void app_main(void) {
static StackType_t lease_task_stack[1000];
static StaticTask_t lease_task_buffer;

zp_task_attr_t lease_task_attr = {
z_task_attr_t lease_task_attr = {
.name = "ZenohLeaseTask",
.priority = 10,
.stack_depth = 1000,
Expand All @@ -89,7 +89,7 @@ void app_main(void) {

char *buf = (char *)pvPortMalloc(256);
for (int idx = 0; 1; ++idx) {
zp_sleep_s(1);
z_sleep_s(1);
snprintf(buf, 256, "[%4d] %s", idx, VALUE);
printf("Putting Data ('%s': '%s')...\n", KEYEXPR, buf);

Expand Down
6 changes: 3 additions & 3 deletions examples/freertos_plus_tcp/z_pub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ void app_main(void) {
}

char *buf = (char *)pvPortMalloc(256);
zp_clock_t now = zp_clock_now();
z_clock_t now = z_clock_now();
for (int idx = 0; 1;) {
if (zp_clock_elapsed_ms(&now) > 1000) {
if (z_clock_elapsed_ms(&now) > 1000) {
snprintf(buf, 256, "[%4d] %s", idx, VALUE);
printf("Putting Data ('%s': '%s')...\n", KEYEXPR, buf);
z_publisher_put(z_loan(pub), (const uint8_t *)buf, strlen(buf), NULL);
++idx;

now = zp_clock_now();
now = z_clock_now();
}

zp_read(z_loan(s), NULL);
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void app_main(void) {
}

while (1) {
zp_sleep_s(5);
z_sleep_s(5);
printf("Pulling data from '%s'...\n", KEYEXPR);
z_subscriber_pull(z_loan(sub));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_put.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void app_main(void) {
}

while (1) {
zp_sleep_s(1);
z_sleep_s(1);
}

// Clean up
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void app_main(void) {
}

while (1) {
zp_sleep_s(5);
z_sleep_s(5);
}

z_undeclare_queryable(z_move(qable));
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void app_main(void) {
}

while (1) {
zp_sleep_s(5);
z_sleep_s(5);
}

z_undeclare_subscriber(z_move(sub));
Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/z_get.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ int main(int argc, char **argv) {
zp_start_lease_task(z_session_loan(&s), NULL);

while (1) {
zp_sleep_s(5);
z_sleep_s(5);
printf("Sending Query '%s'...\n", KEYEXPR);
z_get_options_t opts = z_get_options_default();
if (strcmp(VALUE, "") != 0) {
Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/z_pub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int main(int argc, char **argv) {

char buf[256];
for (int idx = 0; 1; ++idx) {
zp_sleep_s(1);
z_sleep_s(1);
sprintf(buf, "[%4d] %s", idx, VALUE);
printf("Putting Data ('%s': '%s')...\n", KEYEXPR, buf);
z_publisher_put(z_publisher_loan(&pub), (const uint8_t *)buf, strlen(buf), NULL);
Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/z_pull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int main(int argc, char **argv) {
printf("OK!\n");

while (1) {
zp_sleep_s(5);
z_sleep_s(5);
printf("Pulling data from '%s'...\n", KEYEXPR);
z_subscriber_pull(z_pull_subscriber_loan(&sub));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/z_queryable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int main(int argc, char **argv) {
printf("Zenoh setup finished!\n");

while (1) {
zp_sleep_s(5);
z_sleep_s(5);
}

printf("Closing Zenoh Session...");
Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/z_sub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int main(int argc, char **argv) {
printf("OK!\n");

while (1) {
zp_sleep_s(5);
z_sleep_s(5);
}

printf("Closing Zenoh Session...");
Expand Down
36 changes: 18 additions & 18 deletions examples/unix/c11/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@
#define DEFAULT_PING_NB 100
#define DEFAULT_WARMUP_MS 1000

static zp_condvar_t cond;
static zp_mutex_t mutex;
static z_condvar_t cond;
static z_mutex_t mutex;

void callback(const z_sample_t* sample, void* context) {
(void)sample;
(void)context;
zp_condvar_signal(&cond);
z_condvar_signal(&cond);
}
void drop(void* context) {
(void)context;
zp_condvar_free(&cond);
z_condvar_free(&cond);
}

struct args_t {
Expand All @@ -61,8 +61,8 @@ int main(int argc, char** argv) {
DEFAULT_PKT_SIZE, DEFAULT_PING_NB, DEFAULT_WARMUP_MS);
return 1;
}
zp_mutex_init(&mutex);
zp_condvar_init(&cond);
z_mutex_init(&mutex);
z_condvar_init(&cond);
z_owned_config_t config = z_config_default();
z_owned_session_t session = z_open(z_move(config));
if (!z_check(session)) {
Expand Down Expand Up @@ -92,34 +92,34 @@ int main(int argc, char** argv) {
return -1;
}

uint8_t* data = zp_malloc(args.size);
uint8_t* data = z_malloc(args.size);
for (unsigned int i = 0; i < args.size; i++) {
data[i] = (uint8_t)(i % 10);
}
zp_mutex_lock(&mutex);
z_mutex_lock(&mutex);
if (args.warmup_ms) {
printf("Warming up for %dms...\n", args.warmup_ms);
zp_clock_t warmup_start = zp_clock_now();
z_clock_t warmup_start = z_clock_now();
unsigned long elapsed_us = 0;
while (elapsed_us < args.warmup_ms * 1000) {
z_publisher_put(z_loan(pub), data, args.size, NULL);
zp_condvar_wait(&cond, &mutex);
elapsed_us = zp_clock_elapsed_us(&warmup_start);
z_condvar_wait(&cond, &mutex);
elapsed_us = z_clock_elapsed_us(&warmup_start);
}
}
unsigned long* results = zp_malloc(sizeof(unsigned long) * args.number_of_pings);
unsigned long* results = z_malloc(sizeof(unsigned long) * args.number_of_pings);
for (unsigned int i = 0; i < args.number_of_pings; i++) {
zp_clock_t measure_start = zp_clock_now();
z_clock_t measure_start = z_clock_now();
z_publisher_put(z_loan(pub), data, args.size, NULL);
zp_condvar_wait(&cond, &mutex);
results[i] = zp_clock_elapsed_us(&measure_start);
z_condvar_wait(&cond, &mutex);
results[i] = z_clock_elapsed_us(&measure_start);
}
for (unsigned int i = 0; i < args.number_of_pings; i++) {
printf("%d bytes: seq=%d rtt=%luµs, lat=%luµs\n", args.size, i, results[i], results[i] / 2);
}
zp_mutex_unlock(&mutex);
zp_free(results);
zp_free(data);
z_mutex_unlock(&mutex);
z_free(results);
z_free(data);
z_drop(z_move(pub));
z_drop(z_move(sub));

Expand Down
12 changes: 6 additions & 6 deletions examples/unix/c11/z_sub_thr.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
typedef struct {
volatile unsigned long count;
volatile unsigned long finished_rounds;
zp_clock_t start;
zp_clock_t first_start;
z_clock_t start;
z_clock_t first_start;
} z_stats_t;

#if Z_FEATURE_SUBSCRIPTION == 1
Expand All @@ -44,14 +44,14 @@ void on_sample(const z_sample_t *sample, void *context) {
stats->count++;
// Start set measurement
if (stats->count == 1) {
stats->start = zp_clock_now();
stats->start = z_clock_now();
if (stats->first_start.tv_nsec == 0) {
stats->first_start = stats->start;
}
} else if (stats->count >= PACKET_NB) {
// Stop set measurement
stats->finished_rounds++;
unsigned long elapsed_ms = zp_clock_elapsed_ms(&stats->start);
unsigned long elapsed_ms = z_clock_elapsed_ms(&stats->start);
printf("Received %d msg in %lu ms (%.1f msg/s)\n", PACKET_NB, elapsed_ms,
(double)(PACKET_NB * 1000) / (double)elapsed_ms);
stats->count = 0;
Expand All @@ -60,7 +60,7 @@ void on_sample(const z_sample_t *sample, void *context) {

void drop_stats(void *context) {
z_stats_t *stats = (z_stats_t *)context;
unsigned long elapsed_ms = zp_clock_elapsed_ms(&stats->first_start);
unsigned long elapsed_ms = z_clock_elapsed_ms(&stats->first_start);
const unsigned long sent_messages = PACKET_NB * stats->finished_rounds + stats->count;
printf("Stats after unsubscribing: received %ld messages over %lu miliseconds (%.1f msg/s)\n", sent_messages,
elapsed_ms, (double)(sent_messages * 1000) / (double)elapsed_ms);
Expand Down Expand Up @@ -106,7 +106,7 @@ int main(int argc, char **argv) {
}
// Wait for everything to settle
printf("End of test\n");
zp_sleep_s(1);
z_sleep_s(1);
// Clean up
z_undeclare_subscriber(z_move(sub));
zp_stop_read_task(z_loan(s));
Expand Down
36 changes: 18 additions & 18 deletions examples/unix/c99/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@
#define DEFAULT_PING_NB 100
#define DEFAULT_WARMUP_MS 1000

static zp_condvar_t cond;
static zp_mutex_t mutex;
static z_condvar_t cond;
static z_mutex_t mutex;

void callback(const z_sample_t* sample, void* context) {
(void)sample;
(void)context;
zp_condvar_signal(&cond);
z_condvar_signal(&cond);
}
void drop(void* context) {
(void)context;
zp_condvar_free(&cond);
z_condvar_free(&cond);
}

struct args_t {
Expand All @@ -62,8 +62,8 @@ int main(int argc, char** argv) {
DEFAULT_PKT_SIZE, DEFAULT_PING_NB, DEFAULT_WARMUP_MS);
return 1;
}
zp_mutex_init(&mutex);
zp_condvar_init(&cond);
z_mutex_init(&mutex);
z_condvar_init(&cond);
z_owned_config_t config = z_config_default();
z_owned_session_t session = z_open(z_config_move(&config));
if (!z_session_check(&session)) {
Expand Down Expand Up @@ -94,34 +94,34 @@ int main(int argc, char** argv) {
return -1;
}

uint8_t* data = zp_malloc(args.size);
uint8_t* data = z_malloc(args.size);
for (unsigned int i = 0; i < args.size; i++) {
data[i] = (uint8_t)(i % 10);
}
zp_mutex_lock(&mutex);
z_mutex_lock(&mutex);
if (args.warmup_ms) {
printf("Warming up for %dms...\n", args.warmup_ms);
zp_clock_t warmup_start = zp_clock_now();
z_clock_t warmup_start = z_clock_now();
unsigned long elapsed_us = 0;
while (elapsed_us < args.warmup_ms * 1000) {
z_publisher_put(z_publisher_loan(&pub), data, args.size, NULL);
zp_condvar_wait(&cond, &mutex);
elapsed_us = zp_clock_elapsed_us(&warmup_start);
z_condvar_wait(&cond, &mutex);
elapsed_us = z_clock_elapsed_us(&warmup_start);
}
}
unsigned long* results = zp_malloc(sizeof(unsigned long) * args.number_of_pings);
unsigned long* results = z_malloc(sizeof(unsigned long) * args.number_of_pings);
for (unsigned int i = 0; i < args.number_of_pings; i++) {
zp_clock_t measure_start = zp_clock_now();
z_clock_t measure_start = z_clock_now();
z_publisher_put(z_publisher_loan(&pub), data, args.size, NULL);
zp_condvar_wait(&cond, &mutex);
results[i] = zp_clock_elapsed_us(&measure_start);
z_condvar_wait(&cond, &mutex);
results[i] = z_clock_elapsed_us(&measure_start);
}
for (unsigned int i = 0; i < args.number_of_pings; i++) {
printf("%d bytes: seq=%d rtt=%luµs, lat=%luµs\n", args.size, i, results[i], results[i] / 2);
}
zp_mutex_unlock(&mutex);
zp_free(results);
zp_free(data);
z_mutex_unlock(&mutex);
z_free(results);
z_free(data);
z_undeclare_subscriber(z_subscriber_move(&sub));
z_undeclare_publisher(z_publisher_move(&pub));

Expand Down
6 changes: 3 additions & 3 deletions examples/unix/c99/z_pub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ int main(int argc, char **argv) {
}

char *buf = (char *)malloc(256);
zp_clock_t now = zp_clock_now();
z_clock_t now = z_clock_now();
for (int idx = 0; 1;) {
if (zp_clock_elapsed_ms(&now) > 1000) {
if (z_clock_elapsed_ms(&now) > 1000) {
snprintf(buf, 256, "[%4d] %s", idx, value);
printf("Putting Data ('%s': '%s')...\n", keyexpr, buf);
z_publisher_put(z_publisher_loan(&pub), (const uint8_t *)buf, strlen(buf), NULL);
++idx;

now = zp_clock_now();
now = z_clock_now();
}

zp_read(z_session_loan(&s), NULL);
Expand Down
Loading

0 comments on commit 3913d15

Please sign in to comment.