-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: PLC4X - 0.11.0 - Issue writing value to a Beckhoff PLC using ads driver #1156
Comments
@patrickboisclair can you check 0.11 with different syntax of tag - i.e. |
I'll try, think I get "invalid tag", but I will test it out right now |
I get the following exception: |
The tag in the PLC is named ValeurDINT |
Yeah, I see now why you got it without Please check and/or adjust following code:
It should print you all tags which got detected when connection was established. I don't think any more that discovery is a problem, its rather question of type mapping and/or eventual encoding. |
Yep, it works:
|
I did notice tho, that since 0.11.0, in order to write a value, we need to use: Prior to 0.11.0: If we dont use a PlcXXX type, it write Null |
Looks like when writing a tag, without specifying a PLCxxx datatype, in the class "PlcValueHandler.java": the if (tag.getPlcValueType()... always return null |
So if you do this it works:
|
Well works, let me explain:
Checking the code in PlcValueHandler.java:
Passing the "new PlcDINT(value)" is "fixed" by the "hacky shortcut, mentionned in the comment of the code. Hope it make senses. Let me know, if you need more infos / tests on this. |
Well I guess a real fix would be to automatically create a PLCValue of a type that certainly can fit the value and to add an additional check on "isUInt()" before accessing it. Problem is that while assembling the request with "addTagAddress" the tag is not yet resolved and we therefore don't know the type yet. |
I'll try to whip up a fix for this asap ... |
Hi Chris, |
Well ... if the world would let me have a bit control over my free time I could say something about that ... but for now I'll just say: It's done when it's done :-/ |
Just as 2023 was a pretty turbulent year ... is this still an issue? |
Hi Chris,
It is still an issue, I had to revert our project back to "0.9.1" waiting for another release to try it again.
Best regards
Patrick Boisclair
Email: ***@***.***
From: Christofer Dutz ***@***.***>
Sent: Tuesday, February 6, 2024 4:48 AM
To: apache/plc4x ***@***.***>
Cc: Patrick Boisclair ***@***.***>; Mention ***@***.***>
Subject: Re: [apache/plc4x] [Bug]: PLC4X - 0.11.0 - Issue writing value to a Beckhoff PLC using ads driver (Issue #1156)
Attention: Courriel provenant de l'externe. Veuillez valider la source et le contenu avant de cliquer sur un lien ou d'ouvrir un document.
Just as 2023 was a pretty turbulent year ... is this still an issue?
-
Reply to this email directly, view it on GitHub<#1156 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/A6WE737BCZEMOPR2T5SHKPLYSH36HAVCNFSM6AAAAAA6D5VZE2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRZGE2DCNJTGI>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
In my testsuite, that I'm running against my ADS device I'm reading each supported datatype, then write it back, then do 100 reads of all fields at the same time, but with random order ... so writing generally should work. Have you tried with the latest SNAPSHOT version? A lot of work has been put into that. |
I will test it again and return with the results.
Patrick Boisclair
Email: ***@***.***
From: Christofer Dutz ***@***.***>
Sent: Tuesday, February 6, 2024 8:29 AM
To: apache/plc4x ***@***.***>
Cc: Patrick Boisclair ***@***.***>; Mention ***@***.***>
Subject: Re: [apache/plc4x] [Bug]: PLC4X - 0.11.0 - Issue writing value to a Beckhoff PLC using ads driver (Issue #1156)
Attention: Courriel provenant de l'externe. Veuillez valider la source et le contenu avant de cliquer sur un lien ou d'ouvrir un document.
In my testsuite, that I'm running against my ADS device I'm reading each supported datatype, then write it back, then do 100 reads of all fields at the same time, but with random order ... so writing generally should work.
-
Reply to this email directly, view it on GitHub<#1156 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/A6WE732BSTKYMAHHCTQTBQTYSIVZJAVCNFSM6AAAAAA6D5VZE2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRZGYYDOOBVGM>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
And ideally, if it doesn't work ... please create a Wireshark recording of the interaction and attach it to this issue. |
Hi Chris, Here is the Java code:
` As you can see, I write 1 and read it back, and of course I expect 1 as the result, but I get : If you need anything else, pls let me know. Best regards ! |
Ok ... so I think I have something here ;-) ... so if I enter 16777216 into my calculator and switch to hex, I get 0x01000000 ... so this is an endianess problem ... I really wonder why this has never been seen before cause I'm running an excessive testsuite on the ADS ... I would totally freak out, if the value I made up is accidentally an endianess-palindrome. |
If you are write a value to the PLC and then reading that value back, I suspect you don't actually test endianess, just the fact that you can write the data and read the same data back. |
What confuses me is that it would seem that the endianess of a Twincat system seems to be dependent on the architecture it is running on? |
I'm just completely confused ... so in my tests I'm reading a value pre-defined in the PLC program and it's reading -242442424 = which is in hex: 0xF18C9F48 which I can see on the wire as 0x489F8CF1 ... I'm getting it in the exact same value and when I'm sending it back, I see the same values being sent to the PLC and the test then reads again and it's not changed. Here however 1 is encoded as 0x00000001 which is not correct, it should be 0x01000000 ... I'll debug through this. |
What value is it when you view it in Twincat though? |
Well the thing is ... I was missing a "LittleEndian" switch in the parsePlcValue method. Now with this, the "writing of 1" works and still my big-ass test seems to work. I've pushed a fix, so please pull and rebuild and try the SNAPSHOT. I'll continue trying to find out why it's not having any impact on my big test. |
With my tests I have the expected values hard-coded in my PLC program and I read everything separately in a single element read and compare it with the expected value. If that matches, I write the same value back. If this has worked for all types, I then read all elements in a multi-element read and compare the results with the expected ones again. I am a bit frustrated, that this hasn't been revealed before ... I mean ... writing a single 1 and then reading it back should be a super-basic test. |
I've got today an report of broken writes within AMSADS binding I am doing for openHAB. The target device is an ancient BX9000 with TwinCAT2. Binding is already on plc4x 0.11, with all discovery stuff we had prior release. I am cleaning my desk to check this report, so your findings are definitely interesting. I'll be able to check if I get a proper error answers, cause TC2 seem to have its own quirks. |
I can imagine that with TC2 a lot of things are a lot different ... so if you find out things are not compatible with the TC3 driver, that I am building, we should probably have multiple variants. |
Hi Chris, Thank you very much for your help, really appreciated ! |
Always happy to help ... and thanks for reporting and helping us find this issue. And if you want to help any further ... the best thing you could do, would be to publicly talk about PLC4X ;-) |
What happened?
Hi all,
I upgraded from version 0.9.1 to 0.11.0 and I cannot write to my Beckhoff PLC anymore.
When I write 1 to a DINT, 16777216 is stored.
Is it a BIG-ENDIAN vs LITTLE-ENDIAN issue ?
Is it possible to specify the “endianness” of the PLC ?
According to the TWINCat doc, it seems they use LITTLE-ENDIAN.
The PLC type is a "CX8190 / Standard
Attached is 3 REALLY simple Java application.
Write "1" to a DINT and read it back.
First with version 0.9.1 -> WORKS
Second with version 0.10.0 -> DOESN'T WORK (same issue) Third with version 0.11.0 -> DOESN'T WORK (same issue)
I did upgrade our "big" project from 0.9.1 to 0.11.0 yesterday, so I did not notice the issue with 0.10.0... my bad on this.
Hope it can help, bring some light as what changed from 0.9.1 to 0.10.0 and 0.11.0
I will work on getting a Wireshark log during the day and will do more testing.
plc4xTests.zip
Version
v0.11.0
Programming Languages
Protocols
The text was updated successfully, but these errors were encountered: