blob: ce06bb42e4a5550a118dfecb14e86f972c2408a3 [file] [log] [blame]
Jeremy Kerr3d36ee22019-05-30 11:15:37 +08001/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
Jeremy Kerr4cdc2002019-02-07 16:49:12 +08002
3#include <assert.h>
4#include <err.h>
5#include <stdio.h>
6#include <stdlib.h>
7#include <unistd.h>
8#include <sys/poll.h>
9#include <sys/socket.h>
10
11#include "libmctp.h"
12#include "libmctp-serial.h"
13
14static void rx_message(uint8_t eid, void *data, void *msg, size_t len)
15{
16 (void)eid;
17 (void)data;
18 write(STDOUT_FILENO, msg, len);
19}
20
21int main(void)
22{
23 struct mctp_binding_serial *serial;
24 struct mctp *mctp;
25 int rc;
26
27 mctp = mctp_init();
28 assert(mctp);
29
30 serial = mctp_serial_init();
31 assert(serial);
32
33 mctp_serial_open_fd(serial, STDIN_FILENO);
34
35 mctp_serial_register_bus(serial, mctp, 8);
36
37 mctp_set_rx_all(mctp, rx_message, NULL);
38
39 for (;;) {
40 rc = mctp_serial_read(serial);
41 if (rc)
42 break;
43 }
44
45 return EXIT_SUCCESS;
46
47}