-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38cbee0
commit f04f702
Showing
13 changed files
with
289 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// 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 ZENOH_PICO_UTILS_ENDIANNESS_H | ||
#define ZENOH_PICO_UTILS_ENDIANNESS_H | ||
|
||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
// Load int from memory with specified endianness | ||
uint16_t _z_le_load16(const uint8_t *src); | ||
uint32_t _z_le_load32(const uint8_t *src); | ||
uint64_t _z_le_load64(const uint8_t *src); | ||
uint16_t _z_be_load16(const uint8_t *src); | ||
uint32_t _z_be_load32(const uint8_t *src); | ||
uint64_t _z_be_load64(const uint8_t *src); | ||
|
||
// Store int to memory with specified endianness | ||
void _z_le_store16(const uint16_t val, uint8_t *dest); | ||
void _z_le_store32(const uint32_t val, uint8_t *dest); | ||
void _z_le_store64(const uint64_t val, uint8_t *dest); | ||
void _z_be_store16(const uint16_t val, uint8_t *dest); | ||
void _z_be_store32(const uint32_t val, uint8_t *dest); | ||
void _z_be_store64(const uint64_t val, uint8_t *dest); | ||
|
||
// Load little-endian int from memory to host order | ||
uint16_t _z_host_le_load16(const uint8_t *src); | ||
uint32_t _z_host_le_load32(const uint8_t *src); | ||
uint64_t _z_host_le_load64(const uint8_t *src); | ||
|
||
// Store little-endian int to memory from host order | ||
void _z_host_le_store16(const uint16_t val, uint8_t *dst); | ||
void _z_host_le_store32(const uint32_t val, uint8_t *dst); | ||
void _z_host_le_store64(const uint64_t val, uint8_t *dst); | ||
|
||
// Return u16 individual bytes | ||
uint8_t _z_get_u16_lsb(uint_fast16_t val); | ||
uint8_t _z_get_u16_msb(uint_fast16_t val); | ||
|
||
#endif /* ZENOH_PICO_UTILS_ENDIANNESS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,15 +12,26 @@ | |
// ZettaScale Zenoh Team, <[email protected]> | ||
// | ||
|
||
#include "zenoh-pico/transport/multicast/rx.h" | ||
#include "zenoh-pico/transport/common/rx.h" | ||
|
||
#include <stddef.h> | ||
|
||
#include "zenoh-pico/protocol/codec/transport.h" | ||
#include "zenoh-pico/transport/multicast/rx.h" | ||
#include "zenoh-pico/transport/unicast/rx.h" | ||
#include "zenoh-pico/utils/endianness.h" | ||
#include "zenoh-pico/utils/logging.h" | ||
|
||
/*------------------ Reception helper ------------------*/ | ||
size_t _z_read_stream_size(_z_zbuf_t *zbuf) { | ||
uint8_t stream_size[_Z_MSG_LEN_ENC_SIZE]; | ||
// Read the bytes from stream | ||
for (uint8_t i = 0; i < _Z_MSG_LEN_ENC_SIZE; i++) { | ||
stream_size[i] = _z_zbuf_read(zbuf); | ||
} | ||
return _z_host_le_load16(stream_size); | ||
} | ||
|
||
int8_t _z_link_recv_t_msg(_z_transport_message_t *t_msg, const _z_link_t *zl) { | ||
int8_t ret = _Z_RES_OK; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.