Libplctag Versions Save

This C library provides a portable and simple API for accessing Allen-Bradley and Modbus PLC data over Ethernet.

v2.5.5

1 year ago

Thanks to user @nc-koko for surfacing these problems.

  • Events were being missed on tag creation when using asynchronous mode. Specifically the created event was missing.
  • Shutdown was not fully cleaning up internal library Modbus resources in some circumstances under Windows.
  • Thanks to @timyhac for experimenting on the shutdown problem. I think we might still have some work to do there with the combination of the core library, Windows and .Net, but it is a lot better.

Please double check that you are getting all the events you think you should get after upgrading. And, please let me know if you see duplicate events! I did not see any in my testing, but absence of evidence is not evidence of absence.

v2.5.4

1 year ago

This has two main fixes/enhancements:

  • Allow spaces in some parts of the tag string. Spaces are stripped from the attribute names. Spaces are allowed between parts of a path. I probably will not go further than that as it would prevent spaces from being used in attribute values. Thanks to user @igal92 for bringing this up a long, long time ago.
  • Allow the use of DH+ node 0 (zero). This was brought up a long time ago by @jimk907. There was some logic in the set up of DH+ bridging that was using the node ID as a sort of flag to determine whether a path had a DH+ bridge in it. I suggest that you do not use node ID 0 in your DH+ networks. I seem to remember that it is special in some way. But if you do, it is now supported.

v2.5.3

1 year ago

This has two fixes in it. The first fixes issue #385 to help the contributed CLI compile on MinGW64. The second allows the querying of the "elem_type" attribute for AB tags. For now, this supports PCCC tags mostly and CIP PLC tags if you set the elem_type in the tag attribute string. This will change so that the tag type as read back from the PLC is returned but not in this release.

v2.5.2

1 year ago

This has fixes from user @tinajohnson (and apologies for dropping this PR on the floor for so long!) for string termination that could have been a problem if the tag names was long. It also has a performance change that user Rohit found where there could be a extra 100ms delay in some conditions of PLC connection set up. The final fix was for a problem found by user @engerlf where the loop that handled spurious condition variable wake ups was doing an incorrect time comparison.

Thanks very much for all the support from users on this release!

v2.5.1

1 year ago

Thanks to @tinajohnson for the buffer overrun fixes! This also exposed a CI build problem on GitHub because Visual Studio version 16 is no longer available on the Windows CI runner pool.

If you use Windows, please try this out. The DLLs are build with Visual Studio v17 2022 instead of version 16 2019. I do not know if there are any backwards incompatible changes since I do not have any Windows machines that are running anything earlier than Windows 10!

v2.5.0

2 years ago

This release is thanks to user @Joylei who kicked it off with a nice pull request with additional callback functionality. There are two new API functions added to use callbacks with support for a user-supplied pointer parameter.

WARNING note that the library has no way of knowing what any wrapper system does with the data pointed to by the pointer argument! For instance, if you pass in a pointer to a normal Java object, chances are that the garbage collector will run at some point and move your object. Then the pointer will be invalid and your program will likely crash. However, for systems that do support pinning memory in place or do not move memory, this allows you to directly point to some application object. It can also be used to pass integer or floating point data no larger than a pointer.

The examples have been updated to show the use of this in C. The wiki has been updated with the new functions.

A few other changes are in this release such as cleaner handling of events and addition of a PLCTAG_EVENT_CREATED event that will fire when a tag is created and ready for use. Note that "ready for use" depends on the type of the tag. A normal tag in a ControlLogix will perform a tag read before being ready. A tag listing tag will not.

Please test this out. The version has changed to 2.5.0 because there is an API change. I tried hard to make sure that older code will continue to work with this, but there were enough internal changes to event handling that you probably should run this through your own test processes before picking it up for production use.

v2.4.12

2 years ago

One more try. The previous try did not get merged correctly.

Thanks to @heppth for finding a use-after-free problem and helping to reproduce and debug it!

Please upgrade to this release, not the previously mentioned 2.4.11.

v2.4.10

2 years ago

Many thanks to @radrevere for all the help and testing and thought! In some circumstances it was possible to overwrite memory and corrupt the heap.

It looks like the core problem was triggered by the following:

  1. have a non-standard string size
  2. do not use the str_ special string attributes to tell the library what the correct string sizes are. Specifically, the actual size of the character data must be smaller than the default (82) size.
  3. set a value that fits in the non-standard size but leaves some room for zero-ing out the remainder of the default size.

Then the loop that zeros out the rest of the tag buffer will overwrite memory. I put checks on all three parts of writing to the tag buffer data:

  • a check on each byte write of the string data into the tag buffer.
  • a check on each byte write when zeroing out the remainder of the buffer.
  • a check on the final end index when writing out the string count/size value.

Please test this extensively! I was not able to duplicate the problem until I met the three criteria above. I will probably need to add a section to the wiki about strings because they are so tricky.

v2.4.9

2 years ago

Many thanks to user @vernturbine on the forum for helping test the Micro8x0 tag listing. It looks like this is now working. I applied the same fixes to Omron systems as well. Perhaps they work now too? This splits out the tag listing example program into two programs: one for Control/CompactLogix systems and one for Micro8x0 systems. I need to refactor this in the future to make this cleaner.

There are also some additional tests added to the local test suite that I use before pushing to GitHub.

And finally there are some fixes for missing read/write completion events when using special/system tags (which no one but myself probably ever does). This was found when I tried to update the Java wrapper with the latest code.

v2.4.8

2 years ago

This release contains a set of small fixes to allow up to 100k tags with a single instance of libplctag. It also contains some better error handling for errors on macOS for sockpair(). More tests have been added to the run_tests.sh script.

The performance tweaks in this release help the library support at least 100k tags without overwhelming the CPU. With 100k tags each using automatic reads every 4 seconds and 50 simulated PLCs, the library takes about 125% of the CPU (multiple cores) on my 2020 MacBook Air M1. The goals of this set of tweaks were to make sure that the tag tickler thread does not eat all the CPU and that reads are skipped on long delays to catch up with the original requested timing.