Commit Graph

88 Commits

Author SHA1 Message Date
Michael Croes
6e861d2f00 Merge branch 'develop' into tests-taskCanceled 2021-06-07 22:00:52 +02:00
Serge Camille
15f94cd7bf Fix Cancellation test. 2021-06-07 14:13:04 +02:00
Michael Croes
36b59a2926 Cleanup whitespace, usings 2021-06-06 23:20:19 +02:00
Michael Croes
8d081859da Remove unused sync methods 2021-06-06 23:19:56 +02:00
Michael Croes
b0a6a2375f Merge branch 'develop' into multipleVarsAlignment 2021-06-06 22:49:33 +02:00
Michael Croes
66b693676c Merge branch 'develop' into s7-200-cr 2021-06-06 22:32:41 +02:00
Serge Camille
a4b6a360fe ParseDataIntoDataItems needs to always align the response address to a even value after each data item. 2021-06-06 22:16:59 +02:00
Serge Camille
0bef6bc9ff Add unit test for the problem. 2021-06-06 21:59:39 +02:00
Michael Croes
cbe04fbfb4 Merge branch 'develop' into tsap 2021-06-06 21:19:17 +02:00
Serge Camille
fc9c33fdaf Add Net5.0 to test project as well. 2021-06-05 17:59:18 +02:00
Michael Croes
2fae2c01d5 Add TsapPair support to PLC
Add support for custom addressing by supplying a TsapPair to the PLC.
CPU, Rack and Slot properties are still present to preserve backwards
compatibility and to support alternate functionality based on the PLC
type.
2021-06-04 22:25:05 +02:00
Michael Croes
616dc1094c Refactor TSAP related code 2021-06-04 21:45:51 +02:00
Michael Croes
70bc1499ef ConnectionRequestTest: Cleanup trailing whitespace 2021-06-02 23:03:23 +02:00
Michael Croes
fd9aeb5b3b Fix unit test for S7 200 2021-06-02 23:03:06 +02:00
Michael Croes
e66d21af05 Add tests for Boolean.SetBit and Boolean.ClearBit 2021-05-10 20:49:15 +02:00
Michael Croes
2b4ec6d9dd Remove IsAvailable
Addresses #275, #252, #208, #154.
2021-03-29 21:43:24 +02:00
diego
e6d14587d3 Added four new test methods to check ByteLength for S7 String types 2021-03-29 20:51:11 +02:00
Mike Cremer
fdd4519f64 Minor changes 2021-01-29 21:13:38 +01:00
Mike Cremer
de0a9e64dc Added support for strings in Struct type class 2021-01-24 13:56:07 +01:00
Mike Cremer
dfcc4c7408 Added WString support 2021-01-24 12:16:32 +01:00
Serge Camille
1069641606 Add more extensive response code validation.
Fixes #310
2020-09-16 20:25:20 +02:00
Michael Croes
243e868488 Merge branch 'develop' into stringSerialization 2020-09-16 20:13:19 +02:00
Serge Camille
8f3c701a2f Revert UnitTest IP address to 127.0.0.1.
Seems there are sometimes performance regressions when using localhost. Might be related to IPv6, who know.

Fix some TestContext not being public.
2020-09-13 10:28:06 +02:00
Serge Camille
023530322e Remove Port 102 dependencies from Unit Test.
- Adjust readme.
- It is no longer be necessary to shut down service s7oiehsx64.
2020-09-13 10:15:53 +02:00
Serge Camille
9198fc1686 Test project: Enable netcore3.1 testing, switch win64 Snap7 and use custom port.
- Add netcoreapp3.1 target framework, allowing this to run on linux and macos as well.
- Switch windows snap7 DLL to 64bit version 1.4.2. This also improves UnitTest stability (reduces false positives) on the CI (including appveyor)
- Changing the port used for S7NetTests when communicating with Snap7 to a value > 1000 allows tests to run on Linux without elevated privileges.
2020-09-13 10:01:38 +02:00
Serge Camille
b088fe276b Rename StringEx to S7String.
This name is already somewhat used in code and gives this a better name.
2020-09-12 19:27:15 +02:00
Serge Camille
e5bdb10ce3 Add cancellation UnitTest.
This is very fragile with time-dependent cancellation, but I don't know of a better way without messing with the code to be tested.

Seems to only work when the test is run as a single run, not when running the whole test suit.
2020-09-09 21:24:39 +02:00
Serge Camille
6c4d4605f0 Add CancellationToken support to async functions. 2020-09-09 21:24:36 +02:00
Serge Camille
1919b0083a StringEx more strict malformed checks when parsing byte array.
- min length of 2.
- capacity >= length
2020-09-04 22:33:54 +02:00
Serge Camille
fd4bc0fe84 Adjust StringEx ToByteArray.
- Do not allow null string to be passed, raise ArgumentNullException.
- Do not allow string whose ASCII representation is longer than the reserved length, since this currently leads to silent data loss.
- Always write the full binary data length of 2 + reservedLength, since that is what the binary representation of that string is in S7 memory, even if some tail bytes are unused by the current string.

I also suspect that S7WriteMultiple would have chocked on that last bit, but I am not sure. There aren't any tests for writing multiple Dataitems right now.

Adjust tests accordingly. Mostly add some tail bytes where necessary, and assert on exceptions where this is now required.
2020-09-04 22:33:54 +02:00
Serge Camille
64c781ec8b Remove unnecessary includes and commented-out test. 2020-09-04 20:46:16 +02:00
Serge Camille
e8a9983367 Add LReal support, kill old "Double" sham.
- Adds true support for 64bit double / LReal datatype.
- Set old Types.Single and Types.Double to obselete. Both class names use .NET types instead of S7 type names, contrary to all other types.
- Remove already obsoleted conversion from DWord to Real. Why is this even necessary?
  For users caring about converting from DWord, they can still convert to single. But unless we get LWord support, there won't be a direct conversion to double/LReal.
- Adjust unit tests by removing rounding, testing directly double read/writes.

There is quite a bit of breaking changes at least in the automated Struct and object functions which automatically translate .NET types to appropriate S7 types.
My consideration was that if we ever want to support 64bit types, there is no way against breaking those existing incorrect conversions from 64bit .NET double to 32 bit S7 Real variables.
2020-09-04 20:46:16 +02:00
Serge Camille
edfa208c3e Simplify TPKT Read buffer length arguments and improve exception message. 2020-09-03 20:48:18 +02:00
Serge Camille
d11f46eedb Rename ReadFixed to ReadExact, separate Unit test for ReadExact. 2020-09-03 20:48:18 +02:00
Serge Camille
09c8b18d3d Adjust ReadFixed implementation somewhat. Exceeding the length of the buffer was already an error before.
Change the tests by replacing the memory buffer with a Fake stream giving 1 byte at a time.
2020-09-03 20:48:18 +02:00
Jakob Ledermann
7d570f93c1 Unittests for issue #283
These unittests fail intentionally as the issue discussion has not reached
a consesual solution. Any solution should pass the unittests added in this commit.
2020-09-03 20:48:17 +02:00
Serge Camille
2bb7ac7d2a Write large byte array in S7NetTests to check for MaxPDU problems on Snap7.
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.
2020-09-02 20:16:53 +02:00
Serge Camille
bd8177d39e Add nullable support throughout the whole library.
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.
2020-08-31 22:48:45 +02:00
Serge Camille
7035d22506 Convert UnitTest project to SDK project type. 2020-08-18 09:20:31 +02:00
Serge Camille
3258c84fbc Add DateTimeLong test to S7NetTestsSync 2020-08-17 19:20:47 +02:00
Serge Camille
a1d87de2d9 Rename DTL to DateTimeLong 2020-08-17 19:14:28 +02:00
Serge Camille
5d59c8284d Add DTL type
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)
2020-08-16 22:31:26 +02:00
Michael Croes
9a34b14e1e Tests/TypeTests: Add ClassTests from #178
Close #178.
2020-08-13 21:57:42 +02:00
Tim Verwaal
8dc89867e9 Extended PLCAddress.Parse method 2019-12-19 10:55:51 +01:00
Michael Croes
555d1e8956 Add unit test for Types.DateTime 2019-07-17 21:07:45 +02:00
Michael Croes
4ae905ffd5 Set PDU size to 960
Allows communication with Siemens Logo 0BA8, currently no Siemens PLC
is known to support >960 PDU size.
2019-03-14 23:04:26 +01:00
Adam Oleksy
de084394a6 Fix writing nested classes 2018-10-04 18:14:44 +02:00
Adam Oleksy
370fd6b3d9 Fix reading nested classes 2018-09-26 14:43:49 +02:00
Michael Croes
96efb9d56a Add tests for String.ToByteArray(...) 2018-07-11 22:07:34 +02:00
Raphael Schlameuß
214a7a73c8 Read many bytes 1500 (develop branch) (#160)
* ReadBytesWithSingleRequest cannot read >491 Bytes on S7-1500
2018-07-11 10:15:08 +02:00