libplctag / libplctag.NET

A .NET wrapper for libplctag.
https://libplctag.github.io/
Mozilla Public License 2.0
197 stars 49 forks source link

Fix for #304 - use `plc_tag_create_ex` for Initialization #307

Closed timyhac closed 1 year ago

timyhac commented 1 year ago

This PR modifies the Initialize/InitializeAsync methods to make use of plc_tag_create_ex instead of plc_tag_create - which allows us to capture events early in the tag lifecycle.

kyle-github commented 1 year ago

Over the holiday weekend (here in the US), I'll do some testing to make sure that the Modbus code is actually generating the right events. That will tackle this problem from the other end.

jkoplo commented 1 year ago

@kyle-github do you have a good modbus simulator or even some automated tests for modbus?

kyle-github commented 1 year ago

In the src/tests/ directory I have a couple files that do testing. One is a small wrapper (in Python) around libmodbus which is a C-based library that is very, very widely used for Modbus on Linux. This sets up a small Modbus server with some registers. The other is run_tests.sh which is just a shell script that runs 20+ specific tests against my real hardware and this Modbus simulator and against my CIP simulator. The CI system runs a subset of these since there is no PLC hardware in GitHub's test runner pool.

That said, I don't have the ability to inject delays or faults into the Modbus tests like I do with the CIP tests (delays are supported and used to test timeouts).