DatalogicComHelper 1.1.0

dotnet add package DatalogicComHelper --version 1.1.0                
NuGet\Install-Package DatalogicComHelper -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DatalogicComHelper" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DatalogicComHelper --version 1.1.0                
#r "nuget: DatalogicComHelper, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DatalogicComHelper as a Cake Addin
#addin nuget:?package=DatalogicComHelper&version=1.1.0

// Install DatalogicComHelper as a Cake Tool
#tool nuget:?package=DatalogicComHelper&version=1.1.0                

DatalogicComHelper

DatalogicComHelper is a C# library designed to assist in communicating with Datalogic devices (tested with 320N). The library provides simple methods to start the phase mode and one-shot mode of the devices both synchronously and asynchronously, connecting via TCP/IP.

Installation

Via NuGet:
You can install the library via NuGet package manager by searching for DatalogicComHelper or using the following command:

Install-Package DatalogicComHelper

Usage

First you need to configure the device using Datalogic software DL.CODE, setting IP Address, port, operation mode, type(s) of barcode to be read etc.

Parameters:

  • ipAddress: The IP address of the Datalogic device you wish to connect to.
  • ipPort: The port on the Datalogic device to which the connection should be established.
  • startCommandString: The string command that triggers the device to start reading (set via DL.CODE).
  • stopCommandString (only for phase-mode): The string command that triggers the device to stop reading (set via DL.CODE).
  • timeoutMilliseconds: Timeout in milliseconds waiting for a read response. Returns a TimeoutException if elapsed.

Initialize the Service

using DatalogicComHelper;
var service = new DatalogicService();

Start Phase Mode

Asynchronously:

string response = await service.StartPhaseModeAsync("192.168.1.100", 51236, "START", "STOP", 5000);

Synchronously:

string response = service.StartPhaseMode("192.168.1.100", 51236 "START", "STOP", 5000);

Start One-Shot Mode

Asynchronously:

string response = await service.StartOneShotModeAsync("192.168.1.100", 51236, "START", 5000);

Synchronously:

string response = service.StartOneShotMode("192.168.1.100", 51236, "START", 5000);

Note:

All methods send the start trigger and then wait for a response from the device until timeout is reached. If using phase-mode a stop string is sent to the device in any case.

Error Handling

It's recommended to surround the method calls with try-catch blocks to handle any potential errors, especially when dealing with network operations:

try
{
    string response = service.StartOneShotMode("192.168.1.100", 51236, "START", 5000);
    Console.WriteLine(response);
}
catch(Exception ex)
{
    Console.WriteLine($"Error: {ex.Message}");
}

License

Distributed under the MIT License.

Project GitHub

https://github.com/nedoalaimo/DatalogicComHelper/wiki

Product Compatible and additional computed target framework versions.
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8

    • No dependencies.

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
1.1.0 351 8/17/2023
1.0.5 145 8/14/2023
1.0.4 161 8/14/2023
1.0.3 153 8/14/2023
1.0.2 158 8/14/2023
1.0.1 136 8/14/2023
1.0.0 170 8/14/2023

Added timeout where reading the response.