mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-01-24 13:58:00 -05:00
The system watchdog monitors whether there is message traffic on the Bus. If no message was sent for an extended period of time, a reset will occur. It should also protect against system-wide hangs. On Linux, watchdog is simulated by a FreeRTOS task that will call exit on timeout.
46 lines
1.2 KiB
C++
46 lines
1.2 KiB
C++
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#pragma once
|
|
|
|
#include "Message.hpp"
|
|
#include "Watchdog.hpp"
|
|
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace sys
|
|
{
|
|
class Service; // Forward declaration
|
|
class Bus; // Forward declaration
|
|
|
|
class BusProxy
|
|
{
|
|
public:
|
|
static constexpr auto defaultTimeout = 5000U;
|
|
|
|
~BusProxy() noexcept;
|
|
|
|
bool sendUnicast(std::shared_ptr<Message> message, const std::string &targetName);
|
|
SendResult sendUnicast(std::shared_ptr<Message> message, const std::string &targetName, std::uint32_t timeout);
|
|
void sendMulticast(std::shared_ptr<Message> message, BusChannel channel);
|
|
void sendBroadcast(std::shared_ptr<Message> message);
|
|
|
|
std::vector<BusChannel> channels;
|
|
|
|
private:
|
|
friend class Service;
|
|
explicit BusProxy(Service *owner, Watchdog &watchdog);
|
|
|
|
void sendResponse(std::shared_ptr<Message> response, std::shared_ptr<Message> request);
|
|
void connect();
|
|
void disconnect();
|
|
|
|
Service *owner;
|
|
Watchdog &watchdog;
|
|
std::unique_ptr<Bus> busImpl;
|
|
};
|
|
} // namespace sys
|