Repository navigation
Modernize library, fix protocol and connection bugs (v2.0.0) - #1
Merged
Merged
Conversation
Fixes: - Ethernet read requests wrote a 1-byte Length field instead of 2 bytes - TcpSocket reused a closed Socket, so auto-connect failed after the first request - Frame number did not wrap correctly after 128 requests - SerialSocket.ReceiveData could return a null Task - Truncated/corrupt responses threw IndexOutOfRangeException - Serial WriteWordAsync allowed word counts that overflow the length field Improvements: - Return as soon as a full frame arrives instead of always waiting the read timeout - Keep explicitly opened connections open; serialize requests per connector - Optional ping in TcpSocket, IDisposable on connectors and sockets - Target netstandard2.0 and net8.0, drop Ardalis.GuardClauses, fix dotnet pack - Update tests to net10.0 / current packages, use async Task tests, add regression tests - Replace duplicate CodeQL workflows, add CI build/test/pack workflow Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DJd5JnXo2vuX9foBcTtgGQ
- Add NuGet, downloads, CI, CodeQL, target framework and license badges - Restructure README with features, quick start, API overview, connection handling, address/memory type reference, response codes and limits - Add MIT LICENSE file matching the package license Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DJd5JnXo2vuX9foBcTtgGQ
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DJd5JnXo2vuX9foBcTtgGQ
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DJd5JnXo2vuX9foBcTtgGQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This brings the repository up to date: it fixes several real bugs in the Ethernet and serial protocol code, moves off the unsupported
netcoreapp3.1, adds CI, and rewrites the README. The package version is bumped to 2.0.0 because a few public helpers became internal (details below)Bug fixes
ReadWordAsyncandReadBitAsyncwrote theLengthfield as 1 byte instead of 2, which shifted the whole data block by one byte. Per the CIMON master frame layout (ID(9) · FrameNo(1) · Cmd(1) · Res(1) · Length(2) · Data · CheckSum(2)), read requests now use the same 2-byte length as writes.TcpSocketclosed its socket after each request and then tried to reuse it, so with the defaultautoConnect: trueevery later call threwObjectDisposedException. A new socket is now created for each connection.0for the next 128 requests. It now cycles 0–127.SerialSocket.ReceiveDatacould return anulltask, which throwsNullReferenceExceptionwhen awaited.IndexOutOfRangeException. They're now validated (header, frame number, length and checksum) and returnResponseCode.WritingError.WriteWordAsyncaccepted up to 63 words, but the 2-character length field can only describe 61. Larger requests silently sent a wrong length and are now rejected.SerialSocketthrew an exception.Improvements
Connect()now stays open. Only connections opened automatically are closed after the request.TcpSockethas an optionalusePingparameter for networks that block ICMP.IDisposable.netstandard2.0andnet8.0instead of the unsupportednetcoreapp3.1, so the package also works on .NET Framework 4.6.1+.Ardalis.GuardClauses. Its newer versions conflict with the custom extensions this project put in its namespace.dotnet packused to fail on any machine but the author's because the package icon pointed toC:\Users\...\cimon_logo.png. Packing now works and includes the README and symbols.Breaking changes
Toolsand the guard extension methods are nowinternal.PlcConnectorconstructor is nowprotected PlcConnector(IPlcSocket socket, bool autoConnect), and the protected_timeoutfield was removed.WriteWordAsyncaccepts at most 61 words (was 63).Tests and CI
async void, which in xUnit 2 can hide failures. They now useasync Task.CIworkflow that builds, tests and packs the library.Docs
LICENSEfile (MIT, matching the package metadata) and aCHANGELOG.md.archofthings/Cimon.Net.Testing
dotnet build: no warnings fornetstandard2.0ornet8.0dotnet test: 149 passed, 0 faileddotnet pack: the package is created, with the README and symbolsNot changed, worth checking
Serial
WriteBitAsyncsends each bit as a raw0x00/0x01byte rather than the ASCII characters'0'/'1'. That's unusual for an ASCII protocol, but I couldn't confirm what the spec expects, so the behavior is unchanged.