[
https://issues.apache.org/jira/browse/PLC4X-154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17380504#comment-17380504
]
Mauro Riva edited comment on PLC4X-154 at 7/14/21, 11:06 AM:
-------------------------------------------------------------
Hi Christofer,
I didn't find a typeCode for LREAL. However, using Wireshark, I found that the
library [plcpleople/node7|https://github.com/plcpeople/nodeS7] is using BYTE
for the typeCode LREAL and asks for 8 bytes and that works.
Then, I tried this workaround:
Due that the typeCode 0x30 (s7.mspec file) makes the PLC to return
INVALID_ADDRESS (then it results in a INVALID_DATATYPE), I changed that line to:
{code:java}
['0x0F' LREAL ['0x08' , 'X' , '8'
, 'REAL' , 'null' , 'IEC61131_LREAL' ,
'false' , 'false' , 'true' , 'true'
, 'false' ]]
{code}
and then I added to the encodeS7Address function (inside S7ProtocolLogic.java)
the following section:
{code:java}
if (transportSize == transportSize.LREAL) {
transportSize = TransportSize.LREAL;
numElements = numElements * 2;
}
{code}
With those two changes, I can use PLC4x to read LREAL values on an
S7-1200/1500. I can submit a PULL request with these lines, it is not a clean
solution, but it could work for the types (L-XYZ) that you mentioned above.
was (Author: lemariva):
Hi Christofer,
I didn't find a typeCode for LREAL. However, using Wireshark, I found that the
library [plcpleople/node7|https://github.com/plcpeople/nodeS7] is using BYTE
for the typeCode LREAL and asks for 8 bytes and that works.
Then, I tried this workaround:
Due that the typeCode 0x30 (s7.mspec file) makes the PLC to return
INVALID_ADDRESS (then it results in a INVALID_DATATYPE), I changed that line to:
{code:java}
['0x0F' LREAL ['0x08' , 'X' , '8'
, 'REAL' , 'null' , 'IEC61131_LREAL' ,
'false' , 'false' , 'true' , 'true'
, 'false' ]]
{code}
and then I added to the encodeS7Address function (inside S7ProtocolLogic.java)
the following section:
{code:java}
if (transportSize == transportSize.LREAL) {
transportSize = TransportSize.LREAL;
numElements = numElements * 2;
}
{code}
With those two changes, I can use the library to read LREAL values on an
S7-1200/1500. I can submit a PULL request with these lines, it is not a clean
solution, but it could work for the types (L-XYZ) that you mentioned above.
> Reading LREAL from S7 causes PlcRuntimeException
> ------------------------------------------------
>
> Key: PLC4X-154
> URL: https://issues.apache.org/jira/browse/PLC4X-154
> Project: Apache PLC4X
> Issue Type: Bug
> Affects Versions: 0.4.0
> Environment: S7-1500 PLC
> Reporter: Sebastian Wiendl
> Priority: Major
>
> Reading an LREAL in my demo project
> https://github.com/sewiendl/plc4j-demo/tree/feature/read-lreal causes the
> following
> exception:{code}org.apache.plc4x.java.api.exceptions.PlcRuntimeException:
> Field 'LReal' could not be fetched, response was INVALID_DATATYPE
> at
> org.apache.plc4x.java.base.messages.DefaultPlcReadResponse.getFieldInternal(DefaultPlcReadResponse.java:577)
> at
> org.apache.plc4x.java.base.messages.DefaultPlcReadResponse.getObject(DefaultPlcReadResponse.java:81)
> at com.example.plc4jdemo.Main.main(Main.java:39){code}The field was
> added with {code} builder.addItem("LReal",
> "%DB101.DBX110:LREAL");{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)