Skip to content

Commit 3eba31b

Browse files
aacuevasjonnew
authored andcommitted
Add version check for onix gateware v2.x
1 parent dacf31e commit 3eba31b

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

OpenEphys.Onix1/ContextTask.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ public class ContextTask : IDisposable
7676
readonly string contextDriver = DefaultDriver;
7777
readonly int contextIndex = DefaultIndex;
7878

79+
private oni.Hub controllerHub;
80+
7981
/// <summary>
8082
/// Initializes a new instance of the <see cref="ContextTask"/> class.
8183
/// </summary>
@@ -94,6 +96,15 @@ internal ContextTask(string driver, int index)
9496
contextIndex = index;
9597
ctx = new oni.Context(contextDriver, contextIndex);
9698
Initialize();
99+
controllerHub = GetHub(0);
100+
uint versionMajor;
101+
GenericHelper.GetVersionComponents(controllerHub.FirmwareVersion, out versionMajor, out _);
102+
if (versionMajor != 2)
103+
{
104+
throw new NotSupportedException("This library requires version 2.x of the ONIX firmware."
105+
+ "Please update it. Instructions can be found in "
106+
+ "https://open-ephys.github.io/onix-docs/Hardware%20Guide/PCIe%20Host/updating-firmware.html");
107+
}
97108
}
98109

99110
private void Initialize()

OpenEphys.Onix1/GenericHelper.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,17 @@ public static uint GetHubAddressFromDeviceAddress(uint deviceAddress)
66
{
77
return (deviceAddress & 0xFF00u);
88
}
9+
10+
/// <summary>
11+
/// Gets the version components from a 16-bit version register value
12+
/// </summary>
13+
/// <param name="rawVersion">Raw 16-bit version</param>
14+
/// <param name="major">Contains the major component extracted from <paramref name="rawVersion"/></param>
15+
/// <param name="minor">Contains the minor component extracted from <paramref name="rawVersion"/></param>
16+
public static void GetVersionComponents(uint rawVersion, out uint major, out uint minor)
17+
{
18+
major = (rawVersion >> 8) & 0xFF;
19+
minor = rawVersion & 0xFF;
20+
}
921
}
1022
}

0 commit comments

Comments
 (0)