APDPCCommsDLL 1.0.0

dotnet add package APDPCCommsDLL --version 1.0.0
                    
NuGet\Install-Package APDPCCommsDLL -Version 1.0.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="APDPCCommsDLL" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="APDPCCommsDLL" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="APDPCCommsDLL" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add APDPCCommsDLL --version 1.0.0
                    
#r "nuget: APDPCCommsDLL, 1.0.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.
#:package APDPCCommsDLL@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=APDPCCommsDLL&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=APDPCCommsDLL&version=1.0.0
                    
Install as a Cake Tool

APDPCCommsDLL

Implements serial communication protocols for Crane Advanced Protocol Devices (APD), providing robust methods for sending commands, receiving replies, and handling protocol-specific details.

Namespace: APDPCCommsDLL
Main Classes:

  • ISerialComms:
    Interface for serial port operations (open, close, read, write, buffer management).
  • RealComms:
    Concrete implementation of ISerialComms using System.IO.Ports.SerialPort.
  • APDCommsProtocol:
    Core class for building, sending, and processing APD protocol messages, including error handling, retries, and logging.
  • Enums:
    COMMS_RESULT (communication status), NACK_CODES (protocol-specific error codes).

Features:

  • Serial Port Abstraction: Allows for flexible serial communication via the ISerialComms interface.
  • Protocol Handling:
  • Constructs messages with start/end markers, checksums, and destination IDs.
  • Supports both ASCII and binary replies.
  • Handles ACK/NACK responses and extracts protocol-specific codes.
  • Error Handling & Logging:
  • Detailed logging via Microsoft.Extensions.Logging.Abstractions (optional).
  • Handles timeouts, access denied errors, and protocol-specific errors.
  • Configurability:
    • Timeout, retries, and corruption injection for testing.
    • Properties for port name, baud rate, and reply data.

Target Framework:

  • C# 13.0
  • .NET 8

Typical Usage: The DLL is intended to be referenced by applications needing to communicate with AP devices over serial ports, handling all low-level protocol details and error scenarios.

Example Routine to send Users to an APD

        public void SendUsers(ref byte intUsersSent, List<User_Table> Users)
        {
            // Initialise Count
            intUsersSent = 0;

            // First clear All Users on APD
            if (APDComms.Command_Clear_Users())
            {
                // Convert and send Users to APD
                using (IEnumerator<User_Table> lstUsers = Users.GetEnumerator())
                {
                    while (lstUsers.MoveNext())
                    {
                        // Get the current User form the list without casting
                        User_Table user = lstUsers.Current;

                        // Convert to APD User
                        APDUser apdUser = new APDUser();
                        if (user.uuid != null) apdUser.UUID = user.uuid;
                        apdUser.FirstName = user.First_Name.Trim();
                        apdUser.LastName = user.Last_Name.Trim();
                        apdUser.AuditDeviceUsername = user.Audit_Device_Username.Trim();
                        apdUser.AuditDevicePassword = user.Audit_Device_Password.Trim();

                        // Set User's Privilege Level
                        if ((bool)user.Administrator)
                        {
                            apdUser.UserPrivilege = APDUser.USER_PRIVILEGE.ADMIN;
                        }
                        else
                        {
                            if (user.Audit_Device_Superuser)
                            {
                                apdUser.UserPrivilege = APDUser.USER_PRIVILEGE.TEAM_LEADER;
                            }
                            else
                            {
                                apdUser.UserPrivilege = APDUser.USER_PRIVILEGE.OPERATOR;
                            }
                        }

                        // Attempt to send User to APD
                        if (APDComms.Command_Send_User(apdUser))
                        {
                            // Update Count of Users Sent
                            intUsersSent += 1;
                        }
                        else
                        {
                            // Send User failed so abort
                            break;
                        }
                    }
                }
            }
        }
Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0.0 307 10/7/2025