45 msg::Log::get().sinks.add_Serial();
46 msg::Log::get().sinks.add(&msg::StartupLog::get());
50 LOG_ALWAYS(dist::ident());
51 LOGV(
"Flash image (%d bytes) sha256 sum: %s\n", loader::flashimage::len(),
52 loader::flashimage::sha256sum().to_string().c_str());
58 LOG(ANABRID_DEBUG_INIT,
"Detecting and Initializing carrier board...");
59 auto &carrier_ = carrier::Carrier::get();
60 auto carrier_init_result = carrier_.init();
61 if (!carrier_init_result) {
62 LOG_ERROR(
"Error initializing carrier board.");
63 LOG_ERROR(carrier_init_result.err_value().c_str());
64 leds::indicate_error();
70 LOG(ANABRID_DEBUG_INIT,
"Starting up Ethernet...");
71 net::register_settings();
72 auto &netconf = net::StartupConfig::get();
73 int net_error = netconf.begin_ip();
74 if (!net_error && netconf.enable_mdns) {
75 LOG_ALWAYS(
"Starting MDNS");
78 if (!net_error && netconf.enable_jsonl)
79 msg::ApplicationServer::get().begin();
92 auto ® = msg::handlers::Registry::get();
99 if (!daq::calibrate(carrier_)) {
100 LOG_ALWAYS(
"Warning: Error during DAQ calibration. Machine will continue with reduced accuracy.");
104 carrier_.reset(entities::ResetAction::OVERLOAD_RESET);
107 mode::RealManualControl::to_ic();
110 LOG(ANABRID_DEBUG_INIT,
"Executing self-calibration, this may take a few moments...");
111 auto mblock_calibrate_result = carrier_.calibrate_m_blocks();
112 if (!mblock_calibrate_result) {
122 LOG_ALWAYS(mblock_calibrate_result.err_value().c_str());
123 LOG_ALWAYS(
"Info: Startup self-calibration apparently did not succeed. The calibration scheme is by "
124 "default not used in this build anyway.");
128 carrier_.reset(entities::ResetAction::CIRCUIT_RESET | entities::ResetAction::OVERLOAD_RESET);
129 (void)carrier_.write_to_hardware();
133 LOG(ANABRID_DEBUG_INIT,
"Initialization done.");
135 static_plugin::setup();
137 platform::CalibrationBase::begin();
145 auto &netconf = net::StartupConfig::get();
147 if (netconf.enable_jsonl)
148 msg::ApplicationServer::get().loop();
150 if (Serial.available()) {
151 auto input_stream = std::make_shared<transport::DelimitedInputStream<Stream*>>(&Serial);
152 auto output_stream = std::make_shared<transport::DelimitedMessageOutputStream<Stream*>>(&Serial);
153 transport::Transport
transport(std::move(input_stream), output_stream, std::move(output_stream));
157 run::RunManager::get().try_run_next(carrier::Carrier::get());
158 static_plugin::loop();