livoxGen1:ioUringAssmEngine: Fix build

This commit is contained in:
2025-10-31 11:48:31 -04:00
parent 720babd39d
commit 9ab155560a
2 changed files with 80 additions and 60 deletions
+1
View File
@@ -10,6 +10,7 @@ if(ENABLE_STIMBUFFAPI_livoxGen1)
livoxGen1.cpp livoxGen1.cpp
stagingBuffer.cpp stagingBuffer.cpp
pcloudStimulusBuffer.cpp pcloudStimulusBuffer.cpp
ioUringAssemblyEngine.cpp
) )
target_include_directories(livoxGen1 PUBLIC target_include_directories(livoxGen1 PUBLIC
@@ -1,7 +1,7 @@
#include <cstring> #include <cstring>
#include <sys/socket.h> #include <sys/socket.h>
#include <livoxProto1/device.h> #include <livoxProto1/device.h>
#include "IoUringAssemblyEngine.h" #include "ioUringAssemblyEngine.h"
namespace smo { namespace smo {
namespace stim_buff { namespace stim_buff {
@@ -30,18 +30,24 @@ IoUringAssemblyEngine::IoUringAssemblyEngine()
timeoutMs(15), frameIndex(0) timeoutMs(15), frameIndex(0)
{} {}
bool IoUringAssemblyEngine::setSocketFromDevice(const std::shared_ptr<livoxProto1::Device>& device) { bool IoUringAssemblyEngine::setSocketFromDevice(
if (!device) return false; const std::shared_ptr<livoxProto1::Device>& device
// Expect device to expose pcloudDataSocketDesc() )
udpFd = device->pcloudDataSocketDesc(); {
return udpFd >= 0; if (!device) { return false; }
}
// Expect device to expose pcloudDataSocketDesc()
udpFd = device->pcloudDataSocketDesc->native_handle();
return (udpFd >= 0);
}
bool IoUringAssemblyEngine::start(
FrameAssemblyDesc& descRef, uint8_t* frameBasePtr,
size_t frameStrideBytesArg, uint32_t timeoutMsArg
)
{
if (udpFd < 0 || !frameBasePtr || descRef.slots.empty())
{ return false; }
bool IoUringAssemblyEngine::start(FrameAssemblyDesc& descRef,
uint8_t* frameBasePtr,
size_t frameStrideBytesArg,
uint32_t timeoutMsArg) {
if (udpFd < 0 || !frameBasePtr || descRef.slots.empty()) return false;
desc = &descRef; desc = &descRef;
frameBase = frameBasePtr; frameBase = frameBasePtr;
frameStrideBytes = frameStrideBytesArg; frameStrideBytes = frameStrideBytesArg;
@@ -55,37 +61,50 @@ bool IoUringAssemblyEngine::start(FrameAssemblyDesc& descRef,
return true; return true;
} }
void IoUringAssemblyEngine::pause() { void IoUringAssemblyEngine::pause()
{
paused.store(true); paused.store(true);
} }
void IoUringAssemblyEngine::resume() { void IoUringAssemblyEngine::resume()
if (!running.load()) return; {
if (!running.load())
{ return; }
paused.store(false); paused.store(false);
postReceives(); postReceives();
} }
void IoUringAssemblyEngine::stop() { void IoUringAssemblyEngine::stop()
{
running.store(false); running.store(false);
} }
void IoUringAssemblyEngine::onFrameComplete(FrameCompleteCallback cb) { void IoUringAssemblyEngine::onFrameComplete(FrameCompleteCallback cb)
{
frameCb = std::move(cb); frameCb = std::move(cb);
} }
void IoUringAssemblyEngine::postReceives() { void IoUringAssemblyEngine::postReceives()
{
// Intentionally left minimal; real implementation will submit N RECVMSG SQEs // Intentionally left minimal; real implementation will submit N RECVMSG SQEs
} }
void IoUringAssemblyEngine::handleCqesAndTimeout() { void IoUringAssemblyEngine::handleCqesAndTimeout()
{
// Intentionally left minimal; real implementation will poll CQEs with timeout // Intentionally left minimal; real implementation will poll CQEs with timeout
cancelIncompleteAndFillDummies(); cancelIncompleteAndFillDummies();
if (frameCb) frameCb(frameIndex++); if (frameCb)
{ frameCb(frameIndex++); }
} }
void IoUringAssemblyEngine::cancelIncompleteAndFillDummies() { void IoUringAssemblyEngine::cancelIncompleteAndFillDummies()
if (!desc) return; {
for (size_t i = 0; i < desc->numSlots; ++i) { if (!desc)
{ return; }
for (size_t i = 0; i < desc->numSlots; ++i)
{
// In the real path, decide from CQE accounting whether slot i completed. // In the real path, decide from CQE accounting whether slot i completed.
// Here, demonstrate dummy header insertion API. // Here, demonstrate dummy header insertion API.
auto* hdr = reinterpret_cast<DummyLivoxEthHeader*>(desc->slots[i].vaddr); auto* hdr = reinterpret_cast<DummyLivoxEthHeader*>(desc->slots[i].vaddr);
@@ -97,26 +116,26 @@ void IoUringAssemblyEngine::cancelIncompleteAndFillDummies() {
size_t IoUringAssemblyEngine::computePointsPerDgram(int returnMode) size_t IoUringAssemblyEngine::computePointsPerDgram(int returnMode)
{ {
/* Map modes to points per datagram based on Livox docs /*
* Map modes to points per datagram based on Livox docs
* 1: first, 2: strongest -> 96 samples => 96 points * 1: first, 2: strongest -> 96 samples => 96 points
* 3: dual -> 48 samples * 2 points = 96 * 3: dual -> 48 samples * 2 points = 96
* 4: triple -> 30 samples * 3 points = 90 * 4: triple -> 30 samples * 3 points = 90
*/ */
switch (returnMode) switch (returnMode)
{ {
case livoxProto1::Device::ReturnMode::SingleFirst: case static_cast<int>(livoxProto1::Device::ReturnMode::SingleFirst):
case livoxProto1::Device::ReturnMode::SingleStrongest: case static_cast<int>(livoxProto1::Device::ReturnMode::SingleStrongest):
case livoxProto1::Device::ReturnMode::Dual: case static_cast<int>(livoxProto1::Device::ReturnMode::Dual):
return 96u; return 96u;
case livoxProto1::Device::ReturnMode::Triple: case static_cast<int>(livoxProto1::Device::ReturnMode::Triple):
return 90u; return 90u;
default: default:
throw std::runtime_error(std::string(__func__) throw std::runtime_error(
+ ": Unknown returnMode " + std::to_string(returnMode)); std::string(__func__) + ": Unknown returnMode "
+ std::to_string(returnMode));
} }
} }
} // namespace stim_buff } // namespace stim_buff
} // namespace smo } // namespace smo