Skip to content

Commit

Permalink
Merge remote-tracking branch 'eclipse/main' into feature/condvar_time…
Browse files Browse the repository at this point in the history
…dwait
  • Loading branch information
bjsowa committed Dec 12, 2024
2 parents 4890d42 + f37e806 commit d86cc51
Show file tree
Hide file tree
Showing 33 changed files with 712 additions and 633 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/arduino_esp32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
mkdir -p $ARDUINO_BASE
cd $ARDUINO_BASE
platformio init -b esp32thing_plus -O "board_build.cmake_extra_args=-DZ_FEATURE_LINK_BLUETOOTH=1" -O "build_flags=-DZENOH_DEBUG=3 -DZENOH_COMPILER_GCC" -O "lib_ldf_mode=deep+"
platformio init -b esp32thing_plus -O "board_build.cmake_extra_args=-DZ_FEATURE_LINK_BLUETOOTH=1 -DZ_FEATURE_LINK_SERIAL=1" -O "build_flags=-DZENOH_DEBUG=3 -DZENOH_COMPILER_GCC" -O "lib_ldf_mode=deep+"
cd $ARDUINO_BASE/lib
ln -s $ZENOH_PICO_BASE
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/espidf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
mkdir -p $ESPIDF_BASE
cd $ESPIDF_BASE
platformio init -b az-delivery-devkit-v4 --project-option="framework=espidf" --project-option="build_flags=-DZENOH_ESPIDF -DZENOH_DEBUG=3"
platformio init -b az-delivery-devkit-v4 -O "board_build.cmake_extra_args=-DZ_FEATURE_LINK_SERIAL=1" --project-option="framework=espidf" --project-option="build_flags=-DZENOH_ESPIDF -DZENOH_DEBUG=3"
cd $ESPIDF_BASE/lib
ln -s $ZENOH_PICO_BASE
Expand Down
10 changes: 2 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ set(Z_FEATURE_PUBLICATION 1 CACHE STRING "Toggle publication feature")
set(Z_FEATURE_SUBSCRIPTION 1 CACHE STRING "Toggle subscription feature")
set(Z_FEATURE_QUERY 1 CACHE STRING "Toggle query feature")
set(Z_FEATURE_QUERYABLE 1 CACHE STRING "Toggle queryable feature")
set(Z_FEATURE_LIVELINESS 0 CACHE STRING "Toggle liveliness feature")
set(Z_FEATURE_LIVELINESS 1 CACHE STRING "Toggle liveliness feature")
set(Z_FEATURE_INTEREST 1 CACHE STRING "Toggle interests")
set(Z_FEATURE_FRAGMENTATION 1 CACHE STRING "Toggle fragmentation")
set(Z_FEATURE_ENCODING_VALUES 1 CACHE STRING "Toggle encoding values")
Expand All @@ -245,12 +245,6 @@ set(Z_FEATURE_PUBLISHER_SESSION_CHECK 1 CACHE STRING "Toggle publisher session c
set(Z_FEATURE_BATCHING 1 CACHE STRING "Toggle batching")
set(Z_FEATURE_RX_CACHE 0 CACHE STRING "Toggle RX_CACHE")

# Add a warning message if someone tries to enable Z_FEATURE_LIVELINESS directly
if(Z_FEATURE_LIVELINESS AND NOT Z_FEATURE_UNSTABLE_API)
message(WARNING "Z_FEATURE_LIVELINESS can only be enabled when Z_FEATURE_UNSTABLE_API is also enabled. Disabling Z_FEATURE_LIVELINESS.")
set(Z_FEATURE_LIVELINESS 0 CACHE STRING "Toggle liveliness feature" FORCE)
endif()

# Add a warning message if someone tries to enable Z_FEATURE_LINK_SERIAL_USB directly
if(Z_FEATURE_LINK_SERIAL_USB AND NOT Z_FEATURE_UNSTABLE_API)
message(WARNING "Z_FEATURE_LINK_SERIAL_USB can only be enabled when Z_FEATURE_UNSTABLE_API is also enabled. Disabling Z_FEATURE_LINK_SERIAL_USB.")
Expand Down Expand Up @@ -343,7 +337,7 @@ file(GLOB_RECURSE Sources
"src/session/*.c"
"src/transport/*.c"
"src/utils/*.c"
"src/system/platform_common.c"
"src/system/common/*.c"
)

if(WITH_ZEPHYR)
Expand Down
3 changes: 3 additions & 0 deletions examples/rpi_pico/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ void print_ip_address() {

void main_task(void *params) {
(void)params;
#ifndef NDEBUG
vTaskDelay(pdMS_TO_TICKS(3000));
#endif

#if WIFI_SUPPORT_ENABLED
if (cyw43_arch_init()) {
printf("Failed to initialise\n");
Expand Down
2 changes: 1 addition & 1 deletion include/zenoh-pico/collections/arc_slice.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "refcount.h"
#include "slice.h"
#include "zenoh-pico/system/platform_common.h"
#include "zenoh-pico/system/common/platform.h"

#ifdef __cplusplus
extern "C" {
Expand Down
33 changes: 33 additions & 0 deletions include/zenoh-pico/protocol/codec/serial.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Copyright (c) 2024 ZettaScale Technology
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
//
// Contributors:
// ZettaScale Zenoh Team, <[email protected]>
//

#ifndef INCLUDE_ZENOH_PICO_PROTOCOL_CODEC_SERIAL_H
#define INCLUDE_ZENOH_PICO_PROTOCOL_CODEC_SERIAL_H

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

size_t _z_serial_msg_serialize(uint8_t *dest, size_t dest_len, const uint8_t *src, size_t src_len, uint8_t header,
uint8_t *tmp_buf, size_t tmp_buf_len);
size_t _z_serial_msg_deserialize(const uint8_t *src, size_t src_len, uint8_t *dst, size_t dst_len, uint8_t *header,
uint8_t *tmp_buf, size_t tmp_buf_len);

#ifdef __cplusplus
}
#endif

#endif /* INCLUDE_ZENOH_PICO_PROTOCOL_CODEC_SERIAL_H */
61 changes: 61 additions & 0 deletions include/zenoh-pico/protocol/definitions/serial.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// Copyright (c) 2022 ZettaScale Technology
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
//
// Contributors:
// ZettaScale Zenoh Team, <[email protected]>
//

#ifndef INCLUDE_ZENOH_PICO_PROTOCOL_DEFINITIONS_SERIAL_H
#define INCLUDE_ZENOH_PICO_PROTOCOL_DEFINITIONS_SERIAL_H

#include <stdint.h>

#include "zenoh-pico/link/endpoint.h"
#include "zenoh-pico/protocol/definitions/network.h"

#ifdef __cplusplus
extern "C" {
#endif

/// ZSerial Frame Format
///
/// Using COBS
///
/// +-+-+----+------------+--------+-+
/// |O|H|XXXX|ZZZZ....ZZZZ|CCCCCCCC|0|
/// +-+----+------------+--------+-+
/// |O| |Len | Data | CRC32 |C|
/// +-+-+-2--+----N-------+---4----+-+
///
/// Header: 1byte
/// +---------------+
/// |7|6|5|4|3|2|1|0|
/// +---------------+
/// |x|x|x|x|x|R|A|I|
/// +---------------+
///
/// Flags:
/// I - Init
/// A - Ack
/// R - Reset
///
/// Max Frame Size: 1510
/// Max MTU: 1500
/// Max On-the-wire length: 1516 (MFS + Overhead Byte (OHB) + Kind Byte + End of packet (EOP))

#define _Z_FLAG_SERIAL_INIT 0x01
#define _Z_FLAG_SERIAL_ACK 0x02
#define _Z_FLAG_SERIAL_RESET 0x04

#ifdef __cplusplus
}
#endif

#endif /* INCLUDE_ZENOH_PICO_PROTOCOL_DEFINITIONS_SERIAL_H*/
File renamed without changes.
36 changes: 36 additions & 0 deletions include/zenoh-pico/system/common/serial.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// Copyright (c) 2024 ZettaScale Technology
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
//
// Contributors:
// ZettaScale Zenoh Team, <[email protected]>
//

#ifndef ZENOH_PICO_SYSTEM_COMMON_SERIAL_H
#define ZENOH_PICO_SYSTEM_COMMON_SERIAL_H

#include <stdint.h>

#include "zenoh-pico/system/common/platform.h"
#include "zenoh-pico/utils/result.h"

#ifdef __cplusplus
extern "C" {
#endif

z_result_t _z_connect_serial(const _z_sys_net_socket_t sock);
size_t _z_read_serial(const _z_sys_net_socket_t sock, uint8_t *ptr, size_t len);
size_t _z_send_serial(const _z_sys_net_socket_t sock, const uint8_t *ptr, size_t len);
size_t _z_read_exact_serial(const _z_sys_net_socket_t sock, uint8_t *ptr, size_t len);

#ifdef __cplusplus
}
#endif

#endif /* ZENOH_PICO_SYSTEM_COMMON_SERIAL_H */
6 changes: 3 additions & 3 deletions include/zenoh-pico/system/link/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extern "C" {
#if Z_FEATURE_LINK_SERIAL == 1

#define _Z_SERIAL_MTU_SIZE 1500
#define _Z_SERIAL_MFS_SIZE _Z_SERIAL_MTU_SIZE + 2 + 4 // MTU + Serial Len + Serial CRC32
#define _Z_SERIAL_MFS_SIZE _Z_SERIAL_MTU_SIZE + 1 + 2 + 4 // MTU + Header + Serial Len + Serial CRC32
#define _Z_SERIAL_MAX_COBS_BUF_SIZE \
1516 // Max On-the-wire length for an MFS/MTU of 1510/1500 (MFS + Overhead Byte (OHB) + End of packet (EOP))

Expand All @@ -42,8 +42,8 @@ z_result_t _z_listen_serial_from_pins(_z_sys_net_socket_t *sock, uint32_t txpin,
z_result_t _z_listen_serial_from_dev(_z_sys_net_socket_t *sock, char *dev, uint32_t baudrate);
void _z_close_serial(_z_sys_net_socket_t *sock);
size_t _z_read_exact_serial(const _z_sys_net_socket_t sock, uint8_t *ptr, size_t len);
size_t _z_read_serial(const _z_sys_net_socket_t sock, uint8_t *ptr, size_t len);
size_t _z_send_serial(const _z_sys_net_socket_t sock, const uint8_t *ptr, size_t len);
size_t _z_read_serial_internal(const _z_sys_net_socket_t sock, uint8_t *header, uint8_t *ptr, size_t len);
size_t _z_send_serial_internal(const _z_sys_net_socket_t sock, uint8_t header, const uint8_t *ptr, size_t len);

#endif

Expand Down
2 changes: 1 addition & 1 deletion include/zenoh-pico/system/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
#include <stdint.h>

#include "zenoh-pico/config.h"
#include "zenoh-pico/system/platform_common.h"
#include "zenoh-pico/system/common/platform.h"

#endif /* ZENOH_PICO_SYSTEM_PLATFORM_H */
6 changes: 1 addition & 5 deletions include/zenoh-pico/system/platform/espidf.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ typedef struct {
int _fd;
#endif
#if Z_FEATURE_LINK_SERIAL == 1
struct {
uart_port_t _serial;
uint8_t *before_cobs;
uint8_t *after_cobs;
};
uart_port_t _serial;
#endif
};
} _z_sys_net_socket_t;
Expand Down
16 changes: 14 additions & 2 deletions include/zenoh-pico/system/platform/freertos_plus_tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#ifndef ZENOH_PICO_SYSTEM_FREERTOS_PLUS_TCP_TYPES_H
#define ZENOH_PICO_SYSTEM_FREERTOS_PLUS_TCP_TYPES_H

#include <time.h>

#include "FreeRTOS.h"
#include "FreeRTOS_IP.h"
#include "semphr.h"
Expand All @@ -37,9 +39,19 @@ typedef struct {
typedef struct {
TaskHandle_t handle;
EventGroupHandle_t join_event;
void *(*fun)(void *);
void *arg;
#if (configSUPPORT_STATIC_ALLOCATION == 1)
StaticEventGroup_t join_event_buffer;
#endif /* SUPPORT_STATIC_ALLOCATION */
} _z_task_t;

typedef SemaphoreHandle_t _z_mutex_t;
typedef struct {
SemaphoreHandle_t handle;
#if (configSUPPORT_STATIC_ALLOCATION == 1)
StaticSemaphore_t buffer;
#endif /* SUPPORT_STATIC_ALLOCATION */
} _z_mutex_t;
typedef struct {
SemaphoreHandle_t mutex;
SemaphoreHandle_t sem;
Expand All @@ -52,7 +64,7 @@ typedef struct {
#endif // Z_MULTI_THREAD == 1

typedef TickType_t z_clock_t;
typedef TickType_t z_time_t;
typedef struct timeval z_time_t;

typedef struct {
union {
Expand Down
2 changes: 1 addition & 1 deletion include/zenoh-pico/utils/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <stdio.h>

#include "zenoh-pico/system/platform_common.h"
#include "zenoh-pico/system/common/platform.h"

#ifdef __cplusplus
extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
#include "zenoh-pico/session/resource.h"
#include "zenoh-pico/session/subscription.h"
#include "zenoh-pico/session/utils.h"
#include "zenoh-pico/system/common/platform.h"
#include "zenoh-pico/system/platform.h"
#include "zenoh-pico/system/platform_common.h"
#include "zenoh-pico/transport/common/tx.h"
#include "zenoh-pico/transport/multicast.h"
#include "zenoh-pico/transport/unicast.h"
Expand Down
3 changes: 1 addition & 2 deletions src/collections/vec.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ void _z_svec_move(_z_svec_t *dst, _z_svec_t *src) {

z_result_t _z_svec_copy(_z_svec_t *dst, const _z_svec_t *src, z_element_copy_f copy, size_t element_size,
bool use_elem_f) {
dst->_capacity = 0;
dst->_len = 0;
*dst = _z_svec_null();
dst->_val = z_malloc(element_size * src->_capacity);
if (dst->_val == NULL) {
return _Z_ERR_SYSTEM_OUT_OF_MEMORY;
Expand Down
1 change: 1 addition & 0 deletions src/link/unicast/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "zenoh-pico/config.h"
#include "zenoh-pico/link/manager.h"
#include "zenoh-pico/system/common/serial.h"
#include "zenoh-pico/system/link/serial.h"
#include "zenoh-pico/utils/pointers.h"

Expand Down
Loading

0 comments on commit d86cc51

Please sign in to comment.