Skip to content

Commit 3ddf582

Browse files
committed
Device version error prints helpful info to error console
- This address review comments by providing information on what to do about how to address the firmware issue without corrupting the purity of the exception message which should only describe the problem.
1 parent cc96c07 commit 3ddf582

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

OpenEphys.Onix1/ConfigureRhd2164.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public override IObservable<ContextTask> Process(IObservable<ContextTask> source
120120
static class Rhd2164
121121
{
122122
public const int ID = 3;
123-
public const uint MinimumVersion = 2; // TODO: Version 3 resolves a sampling rate issue, should we bump this to force an update even though 2 is functional?
123+
public const uint MinimumVersion = 2;
124124

125125
// constants
126126
public const int AmplifierChannelCount = 64;

OpenEphys.Onix1/ContextHelper.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,17 @@ static void ThrowInvalidDeviceException(Type expectedType, uint address)
9696

9797
static void ThrowInvalidDeviceVersionException(Type expectedType, uint address, uint deviceVersion, uint minimumVersion)
9898
{
99-
throw new InvalidOperationException($"Invalid device version. Detected {expectedType.Name} v{deviceVersion} at {address}, but v{minimumVersion} is required. A firmware update is recommended.");
99+
var assembly = Assembly.GetExecutingAssembly();
100+
string libraryName = assembly.GetName().Name ?? "Unknown";
101+
string libraryVersion = assembly.GetName().Version.ToString() ?? "Unknown";
102+
103+
Console.Error.WriteLine($"Error: The {expectedType.Name} device at address {address} is v{deviceVersion}, " +
104+
$"but v{minimumVersion} is required by {libraryName} {libraryVersion}.");
105+
Console.Error.WriteLine($"In order to use {libraryName} {libraryVersion} with this device, you will need to update it firmware. " +
106+
$"Firmware update files and instructions can be found at https://open-ephys.github.io/onix-docs/index.html.");
107+
108+
throw new InvalidOperationException($"Invalid device version. The {expectedType.Name} device at address {address} is v{deviceVersion}, " +
109+
$"but v{minimumVersion} is required.");
100110
}
101111

102112
internal static bool CheckDeviceType(Type deviceType, Type targetType)

0 commit comments

Comments
 (0)