blob: c3f55ba10c6b2337feeb78563fd9acc383d7e575 [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"
Austin Schuhb0e439d2023-05-15 10:55:40 -07005#include "aos/sha256.h"
Austin Schuhe84c3ed2019-12-14 15:29:48 -08006
Austin Schuhc5fa6d92022-02-25 14:36:28 -08007DEFINE_string(config, "aos_config.json", "Path to the config.");
Austin Schuha922ad02021-10-23 23:25:50 -07008DEFINE_int32(rt_priority, -1, "If > 0, run as this RT priority");
Austin Schuhe84c3ed2019-12-14 15:29:48 -08009
10namespace aos {
11namespace message_bridge {
12
13int Main() {
14 aos::FlatbufferDetachedBuffer<aos::Configuration> config =
15 aos::configuration::ReadConfig(FLAGS_config);
16
17 aos::ShmEventLoop event_loop(&config.message());
Austin Schuha922ad02021-10-23 23:25:50 -070018 if (FLAGS_rt_priority > 0) {
19 event_loop.SetRuntimeRealtimePriority(FLAGS_rt_priority);
20 }
Austin Schuhe84c3ed2019-12-14 15:29:48 -080021
Austin Schuhb0e439d2023-05-15 10:55:40 -070022 MessageBridgeClient app(&event_loop, Sha256(config.span()));
Austin Schuhe84c3ed2019-12-14 15:29:48 -080023
Sarah Newman45a64df2022-04-11 19:33:46 -070024 logging::DynamicLogging dynamic_logging(&event_loop);
Austin Schuhe84c3ed2019-12-14 15:29:48 -080025 // TODO(austin): Save messages into a vector to be logged. One file per
26 // channel? Need to sort out ordering.
27 //
28 // TODO(austin): Low priority, "reliable" logging channel.
29
30 event_loop.Run();
31
32 return EXIT_SUCCESS;
33}
34
35} // namespace message_bridge
36} // namespace aos
37
38int main(int argc, char **argv) {
39 aos::InitGoogle(&argc, &argv);
40
41 return aos::message_bridge::Main();
42}