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