Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/Devices/PortController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ PortController::PortController(PortName port_, std::shared_ptr<Onix1> ctx_) :

int PortController::configureDevice()
{
if (deviceContext == nullptr || !deviceContext->isInitialized()) return -5;
if (deviceContext == nullptr || !deviceContext->isInitialized()) return 1;

return deviceContext->writeRegister(deviceIdx, (uint32_t)PortControllerRegister::ENABLE, 1);
}
Expand Down
15 changes: 10 additions & 5 deletions Source/Onix1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ Onix1::~Onix1()
oni_destroy_ctx(ctx_);
}

int Onix1::updateDeviceTable()
int Onix1::getDeviceTable(device_map_t* deviceTable)
{
if (deviceTable.size() > 0)
deviceTable.clear();
if (deviceTable->size() > 0)
deviceTable->clear();

issueReset();

oni_size_t numDevices;
int rc = getOption<oni_size_t>(ONI_OPT_NUMDEVICES, &numDevices);
Expand All @@ -70,13 +72,13 @@ int Onix1::updateDeviceTable()

for (const auto& device : devices)
{
deviceTable.insert({ device.idx, device });
deviceTable->insert({ device.idx, device });
}

return rc;
}

std::map<int, int> Onix1::getHubIds()
std::map<int, int> Onix1::getHubIds(device_map_t deviceTable) const
{
std::map<int, int> hubIds;

Expand All @@ -92,7 +94,10 @@ std::map<int, int> Onix1::getHubIds()
oni_reg_val_t hubId = 0;
int rc = oni_read_reg(ctx_, offsets[i] + ONIX_HUB_DEV_IDX, (uint32_t)ONIX_HUB_HARDWAREID, &hubId);
if (rc != ONI_ESUCCESS)
{
LOGE("Unable to read the hub device index for the hub at index ", offsets[i]);
continue;
}

hubIds.insert({ offsets[i], hubId });
}
Expand Down
8 changes: 2 additions & 6 deletions Source/Onix1.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ namespace OnixSourcePlugin

int writeRegister(oni_dev_idx_t, oni_reg_addr_t, oni_reg_val_t) const;

device_map_t getDeviceTable() const noexcept { return deviceTable; }

int updateDeviceTable();
int getDeviceTable(device_map_t*);

oni_frame_t* readFrame() const;

Expand All @@ -111,7 +109,7 @@ namespace OnixSourcePlugin
double convertTimestampToSeconds(uint32_t timestamp) const { return static_cast<double>(timestamp) / ACQ_CLK_HZ; }

/** Gets a map of all hubs connected, where the index of the map is the hub address, and the value is the hub ID */
std::map<int, int> getHubIds();
std::map<int, int> getHubIds(device_map_t) const;

/** Gets a vector of device indices from a device_map_t object, optionally filtered by a specific hub */
static std::vector<int> getDeviceIndices(device_map_t deviceMap, int hubIndex = -1);
Expand All @@ -130,8 +128,6 @@ namespace OnixSourcePlugin

uint32_t ACQ_CLK_HZ;

device_map_t deviceTable;

template<typename opt_t>
size_t opt_size_(opt_t opt)
{
Expand Down
Loading