Opticon.csp2
2.0.7
dotnet add package Opticon.csp2 --version 2.0.7
NuGet\Install-Package Opticon.csp2 -Version 2.0.7
<PackageReference Include="Opticon.csp2" Version="2.0.7" />
<PackageVersion Include="Opticon.csp2" Version="2.0.7" />
<PackageReference Include="Opticon.csp2" />
paket add Opticon.csp2 --version 2.0.7
#r "nuget: Opticon.csp2, 2.0.7"
#:package Opticon.csp2@2.0.7
#addin nuget:?package=Opticon.csp2&version=2.0.7
#tool nuget:?package=Opticon.csp2&version=2.0.7
Opticon.Csp2Net
.NET package for interfacing with Opticon OPN Companion devices using the CSP2 protocol
Features
- Provides a C# interface for communicating with Opticon Companion devices using the CSP2 native functionality.
- Supports both legacy .NET Framework applications and modern .NET applications.
- Fully cross-platform on Windows, Linux, and macOS when running on supported .NET runtimes.
- Simplifies device connection, polling, barcode reading, and parameter management
Installation
Install via NuGet:
dotnet add package Opticon.csp2
Or search for 'Opticon.csp2' in the Visual Studio NuGet Package Manager.
Compatibility
| Platform / Runtime | Supported |
|---|---|
| .NET Framework 4.6.1+ | ✅ |
| .NET Standard 2.0 | ✅ |
| .NET Standard 2.1 | ✅ |
| .NET 6 | ✅ |
| .NET 8 | ✅ |
| .NET 9 | ✅ |
Operating Systems
| Operating System | Supported |
|---|---|
| Windows | ✅ |
| Linux | ✅ |
| macOS | ✅ |
Documentation
The full documentation of this package can be found here:
Usage
The following example demonstrates how to poll for devices, retrieve barcode data and manage device parameters.
using Opticon.Csp2Net;
class Program
{
static async Task Main(string[] args)
{
Console.WriteLine($"Csp2Net Package Version = {OpnEnvironment.GetDllVersion()}");
if (OperatingSystem.IsMacOS() || OperatingSystem.IsLinux())
Console.WriteLine($"\nMake sure your device is configured to use the CDC-driver (default: BQZ; OPN-2500/OPN-6000 only)\n(See https://opticonfigure.opticon.com)\n");
string logDirectory = Path.Combine(AppContext.BaseDirectory, "Logs");
Directory.CreateDirectory(logDirectory);
OpnDevice.StartPolling((device, connected) =>
{
try
{
if (connected)
{
device.Connect(); // Not mandatory (port is automatically opened on each request if needed)
device.Interrogate(); // No longer needed (Interrogate is automatically called when requesting device info)
string deviceId = device.GetDeviceId() ?? "Unknown";
string model = device.GetModel() ?? "Unknown";
// Handle new connection
Console.WriteLine($"[{model}] [{deviceId}] [{device.PortName}] Connected ({device.GetSoftwareVersion()})");
// Read all barcodes from the device AND correct time stamps based on device and system time
var barcodes = device.ReadBarcodes(true);
Console.WriteLine($"[{model}] [{deviceId}] [{device.PortName}] {barcodes.Count} Barcode(s) Read");
string logFile = Path.Combine(logDirectory, $"Barcodes_{deviceId}.txt");
foreach (var barcode in barcodes)
{
DateTime ts = barcode.Timestamp;
string line = $"{barcode.Data};{ts:HH:mm:ss};{ts:dd-MM-yyyy};{barcode.SymbologyName};{deviceId}";
File.AppendAllText(logFile, line + Environment.NewLine);
Console.WriteLine($"[{model}] [{deviceId}] [{device.PortName}] [{ts}] [{barcode.Data}] [{barcode.SymbologyName}]");
}
device.ClearBarcodes();
// Sync device time AFTER reading barcodes to be able to correct time stamps based on the computer and device time
// Calling device.ReadBarcodes(true) already syncs the time
//device.TryGetTime(out DateTime dTime);
//device.SetTime(DateTime.Now);
// Demonstrates the reading and writing of all parameter types (bool, int, enum and string/byte array)
//device.GetParameter(OpnParameter.Code39, out bool enabled);
//device.GetParameter(OpnParameter.ScannerOnTime, out int time);
//device.GetParameter(OpnParameter.DeleteEnable, out DeleteEnableOptions deleteOptions);
//device.SetParameter(OpnParameter.Code39, true);
//device.SetParameter(OpnParameter.ScannerOnTime, 20);
//device.SetParameter(OpnParameter.Gs1DataBar, Gs1DataBarOptions.Gs1DataBar | Gs1DataBarOptions.Gs1Expanded);
//device.SetParameter(OpnParameter.ScratchPad, "Hello");
// Don't disconnect if you want callbacks for detecting new barcodes while connected (only works on Windows and using the USB-VCP driver)
device.Disconnect();
}
else
{ // Handle removal / disconnect
if (device.GetDeviceId() != null)
Console.WriteLine($"[{device.GetModel()}] [{device.GetDeviceId()}] [{device.PortName}] Disconnected");
else
Console.WriteLine($"[{device.PortName}] Removed");
}
return 1; // Return 1 to indicate the device was successfully processed
}
catch (Exception ex)
{
Console.WriteLine($"Exception occurred ({device.PortName}): {ex.Message}");
return 0; // Return 0 to continue polling, so we can retry later
}
});
Console.WriteLine("Connect your OPN Companion devices.....");
await Task.Delay(Timeout.Infinite);
}
}
Troubleshooting
Device not found or recognized
On Linux and macOS, make sure your device is configured to use the CDC driver (default: BQZ; only supported on OPN-2500 and OPN-6000).
Note Laser scanners, like the OPN-2500, can't read barcodes from a screen. To print the barcode, use Opticonfigure
Legacy .Net Wrapper
For legacy application using the old .Net wrapper, 'Opticon.csp2'-calls are still available, but COM port numbers have been replaced by port names for cross-platform compatiblity. However, it is recommended to upgrade to the new CspNet implementation, since it's more suitable for Object-oriented programming and is more user friendly
License
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Win32.Registry (>= 5.0.0)
- System.IO.Ports (>= 8.0.0)
-
.NETStandard 2.1
- Microsoft.Win32.Registry (>= 5.0.0)
- System.IO.Ports (>= 8.0.0)
-
net6.0
- Microsoft.Win32.Registry (>= 5.0.0)
- System.IO.Ports (>= 8.0.0)
-
net8.0
- Microsoft.Win32.Registry (>= 5.0.0)
- System.IO.Ports (>= 8.0.0)
-
net9.0
- Microsoft.Win32.Registry (>= 5.0.0)
- System.IO.Ports (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.7 | 0 | 6/11/2026 |
| 2.0.6 | 0 | 6/11/2026 |
| 2.0.5 | 33 | 6/10/2026 |
| 2.0.4 | 47 | 6/9/2026 |
| 2.0.3 | 54 | 6/5/2026 |
| 2.0.1 | 91 | 6/3/2026 |
| 1.2.5 | 100 | 6/2/2026 |
| 1.2.4 | 89 | 5/1/2026 |
| 1.2.3 | 78 | 4/30/2026 |
| 1.2.2 | 91 | 4/28/2026 |
| 1.2.1 | 94 | 4/23/2026 |
| 1.2.0 | 91 | 4/23/2026 |
| 1.1.4 | 96 | 4/21/2026 |
| 1.1.3 | 85 | 4/20/2026 |
| 1.1.2 | 95 | 4/20/2026 |
| 1.0.4 | 94 | 4/17/2026 |
| 1.0.4-beta | 89 | 4/17/2026 |
| 1.0.3 | 106 | 4/16/2026 |
| 1.0.2 | 99 | 4/16/2026 |