Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on:
push:
branches: [ main ]
pull_request:

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5

- uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
10.0.x

- name: Restore
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore

- name: Test
run: dotnet test --configuration Release --no-build --verbosity normal

- name: Pack
run: dotnet pack src/CimonPlc/CimonPlc.csproj --configuration Release --no-build --output artifacts

- uses: actions/upload-artifact@v4
with:
name: nuget-package
path: artifacts/*
72 changes: 0 additions & 72 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

65 changes: 12 additions & 53 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
name: CodeQL

on:
push:
branches: [ "main" ]
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
branches: [ main ]
schedule:
- cron: '42 12 * * 2'

Expand All @@ -29,44 +17,15 @@ jobs:
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'csharp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
- name: Checkout repository
uses: actions/checkout@v5

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: csharp
build-mode: none

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Changelog

## 2.0.0

### Fixed
- **Ethernet read requests were malformed**: the `Length` field of `ReadWordAsync`/`ReadBitAsync` frames was written as 1 byte instead of 2,
shifting the whole data block by one byte. Read frames now use the same `ID | FrameNo | Cmd | Res | Length(2) | Data | CheckSum` layout as write frames.
- `TcpSocket` could not reconnect after being disconnected (a closed `Socket` was reused), so with `autoConnect` every request after the first one failed
with `ObjectDisposedException`. A new socket is now created for each connection.
- Frame numbers did not wrap correctly: after 128 requests the frame number stayed `0` for the next 128 requests. It now cycles from 0 to 127.
- `SerialSocket.ReceiveData` returned a `null` task when a read was incomplete, which caused a `NullReferenceException` when awaited.
- Short, truncated or corrupted responses caused `IndexOutOfRangeException`; they now return `ResponseCode.WritingError`.
- Serial `WriteWordAsync` accepted up to 63 words although the 2-char length field can only describe 61; larger requests silently produced a wrong length.
- Opening an already open `SerialSocket` threw an exception.

### Changed
- Responses are returned as soon as a complete frame arrives, instead of always waiting for the full read timeout (1 s by default) on every request.
- Connections opened explicitly with `Connect()` are no longer closed after each request when `autoConnect` is enabled; only connections opened automatically are closed.
- Requests on one connector are serialized, so a connector can be shared between concurrent tasks.
- `TcpSocket` has a new optional `usePing` parameter to skip the ICMP ping before connecting.
- `PlcConnector`, `TcpSocket` and `SerialSocket` implement `IDisposable`.
- Addresses are sent in upper case.
- Targets `netstandard2.0` and `net8.0` (was `netcoreapp3.1`, which is out of support), so the package also works on .NET Framework.
- Removed the `Ardalis.GuardClauses` dependency.
- **Breaking:** the helper classes `Tools` and the guard extensions are now internal.
- **Breaking:** `PlcConnector` constructor is now `protected PlcConnector(IPlcSocket socket, bool autoConnect)` and the protected `_timeout` field was removed.
- Fixed `dotnet pack`, which referenced an icon on a local disk path.
- Replaced duplicate CodeQL workflows with a single updated one, and added a CI workflow that builds, tests and packs the library.

## 1.1.0
- Downgrade project to .NET Core 3.1.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Mojtaba Kiani

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading
Loading