blob: 82a59fb933cc0f6e7b939fefe2998d7028f652cc [file] [log] [blame]
Austin Schuhe84c3ed2019-12-14 15:29:48 -08001#include "aos/events/shm_event_loop.h"
2#include "aos/init.h"
Sarah Newman45a64df2022-04-11 19:33:46 -07003#include "aos/logging/dynamic_logging.h"
Austin Schuh60e77942022-05-16 17:48:24 -07004#include "aos/network/message_bridge_client_lib.h"
Adam Snaider96a0f4b2023-05-18 20:41:19 -07005#include "aos/network/sctp_lib.h"
Austin Schuhb0e439d2023-05-15 10:55:40 -07006#include "aos/sha256.h"
Adam Snaider96a0f4b2023-05-18 20:41:19 -07007#include "aos/util/file.h"
Austin Schuhe84c3ed2019-12-14 15:29:48 -08008
Austin Schuhc5fa6d92022-02-25 14:36:28 -08009DEFINE_string(config, "aos_config.json", "Path to the config.");
Austin Schuha922ad02021-10-23 23:25:50 -070010DEFINE_int32(rt_priority, -1, "If > 0, run as this RT priority");
Austin Schuhe84c3ed2019-12-14 15:29:48 -080011
12namespace aos {
13namespace message_bridge {
14
Adam Snaider96a0f4b2023-05-18 20:41:19 -070015using ::aos::util::ReadFileToVecOrDie;
16
Austin Schuhe84c3ed2019-12-14 15:29:48 -080017int Main() {
18 aos::FlatbufferDetachedBuffer<aos::Configuration> config =
19 aos::configuration::ReadConfig(FLAGS_config);
20
21 aos::ShmEventLoop event_loop(&config.message());
Austin Schuha922ad02021-10-23 23:25:50 -070022 if (FLAGS_rt_priority > 0) {
23 event_loop.SetRuntimeRealtimePriority(FLAGS_rt_priority);
24 }
Austin Schuhe84c3ed2019-12-14 15:29:48 -080025
Adam Snaider9bb33442023-06-26 16:31:37 -070026 MessageBridgeClient app(&event_loop, Sha256(config.span()));
Austin Schuhe84c3ed2019-12-14 15:29:48 -080027
Sarah Newman45a64df2022-04-11 19:33:46 -070028 logging::DynamicLogging dynamic_logging(&event_loop);
Austin Schuhe84c3ed2019-12-14 15:29:48 -080029 // TODO(austin): Save messages into a vector to be logged. One file per
30 // channel? Need to sort out ordering.
31 //
32 // TODO(austin): Low priority, "reliable" logging channel.
33
34 event_loop.Run();
35
36 return EXIT_SUCCESS;
37}
38
39} // namespace message_bridge
40} // namespace aos
41
42int main(int argc, char **argv) {
43 aos::InitGoogle(&argc, &argv);
44
45 return aos::message_bridge::Main();
46}