Closed maxxie85 closed 2 years ago
Some additional information, I noticed there was a major upgrade for TC/BSD. I was running TC/BSD 12. After the upgrade to TC/BSD 13.0.11.1.2 I still get the same issue.
Just registering the Symbol as Device Notification seems to trigger the problem here. Could you narrow down the problem to a single symbol? Demonstration code would be helpful, C# + PLC.
Well this is most interesting. When I tried to narrow it down, I seem to have solved it myself. Because I can't trigger the exception anymore. Only I thing I can think of is I cleaned up the decorator class we use.
I had the issue again, after a little digging I found what triggers this problem.
First some clarification, it happens on TC RT (TCBSD) as wel on TC CE7, the difference is that TC RT (TCBSD) keeps running while TC CE7 crashes and requires a power cycle of the PLC. More interesting, and this threw me off before, it doesn't happen on TC CE7 3.1.4024.10 but does on TC CE7 3.1.4024.17 and 3.1.4024.22 (at least for the CX9020 that is).
So what I found is that an exception is triggered when registering a WhenValueChanged on a Symbol that is represented in the PLC as a Property with a Get and a Set. If the property only has a Get, everything is fine.
On the CX9020 3.1.4024.17 and .22 this results in a hang of the PLC with a message in XaeShell
Severity Code Description Project File Line Suppression State
Error 9-6-2022 10:30:39 859 ms | 'PlcAuxTask' (270): Exception 'Misaligned data' in module
'TcFrameworkW32.DLL' (?)
Offset=0x22b40
Code P1:0x00 P2:0xD1BF2B40
P3:0x00000000 P4:0x0180001A
Stack:
0xD8C7245C
0x00000000
0x00000000
0x00000000
And in .Net you get and Exception with ADS Error code 1803 DemoApplication WhenValueChanged.zip
An PLC Property doesn't support Notifications. Therefore a WhenValueChanged should throw an AdsErrorException with the following code
/// <summary>
/// Invalid parameter value(s).
/// <para>Error code: 1803 (0x70b).</para>
/// <para>Category: Device</para>
/// <para>C++: ADSERR_DEVICE_INVALIDPARM</para>
/// </summary>
DeviceInvalidParam = 0x0000070b,
At least with my actual virtual test system (Windows 64Bit + TwinCAT 4024.23) this works as intended. I will check this another way, unfortunately I don't have a CX9020 by hand at the moment.
An PLC Property doesn't support Notifications.
Interestingly that it does works on a CX9020 with TC3.1.4024.10, but that could be a happy accident. As it isn't a supported feature, that makes this issue mute. However I do feel that it shouldn't crash the PLC.
Probably it simply neither crashed the Plc in 4024.10, but I personally don't believe that the Notification behind was functional. Nevertheless It shouldn't crash and It should return a proper AdsErrorException (under WinCE, TcBSD or whatever). We have to check if the issue is fixed also on ARM platforms - at least with our latest 4024.29.
On WinCE 3.1.4024.10 on the CX9020 it is a functional notification. We have several PLC's on that version where we do our testing and development on. I have a CX8190 also on that version and it also works on that one. That is what confused me the first time, because when I worked on TCBDS it suddenly failed with an exception which I didn't got on the ARM PLC's.
I can't test the ARM version of 4024.29 as I don't see a public build of that version for the CX9020
You are right, on Win64 3.1.4024.10 everything works as expected, the 3.14024.29 still triggers an AdsErrorException Code 1803 on registering the Notification.
I have opened an internal issue for the PLC Team. Actually I don't now in which version it will be fixed (something > 4024.32). Because this is a TwinCAT Core problem I close it here ....
When registering a WhenValueChanged subscription on a Symbol. The method throws a Parameter value(s) is invalid (ADS error code 1803) exception when using the TwinCAT RTx64 based on TCBSD.
However the same code does works on a CX8190 or CX9020 system.
The code
StackTrace