The previous problem of not being able to use a larger chunk size than 200 was that the complete header building code for the async implementation was incorrect. Specifically, it wrote the package size only as a byte instead of a int16, thus restricting the package size to something < 256.
With the sharing of the Header building code in the previous commits, this problem was resolved by accident, and thus the chunk size can be increased to the maximum value allowed by the PDUSize.
For me the tests work fine even when adjust the "chunk size" in WriteBytesAsync. So Snap7 seems to be fine, at least the current version.
This should probably be tested with some live PLC's as well.
Both Synchronous and Asynchronous need to build the same binary data package to write a bytes array. Move that package building out into a common function.
Also use IEnumerable to pass in data instead of converting it to array and back multiple times. Not that happy with the whole ByteArray class, we could probably just use a MemoryStream instead.
This requires reference types that can be null to be annotated by a ? operator, similar to value types.
This gives the advantage that the compiler can warn against any null dereference exceptions, of which this commits elimits a few.
To make the underlying protocol implementation not any more complicated and to eliminate existing problems, and not that precise error reporting, I replaced some return null statements with explicit Exceptions. This lead to the assumption that those core protocoll functions always return non-null objects if they do not throw, making the PLC code simpler.
Adjust some NotConnected tests to look for explicit PlcException instead of NullReferenceException.
Add new class Types.Dtl by taking the DateTime type and adjusting things.
Also add unit test with binary data calculated by hand. (Need to verify with actual S7 data)
Release highlights:
- Add support for (I|O|Q)(B|D|W) addressing
- Fix Type for Mxxxx.x addresses
- Align array offsets to even bytes in classes
- Improve exceptions on failed reads
Release highlights:
- Adress checks for bit writes
- Support for reading/writing complex objects
- Better exceptions on Open(Async)
- Revert negotiated max PDU size to 960
- Add Logo0BA8 support
- Read/Write-Timeout support on TCP connection
- Fix for 0-padding of last dataItem in WriteMultiple
- Allow override of default port
- Improve exception message when parsing string
- Add DateTime type for reading/writing
- Verify items fit in a PDU on Read/Write-Multiple
- Fix size calculation for bit arrays