Skip to content

Commit dc64aae

Browse files
authored
Merge pull request #73 from open-ephys-plugins/issue-72
Add block read size functionality
2 parents f2fd173 + 5b91e93 commit dc64aae

File tree

10 files changed

+433
-192
lines changed

10 files changed

+433
-192
lines changed

Source/Devices/PortController.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ PortController::PortController(PortName port_, std::shared_ptr<Onix1> ctx_) :
3232

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

3737
return deviceContext->writeRegister(deviceIdx, (uint32_t)PortControllerRegister::ENABLE, 1);
3838
}

Source/Onix1.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ Onix1::~Onix1()
4949
oni_destroy_ctx(ctx_);
5050
}
5151

52-
int Onix1::updateDeviceTable()
52+
int Onix1::getDeviceTable(device_map_t* deviceTable)
5353
{
54-
if (deviceTable.size() > 0)
55-
deviceTable.clear();
54+
if (deviceTable->size() > 0)
55+
deviceTable->clear();
56+
57+
issueReset();
5658

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

7173
for (const auto& device : devices)
7274
{
73-
deviceTable.insert({ device.idx, device });
75+
deviceTable->insert({ device.idx, device });
7476
}
7577

7678
return rc;
7779
}
7880

79-
std::map<int, int> Onix1::getHubIds()
81+
std::map<int, int> Onix1::getHubIds(device_map_t deviceTable) const
8082
{
8183
std::map<int, int> hubIds;
8284

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

97102
hubIds.insert({ offsets[i], hubId });
98103
}

Source/Onix1.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ namespace OnixSourcePlugin
9898

9999
int writeRegister(oni_dev_idx_t, oni_reg_addr_t, oni_reg_val_t) const;
100100

101-
device_map_t getDeviceTable() const noexcept { return deviceTable; }
102-
103-
int updateDeviceTable();
101+
int getDeviceTable(device_map_t*);
104102

105103
oni_frame_t* readFrame() const;
106104

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

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

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

131129
uint32_t ACQ_CLK_HZ;
132130

133-
device_map_t deviceTable;
134-
135131
template<typename opt_t>
136132
size_t opt_size_(opt_t opt)
137133
{

0 commit comments

Comments
 (0)