From 44752b45fa7c5ca56ba5f6e5adae1b9b10f9eb50 Mon Sep 17 00:00:00 2001 From: Tom Burdick Date: Wed, 10 Jul 2024 13:40:30 -0500 Subject: [PATCH] samples: Add mctp host and client samples Samples work by sending MCTP encoded messages over a uart between two boards. Signed-off-by: Tom Burdick --- MAINTAINERS.yml | 11 +++ .../modules/mctp/mctp_endpoint/.clang-format | 92 ++++++++++++++++++ .../modules/mctp/mctp_endpoint/CMakeLists.txt | 7 ++ .../mctp_endpoint/boards/frdm_k64f.overlay | 5 + .../boards/mimxrt1010_evk.overlay | 5 + .../boards/mimxrt1060_evk.overlay | 10 ++ .../boards/nucleo_f446re.overlay | 5 + samples/modules/mctp/mctp_endpoint/prj.conf | 5 + samples/modules/mctp/mctp_endpoint/src/main.c | 93 +++++++++++++++++++ samples/modules/mctp/mctp_host/.clang-format | 92 ++++++++++++++++++ samples/modules/mctp/mctp_host/.editorconfig | 92 ++++++++++++++++++ samples/modules/mctp/mctp_host/CMakeLists.txt | 6 ++ .../mctp_host/boards/mimxrt1010_evk.overlay | 5 + .../boards/nrf52840dk_nrf52840.overlay | 3 + .../mctp_host/boards/nucleo_f303re.overlay | 7 ++ .../mctp_host/boards/nucleo_f446re.overlay | 5 + samples/modules/mctp/mctp_host/prj.conf | 4 + samples/modules/mctp/mctp_host/src/main.c | 67 +++++++++++++ 18 files changed, 514 insertions(+) create mode 100644 samples/modules/mctp/mctp_endpoint/.clang-format create mode 100644 samples/modules/mctp/mctp_endpoint/CMakeLists.txt create mode 100644 samples/modules/mctp/mctp_endpoint/boards/frdm_k64f.overlay create mode 100644 samples/modules/mctp/mctp_endpoint/boards/mimxrt1010_evk.overlay create mode 100644 samples/modules/mctp/mctp_endpoint/boards/mimxrt1060_evk.overlay create mode 100644 samples/modules/mctp/mctp_endpoint/boards/nucleo_f446re.overlay create mode 100644 samples/modules/mctp/mctp_endpoint/prj.conf create mode 100644 samples/modules/mctp/mctp_endpoint/src/main.c create mode 100644 samples/modules/mctp/mctp_host/.clang-format create mode 100644 samples/modules/mctp/mctp_host/.editorconfig create mode 100644 samples/modules/mctp/mctp_host/CMakeLists.txt create mode 100644 samples/modules/mctp/mctp_host/boards/mimxrt1010_evk.overlay create mode 100644 samples/modules/mctp/mctp_host/boards/nrf52840dk_nrf52840.overlay create mode 100644 samples/modules/mctp/mctp_host/boards/nucleo_f303re.overlay create mode 100644 samples/modules/mctp/mctp_host/boards/nucleo_f446re.overlay create mode 100644 samples/modules/mctp/mctp_host/prj.conf create mode 100644 samples/modules/mctp/mctp_host/src/main.c diff --git a/MAINTAINERS.yml b/MAINTAINERS.yml index 4bb53aed4087a88..3430c71ead7ac13 100644 --- a/MAINTAINERS.yml +++ b/MAINTAINERS.yml @@ -4743,6 +4743,17 @@ West: labels: - "platform: Intel" +"West project: libmctp": + status: maintained + maintainers: + - teburd + collaborators: + - nashif + files: + - modules/libmctp/ + labels: + - "area: MCTP" + "West project: libmetal": status: odd fixes collaborators: diff --git a/samples/modules/mctp/mctp_endpoint/.clang-format b/samples/modules/mctp/mctp_endpoint/.clang-format new file mode 100644 index 000000000000000..150127471485c20 --- /dev/null +++ b/samples/modules/mctp/mctp_endpoint/.clang-format @@ -0,0 +1,92 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Note: The list of ForEachMacros can be obtained using: +# +# git grep -h '^#define [^[:space:]]*FOR_EACH[^[:space:]]*(' include/ \ +# | sed "s,^#define \([^[:space:]]*FOR_EACH[^[:space:]]*\)(.*$, - '\1'," \ +# | sort | uniq +# +# References: +# - https://clang.llvm.org/docs/ClangFormatStyleOptions.html + +--- +BasedOnStyle: LLVM +AlignConsecutiveMacros: AcrossComments +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AttributeMacros: + - __aligned + - __deprecated + - __packed + - __printf_like + - __syscall + - __syscall_always_inline + - __subsystem +BitFieldColonSpacing: After +BreakBeforeBraces: Linux +ColumnLimit: 100 +ConstructorInitializerIndentWidth: 8 +ContinuationIndentWidth: 8 +ForEachMacros: + - 'FOR_EACH' + - 'FOR_EACH_FIXED_ARG' + - 'FOR_EACH_IDX' + - 'FOR_EACH_IDX_FIXED_ARG' + - 'FOR_EACH_NONEMPTY_TERM' + - 'RB_FOR_EACH' + - 'RB_FOR_EACH_CONTAINER' + - 'SYS_DLIST_FOR_EACH_CONTAINER' + - 'SYS_DLIST_FOR_EACH_CONTAINER_SAFE' + - 'SYS_DLIST_FOR_EACH_NODE' + - 'SYS_DLIST_FOR_EACH_NODE_SAFE' + - 'SYS_SFLIST_FOR_EACH_CONTAINER' + - 'SYS_SFLIST_FOR_EACH_CONTAINER_SAFE' + - 'SYS_SFLIST_FOR_EACH_NODE' + - 'SYS_SFLIST_FOR_EACH_NODE_SAFE' + - 'SYS_SLIST_FOR_EACH_CONTAINER' + - 'SYS_SLIST_FOR_EACH_CONTAINER_SAFE' + - 'SYS_SLIST_FOR_EACH_NODE' + - 'SYS_SLIST_FOR_EACH_NODE_SAFE' + - '_WAIT_Q_FOR_EACH' + - 'Z_FOR_EACH' + - 'Z_FOR_EACH_ENGINE' + - 'Z_FOR_EACH_EXEC' + - 'Z_FOR_EACH_FIXED_ARG' + - 'Z_FOR_EACH_FIXED_ARG_EXEC' + - 'Z_FOR_EACH_IDX' + - 'Z_FOR_EACH_IDX_EXEC' + - 'Z_FOR_EACH_IDX_FIXED_ARG' + - 'Z_FOR_EACH_IDX_FIXED_ARG_EXEC' + - 'Z_GENLIST_FOR_EACH_CONTAINER' + - 'Z_GENLIST_FOR_EACH_CONTAINER_SAFE' + - 'Z_GENLIST_FOR_EACH_NODE' + - 'Z_GENLIST_FOR_EACH_NODE_SAFE' + - 'STRUCT_SECTION_FOREACH' + - 'TYPE_SECTION_FOREACH' + - 'K_SPINLOCK' +IfMacros: + - 'CHECKIF' +# Disabled for now, see bug https://github.com/zephyrproject-rtos/zephyr/issues/48520 +#IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^".*\.h"$' + Priority: 0 + - Regex: '^<(assert|complex|ctype|errno|fenv|float|inttypes|limits|locale|math|setjmp|signal|stdarg|stdbool|stddef|stdint|stdio|stdlib|string|tgmath|time|wchar|wctype)\.h>$' + Priority: 1 + - Regex: '^\$' + Priority: 2 + - Regex: '.*' + Priority: 3 +IndentCaseLabels: false +IndentWidth: 8 +InsertBraces: true +SpaceBeforeParens: ControlStatementsExceptControlMacros +SortIncludes: Never +UseTab: ForContinuationAndIndentation +WhitespaceSensitiveMacros: + - STRINGIFY + - Z_STRINGIFY diff --git a/samples/modules/mctp/mctp_endpoint/CMakeLists.txt b/samples/modules/mctp/mctp_endpoint/CMakeLists.txt new file mode 100644 index 000000000000000..61e3fe532ba732b --- /dev/null +++ b/samples/modules/mctp/mctp_endpoint/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +project(i2c_peripheral) + +target_sources(app PRIVATE src/main.c) diff --git a/samples/modules/mctp/mctp_endpoint/boards/frdm_k64f.overlay b/samples/modules/mctp/mctp_endpoint/boards/frdm_k64f.overlay new file mode 100644 index 000000000000000..43526cf829a8214 --- /dev/null +++ b/samples/modules/mctp/mctp_endpoint/boards/frdm_k64f.overlay @@ -0,0 +1,5 @@ +/ { + aliases { + i2c-target = &arduino_i2c; + }; +}; diff --git a/samples/modules/mctp/mctp_endpoint/boards/mimxrt1010_evk.overlay b/samples/modules/mctp/mctp_endpoint/boards/mimxrt1010_evk.overlay new file mode 100644 index 000000000000000..43526cf829a8214 --- /dev/null +++ b/samples/modules/mctp/mctp_endpoint/boards/mimxrt1010_evk.overlay @@ -0,0 +1,5 @@ +/ { + aliases { + i2c-target = &arduino_i2c; + }; +}; diff --git a/samples/modules/mctp/mctp_endpoint/boards/mimxrt1060_evk.overlay b/samples/modules/mctp/mctp_endpoint/boards/mimxrt1060_evk.overlay new file mode 100644 index 000000000000000..fc9192d341eb9ca --- /dev/null +++ b/samples/modules/mctp/mctp_endpoint/boards/mimxrt1060_evk.overlay @@ -0,0 +1,10 @@ +/ { + aliases { + i2c-target = &arduino_i2c; + }; +}; + +&arduino_serial { + status = "okay"; + current-speed = <115200>; +}; diff --git a/samples/modules/mctp/mctp_endpoint/boards/nucleo_f446re.overlay b/samples/modules/mctp/mctp_endpoint/boards/nucleo_f446re.overlay new file mode 100644 index 000000000000000..43526cf829a8214 --- /dev/null +++ b/samples/modules/mctp/mctp_endpoint/boards/nucleo_f446re.overlay @@ -0,0 +1,5 @@ +/ { + aliases { + i2c-target = &arduino_i2c; + }; +}; diff --git a/samples/modules/mctp/mctp_endpoint/prj.conf b/samples/modules/mctp/mctp_endpoint/prj.conf new file mode 100644 index 000000000000000..9b1789ebe724e52 --- /dev/null +++ b/samples/modules/mctp/mctp_endpoint/prj.conf @@ -0,0 +1,5 @@ +CONFIG_SERIAL=y +CONFIG_PICOLIBC=y +CONFIG_MCTP=y +CONFIG_LOG=y +CONFIG_LOG_MODE_IMMEDIATE=y diff --git a/samples/modules/mctp/mctp_endpoint/src/main.c b/samples/modules/mctp/mctp_endpoint/src/main.c new file mode 100644 index 000000000000000..25121112be77630 --- /dev/null +++ b/samples/modules/mctp/mctp_endpoint/src/main.c @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2024 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +LOG_MODULE_REGISTER(mctp_endpoint); + +#include + +static struct mctp_binding_serial *serial; +static struct mctp *mctp_ctx; + +#define LOCAL_HELLO_EID 10 + +#define REMOTE_HELLO_EID 20 + +static int mctp_uart_poll_out(void *data, void *buf, size_t len) +{ + const struct device *uart = data; + + for (size_t i = 0; i < len; i++) { + uart_poll_out(uart, ((uint8_t *)buf)[i]); + } + + return (int)len; +} + +static void rx_message(uint8_t eid, bool tag_owner, + uint8_t msg_tag, void *data, void *msg, + size_t len) +{ + switch (eid) { + case REMOTE_HELLO_EID: + LOG_INF("got mctp message %s for eid %d, replying to 5 with \"world\"", + (char *)msg, eid); + mctp_message_tx(mctp_ctx, LOCAL_HELLO_EID, false, 0, "world", sizeof("world")); + break; + default: + LOG_INF("Unknown endpoint %d", eid); + break; + } +} + +const struct device *uart = DEVICE_DT_GET(DT_NODELABEL(arduino_serial)); + +#define RX_BUF_SZ 128 + +int main(void) +{ + LOG_INF("MCTP Endpoint %d on %s\n", LOCAL_HELLO_EID, CONFIG_BOARD_TARGET); + int rc = 0; + uint8_t rx_buf[RX_BUF_SZ]; + + mctp_ctx = mctp_init(); + assert(mctp_ctx != NULL); + + serial = mctp_serial_init(); + assert(serial); + + mctp_serial_set_tx_fn(serial, mctp_uart_poll_out, (void *)uart); + + mctp_register_bus(mctp_ctx, mctp_binding_serial_core(serial), LOCAL_HELLO_EID); + + mctp_set_rx_all(mctp_ctx, rx_message, NULL); + + /* MCTP poll loop */ + while (true) { + int i; + + for (i = 0; i < RX_BUF_SZ; i++) { + rc = uart_poll_in(uart, &rx_buf[i]); + if (rc != 0) { + break; + } + } + + mctp_serial_rx(serial, rx_buf, i); + k_yield(); + } + + LOG_INF("exiting"); + return 0; +} diff --git a/samples/modules/mctp/mctp_host/.clang-format b/samples/modules/mctp/mctp_host/.clang-format new file mode 100644 index 000000000000000..150127471485c20 --- /dev/null +++ b/samples/modules/mctp/mctp_host/.clang-format @@ -0,0 +1,92 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Note: The list of ForEachMacros can be obtained using: +# +# git grep -h '^#define [^[:space:]]*FOR_EACH[^[:space:]]*(' include/ \ +# | sed "s,^#define \([^[:space:]]*FOR_EACH[^[:space:]]*\)(.*$, - '\1'," \ +# | sort | uniq +# +# References: +# - https://clang.llvm.org/docs/ClangFormatStyleOptions.html + +--- +BasedOnStyle: LLVM +AlignConsecutiveMacros: AcrossComments +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AttributeMacros: + - __aligned + - __deprecated + - __packed + - __printf_like + - __syscall + - __syscall_always_inline + - __subsystem +BitFieldColonSpacing: After +BreakBeforeBraces: Linux +ColumnLimit: 100 +ConstructorInitializerIndentWidth: 8 +ContinuationIndentWidth: 8 +ForEachMacros: + - 'FOR_EACH' + - 'FOR_EACH_FIXED_ARG' + - 'FOR_EACH_IDX' + - 'FOR_EACH_IDX_FIXED_ARG' + - 'FOR_EACH_NONEMPTY_TERM' + - 'RB_FOR_EACH' + - 'RB_FOR_EACH_CONTAINER' + - 'SYS_DLIST_FOR_EACH_CONTAINER' + - 'SYS_DLIST_FOR_EACH_CONTAINER_SAFE' + - 'SYS_DLIST_FOR_EACH_NODE' + - 'SYS_DLIST_FOR_EACH_NODE_SAFE' + - 'SYS_SFLIST_FOR_EACH_CONTAINER' + - 'SYS_SFLIST_FOR_EACH_CONTAINER_SAFE' + - 'SYS_SFLIST_FOR_EACH_NODE' + - 'SYS_SFLIST_FOR_EACH_NODE_SAFE' + - 'SYS_SLIST_FOR_EACH_CONTAINER' + - 'SYS_SLIST_FOR_EACH_CONTAINER_SAFE' + - 'SYS_SLIST_FOR_EACH_NODE' + - 'SYS_SLIST_FOR_EACH_NODE_SAFE' + - '_WAIT_Q_FOR_EACH' + - 'Z_FOR_EACH' + - 'Z_FOR_EACH_ENGINE' + - 'Z_FOR_EACH_EXEC' + - 'Z_FOR_EACH_FIXED_ARG' + - 'Z_FOR_EACH_FIXED_ARG_EXEC' + - 'Z_FOR_EACH_IDX' + - 'Z_FOR_EACH_IDX_EXEC' + - 'Z_FOR_EACH_IDX_FIXED_ARG' + - 'Z_FOR_EACH_IDX_FIXED_ARG_EXEC' + - 'Z_GENLIST_FOR_EACH_CONTAINER' + - 'Z_GENLIST_FOR_EACH_CONTAINER_SAFE' + - 'Z_GENLIST_FOR_EACH_NODE' + - 'Z_GENLIST_FOR_EACH_NODE_SAFE' + - 'STRUCT_SECTION_FOREACH' + - 'TYPE_SECTION_FOREACH' + - 'K_SPINLOCK' +IfMacros: + - 'CHECKIF' +# Disabled for now, see bug https://github.com/zephyrproject-rtos/zephyr/issues/48520 +#IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^".*\.h"$' + Priority: 0 + - Regex: '^<(assert|complex|ctype|errno|fenv|float|inttypes|limits|locale|math|setjmp|signal|stdarg|stdbool|stddef|stdint|stdio|stdlib|string|tgmath|time|wchar|wctype)\.h>$' + Priority: 1 + - Regex: '^\$' + Priority: 2 + - Regex: '.*' + Priority: 3 +IndentCaseLabels: false +IndentWidth: 8 +InsertBraces: true +SpaceBeforeParens: ControlStatementsExceptControlMacros +SortIncludes: Never +UseTab: ForContinuationAndIndentation +WhitespaceSensitiveMacros: + - STRINGIFY + - Z_STRINGIFY diff --git a/samples/modules/mctp/mctp_host/.editorconfig b/samples/modules/mctp/mctp_host/.editorconfig new file mode 100644 index 000000000000000..988cb95f5e42ea6 --- /dev/null +++ b/samples/modules/mctp/mctp_host/.editorconfig @@ -0,0 +1,92 @@ +# EditorConfig: https://editorconfig.org/ + +# top-most EditorConfig file +root = true + +# All (Defaults) +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +max_line_length = 100 + +# Assembly +[*.S] +indent_style = tab +indent_size = 8 + +# C +[*.{c,h}] +indent_style = tab +indent_size = 8 + +# C++ +[*.{cpp,hpp}] +indent_style = tab +indent_size = 8 + +# Linker Script +[*.ld] +indent_style = tab +indent_size = 8 + +# Python +[*.py] +indent_style = space +indent_size = 4 + +# Perl +[*.pl] +indent_style = tab +indent_size = 8 + +# reStructuredText +[*.rst] +indent_style = space +indent_size = 3 + +# YAML +[*.{yml,yaml}] +indent_style = space +indent_size = 2 + +# Shell Script +[*.sh] +indent_style = space +indent_size = 4 + +# Windows Command Script +[*.cmd] +end_of_line = crlf +indent_style = tab +indent_size = 8 + +# Valgrind Suppression File +[*.supp] +indent_style = space +indent_size = 3 + +# CMake +[{CMakeLists.txt,*.cmake}] +indent_style = space +indent_size = 2 + +# Makefile +[Makefile] +indent_style = tab +indent_size = 8 + +# Device tree +[*.{dts,dtsi,overlay}] +indent_style = tab +indent_size = 8 + +# Git commit messages +[COMMIT_EDITMSG] +max_line_length = 75 + +# Kconfig +[Kconfig*] +indent_style = tab +indent_size = 8 diff --git a/samples/modules/mctp/mctp_host/CMakeLists.txt b/samples/modules/mctp/mctp_host/CMakeLists.txt new file mode 100644 index 000000000000000..7bfdd1eddb8bce4 --- /dev/null +++ b/samples/modules/mctp/mctp_host/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(i2c_controller) + +target_sources(app PRIVATE src/main.c) diff --git a/samples/modules/mctp/mctp_host/boards/mimxrt1010_evk.overlay b/samples/modules/mctp/mctp_host/boards/mimxrt1010_evk.overlay new file mode 100644 index 000000000000000..bf41a7896b38d33 --- /dev/null +++ b/samples/modules/mctp/mctp_host/boards/mimxrt1010_evk.overlay @@ -0,0 +1,5 @@ +/ { + aliases { + i2c-controller = &arduino_i2c; + }; +}; diff --git a/samples/modules/mctp/mctp_host/boards/nrf52840dk_nrf52840.overlay b/samples/modules/mctp/mctp_host/boards/nrf52840dk_nrf52840.overlay new file mode 100644 index 000000000000000..48c7f840dcab6b3 --- /dev/null +++ b/samples/modules/mctp/mctp_host/boards/nrf52840dk_nrf52840.overlay @@ -0,0 +1,3 @@ +&arduino_serial{ + status = "okay"; +}; diff --git a/samples/modules/mctp/mctp_host/boards/nucleo_f303re.overlay b/samples/modules/mctp/mctp_host/boards/nucleo_f303re.overlay new file mode 100644 index 000000000000000..f461ac882fe8ec3 --- /dev/null +++ b/samples/modules/mctp/mctp_host/boards/nucleo_f303re.overlay @@ -0,0 +1,7 @@ +/ { + aliases { + i2c-controller = &arduino_i2c; + }; +}; + +arduino_serial: &usart2 {}; diff --git a/samples/modules/mctp/mctp_host/boards/nucleo_f446re.overlay b/samples/modules/mctp/mctp_host/boards/nucleo_f446re.overlay new file mode 100644 index 000000000000000..bf41a7896b38d33 --- /dev/null +++ b/samples/modules/mctp/mctp_host/boards/nucleo_f446re.overlay @@ -0,0 +1,5 @@ +/ { + aliases { + i2c-controller = &arduino_i2c; + }; +}; diff --git a/samples/modules/mctp/mctp_host/prj.conf b/samples/modules/mctp/mctp_host/prj.conf new file mode 100644 index 000000000000000..359b4882e882ef1 --- /dev/null +++ b/samples/modules/mctp/mctp_host/prj.conf @@ -0,0 +1,4 @@ +# nothing here +CONFIG_SERIAL=y +CONFIG_MCTP=y +CONFIG_LOG=y diff --git a/samples/modules/mctp/mctp_host/src/main.c b/samples/modules/mctp/mctp_host/src/main.c new file mode 100644 index 000000000000000..dec9f41c0d6d266 --- /dev/null +++ b/samples/modules/mctp/mctp_host/src/main.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +LOG_MODULE_REGISTER(mctp_host); + +#define LOCAL_HELLO_EID 20 + +#define REMOTE_HELLO_EID 10 + +static void rx_message(uint8_t eid, bool tag_owner, + uint8_t msg_tag, void *data, void *msg, + size_t len) +{ + LOG_INF("received message %s for endpoint %d, msg_tag %d, len %zu", (char *)msg, eid, + msg_tag, len); +} + +const struct device *uart = DEVICE_DT_GET(DT_NODELABEL(arduino_serial)); + +static uint8_t msg[sizeof(struct pldm_msg_hdr) + + sizeof(PLDM_GET_SENSOR_READING_REQ_BYTES)]; + +int main(void) +{ + printf("Hello MCTP! %s\n", CONFIG_BOARD_TARGET); + + int rc; + struct mctp_binding_serial *serial; + struct mctp *mctp_ctx; + + mctp_ctx = mctp_init(); + assert(mctp_ctx != NULL); + + serial = mctp_serial_init(); + assert(serial); + + mctp_serial_open(serial, uart); + + mctp_register_bus(mctp_ctx, mctp_binding_serial_core(serial), LOCAL_HELLO_EID); + mctp_set_rx_all(mctp_ctx, rx_message, NULL); + + /* MCTP poll loop, send "hello" and get "world" back */ + while (true) { + mctp_message_tx(mctp_ctx, REMOTE_HELLO_EID, false, 0, "hello", sizeof("hello")); + + k_msleep(1); + for (int i = 0; i < 10000; i++) { + rc = mctp_serial_read(serial); + } + k_msleep(1000); + } + + return 0; +}