Commit Graph

382 Commits

Author SHA1 Message Date
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
Michael Croes
40edecad43 Merge pull request #356 from mycroes/enable-documentation
Generate documentation file
2021-01-05 22:14:26 +01:00
Michael Croes
0b04c86cb9 Generate documentation file 2021-01-05 22:07:11 +01:00
Michael Croes
9cd63d906f Merge pull request #338 from scamille/fixOpen
Fix OpenAsync function to rethrow exception during connection establish.
2020-10-17 20:04:57 +02:00
Serge Camille
d051b93bdc Fix OpenAsync function to rethrow exception during connection establish.
This bug was introduced in 106e9912
2020-10-17 17:54:30 +02:00
Michael Croes
c9bab7523a Merge pull request #317 from scamille/read-request-header
Unify async read request header building.
2020-10-14 21:14:17 +02:00
Serge Camille
a7608e3cb7 Rename and Move DataRequestItem 2020-09-26 21:28:31 +02:00
Serge Camille
4d37679c75 Move BuildReadRequestPackage to PlcHelpers, cleanup. 2020-09-26 21:21:37 +02:00
Serge Camille
e2a0ed548d Unify async read request header building.
Add concept of DataRequestItem which contains the necessary data to build the request.
2020-09-26 21:21:37 +02:00
Michael Croes
4124bae1bc Merge pull request #314 from scamille/cleanupOpen
Cleanup OpenAsync function.
2020-09-21 23:09:07 +02:00
Michael Croes
2bcc5e6b9c Merge branch 'develop' into cleanupOpen 2020-09-21 23:06:06 +02:00
Serge Camille
33981ab4f9 Use int for MaxPduSize and parse communication response for it as uint16 2020-09-16 23:09:23 +02:00
Serge Camille
de60a7b6b0 Add .ConfigureAwait(false) throughout OpenAsync callstack. 2020-09-16 22:38:05 +02:00
Michael Croes
de87409458 Merge pull request #321 from FalcoGoodbody/patch-1
Remove outdated documentation link.
2020-09-16 22:32:55 +02:00
Serge Camille
ca89736c7c Use GetAwaiter().GetResult(); 2020-09-16 22:31:51 +02:00
Serge Camille
4a72c3596b Revert MaxPDUSize parse change. 2020-09-16 22:28:42 +02:00
Michael Croes
786e012179 Merge branch 'develop' into patch-1 2020-09-16 22:07:15 +02:00
Michael Croes
f46833606f Merge pull request #316 from scamille/responseValidation
Add more extensive response code validation.
2020-09-16 20:53:46 +02:00
Serge Camille
b95b71e9aa Remove unnecessary string interpolation in ValidateResponseCode 2020-09-16 20:26:53 +02:00
Serge Camille
1069641606 Add more extensive response code validation.
Fixes #310
2020-09-16 20:25:20 +02:00
Michael Croes
36a9ecb2c8 Merge pull request #315 from scamille/stringSerialization
Rename StringEx to S7String.
2020-09-16 20:15:11 +02:00
Michael Croes
243e868488 Merge branch 'develop' into stringSerialization 2020-09-16 20:13:19 +02:00
Michael Croes
ff65f06b7d Merge pull request #318 from scamille/netcoretests
Linux timeout fix & Multi-Platform Unit Test support
2020-09-16 20:12:48 +02:00
FalcoGoodbody
065b1fbdf8 Update README.md
delete the link to PDF documentation because it is outdated. The actual docu can be found in the wiki
2020-09-15 09:19:51 +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
12a2e3c0b1 Fix runtime error on linux with default Socket timeouts.
The default value for socket timeout API is 0 and not -1, so revert to that value to give the intended infinite timeout on all platforms.
2020-09-13 09:57:13 +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
80ad95372b Use Stream.Dispose() for NetStandard 1.3 2020-09-12 11:19:08 +02:00
Serge Camille
106e9912ab Cleanup OpenAsync function.
- Separate into Connect and EstablishConnection step.
- Remove redundant null checks for returned data.
-  Only assing PLC stream object once we fully established a connection, and Close otherwise.
- Replace sync implementation with Async call.
2020-09-12 11:14:41 +02:00
Michael Croes
af39659944 Merge pull request #307 from scamille/fb-asyncCancellationTokens
Add CancellationToken support to async functions.
2020-09-10 23:50:41 +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
faea428e4c Try not to replace OperationCanceledException with PlcException. 2020-09-09 21:24:39 +02:00
Serge Camille
4da76c7f6d Add missing cancellationToken to Stream.WriteAsync call. 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
Michael Croes
730ccbf9fc Merge pull request #308 from scamille/fb-fixWarnings
Fix some null deref warnings.
2020-09-09 21:03:25 +02:00
Michael Croes
b36c4a98ec Merge branch 'develop' into fb-fixWarnings 2020-09-09 21:01:54 +02:00
Michael Croes
70c3f8e996 Merge pull request #309 from scamille/fb-varHints
Apply some of the hints that the compiler is giving.
2020-09-09 20:42:33 +02:00
Michael Croes
cf1b71220a Merge branch 'develop' into fb-varHints 2020-09-09 20:40:09 +02:00
Michael Croes
88c45bd995 Merge pull request #292 from scamille/fb-StringEx
Adjust StringEx ToByteArray.
2020-09-08 21:59:28 +02:00
Serge Camille
cf493d47f0 Apply some of the hints that the compiler is giving. 2020-09-06 15:04:20 +02:00
Serge Camille
9e2f17fdf3 Fix some null deref warnings. 2020-09-06 15:00:08 +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
Michael Croes
9ff73ff3f7 Merge pull request #303 from mycroes/remove-embed-sources
Remove EmbedAllSources from S7.Net
2020-09-04 22:10:52 +02:00
Michael Croes
c31353bed2 Remove EmbedAllSources from S7.Net
Sources are already provided via SourceLink, no need to embed them as
well.
2020-09-04 22:06:58 +02:00
Michael Croes
b16097092b Merge pull request #290 from scamille/fb-AdjustDataItemsPduCheck
Adjust AssertPduSize checks for Reading multiple DataItems.
2020-09-04 21:39:55 +02:00
Serge Camille
eca2ed6474 Add required request & response sizes to PDU limit exception messages. 2020-09-04 21:06:06 +02:00