Voyant API 0.9.2
Loading...
Searching...
No Matches
carbon_client.hpp
Go to the documentation of this file.
1// Copyright (c) 2024-2025 Voyant Photonics, Inc.
2// All rights reserved.
3
4#pragma once
5
7#include <carbon_config.hpp>
8#include <csignal>
9#include <cstdint>
10#include <memory>
13#include <voyant_types_ffi.hpp>
14
40{
41public:
48 explicit CarbonClient(const CarbonConfig& config);
49
51
52 // Non-copyable, non-movable (owns async runtime)
53 CarbonClient(const CarbonClient&) = delete;
57
62 bool start();
63
68 void stop();
69
73 bool isRunning() const;
74
80
86
92
106
111 static void setupSignalHandling(int signal = SIGINT);
112
116 static bool isTerminated();
117
121 static void resetTerminationFlag();
122
123private:
124 CarbonClientHandleC* handle_; // opaque pointer — type defined in carbon_client_ffi.hpp
125 std::unique_ptr<uint8_t[]> buffer_;
126 static constexpr size_t kBufferSize_ = 8 * 1024 * 1024; // 8MB
128
129 static volatile std::sig_atomic_t terminated_;
130 static void signalHandler(int);
131};
Client for receiving frames from a Carbon LiDAR sensor.
Definition carbon_client.hpp:40
static void resetTerminationFlag()
Resets the termination flag.
CarbonClient(CarbonClient &&)=delete
VoyantFrameWrapper latestFrame_
Definition carbon_client.hpp:127
static volatile std::sig_atomic_t terminated_
Definition carbon_client.hpp:129
SdlStatus pollSdl()
Poll for SDL command confirmation via heartbeat. Call repeatedly after sendSdl() returns Pending.
const VoyantFrameWrapper & latestFrame() const
static bool isTerminated()
Returns true if a termination signal has been received.
SdlStatus sendSdl(const SdlCommandParams &cmd)
Send an SDL command to the sensor FPGA.
CarbonClientHandleC * handle_
Definition carbon_client.hpp:124
CarbonClient(const CarbonConfig &config)
Construct a CarbonClient from a CarbonConfig. The config is cloned internally — it remains valid afte...
VoyantFrameWrapper & latestFrame()
Access the latest received frame.
bool isRunning() const
Returns true if the client is running and no shutdown has been requested.
bool start()
Start receiving and processing data.
std::unique_ptr< uint8_t[]> buffer_
Definition carbon_client.hpp:125
SensorState getSensorState() const
Get the latest sensor state from the most recent heartbeat.
CarbonClient & operator=(const CarbonClient &)=delete
static constexpr size_t kBufferSize_
Definition carbon_client.hpp:126
CarbonClient(const CarbonClient &)=delete
void stop()
Stop receiving and processing data. Safe to call multiple times. Can restart with start().
CarbonClient & operator=(CarbonClient &&)=delete
static void signalHandler(int)
static void setupSignalHandling(int signal=SIGINT)
Set up OS signal handling for graceful termination.
bool tryReceiveFrame()
Try to receive the latest frame if one is available.
Configuration for the Carbon LiDAR pipeline.
Definition carbon_config.hpp:29
Wrapper for VoyantFrame messages.
Definition voyant_frame_wrapper.hpp:19
Definition carbon_client_ffi.hpp:28
Definition voyant_types_ffi.hpp:292
SdlStatus
Definition voyant_types_ffi.hpp:50