Hi Christof,
writeRequestBuilder.addItem("someByte", "%DB100.DBB817:USINT", 0xFF);
yes, that way it works but it feels like an ugly "cast" from the software point
of view. 😄
Anyway, I can live with it for a while.
Thanks for you patience and the will to help.
Best regards,
Markus
________________________________
Von: Christofer Dutz <[email protected]>
Gesendet: Dienstag, 30. November 2021 14:55
An: [email protected] <[email protected]>
Betreff: RE: Supported Datatypes for S7-1200 with PLC4J
Hi,
unfortunately I think that way it won't work ... your're passing in 8 elements
and expecting it to be mapped to one element in the driver. However I currently
can't tell you which way would work.
Right now, I would suggest you try using a USINT instead of BYTE and then
simply pass in your numeric value.
writeRequestBuilder.addItem("someByte", "%DB100.DBB817:USINT", 0xFF);
Chris
-----Original Message-----
From: Markus Franke <[email protected]>
Sent: Dienstag, 30. November 2021 14:51
To: [email protected]
Subject: AW: Supported Datatypes for S7-1200 with PLC4J
Hi Christofer,
ok I got it.
So in your case, you would need to either initialize a List of PlcBool values
and write that, or you write the BYTE variable with an USINT or SINT value.
However, I already tried using a List of PlcBool as follows
writeRequestBuilder.addItem("someByte", "%DB100.DBB817:BYTE", true, true, true,
true, true, true, true, true);
but this gives me
---snip---
Exception in thread "main" java.lang.ClassCastException: class
org.apache.plc4x.java.spi.values.PlcBYTE cannot be cast to class
org.apache.plc4x.java.spi.values.PlcList
(org.apache.plc4x.java.spi.values.PlcBYTE and
org.apache.plc4x.java.spi.values.PlcList are in unnamed module of loader 'app')
at
org.apache.plc4x.java.s7.readwrite.io.DataItemIO.staticSerialize(DataItemIO.java:291)
at
org.apache.plc4x.java.s7.readwrite.io.DataItemIO.staticSerialize(DataItemIO.java:275)
at
org.apache.plc4x.java.s7.readwrite.protocol.S7ProtocolLogic.serializePlcValue(S7ProtocolLogic.java:862)
at
org.apache.plc4x.java.s7.readwrite.protocol.S7ProtocolLogic.write(S7ProtocolLogic.java:288)
at
org.apache.plc4x.java.spi.optimizer.BaseOptimizer.lambda$optimizedWrite$2(BaseOptimizer.java:114)
at
org.apache.plc4x.java.spi.optimizer.BaseOptimizer.send(BaseOptimizer.java:151)
at
org.apache.plc4x.java.spi.optimizer.BaseOptimizer.optimizedWrite(BaseOptimizer.java:114)
at
org.apache.plc4x.java.spi.connection.AbstractPlcConnection.write(AbstractPlcConnection.java:159)
at
org.apache.plc4x.java.spi.messages.DefaultPlcWriteRequest.execute(DefaultPlcWriteRequest.java:65)
---snap---
Another form I tried
List<PlcValue> list = new ArrayList<PlcValue>(Arrays.asList(new PlcBOOL(true),
new PlcBOOL(true), new PlcBOOL(true), new PlcBOOL(true), new PlcBOOL(true), new
PlcBOOL(true), new PlcBOOL(true), new PlcBOOL(true) ));
writeRequestBuilder.addItem("someByte", "%DB100.DBB817:BYTE", list);
This gives me
---snip---
Exception in thread "main" java.lang.ClassCastException: class
java.util.ArrayList cannot be cast to class java.lang.String
(java.util.ArrayList and java.lang.String are in module java.base of loader
'bootstrap') at org.apache.plc4x.java.spi.values.PlcBYTE.of(PlcBYTE.java:61)
at
org.apache.plc4x.java.spi.values.IEC61131ValueHandler.of(IEC61131ValueHandler.java:129)
at
org.apache.plc4x.java.spi.values.IEC61131ValueHandler.newPlcValue(IEC61131ValueHandler.java:49)
at
org.apache.plc4x.java.spi.messages.DefaultPlcWriteRequest$Builder.lambda$build$0(DefaultPlcWriteRequest.java:204)
at java.base/java.util.TreeMap.forEach(TreeMap.java:1002)
at
org.apache.plc4x.java.spi.messages.DefaultPlcWriteRequest$Builder.build(DefaultPlcWriteRequest.java:199)
---snap---
Am I doing something terribly wrong here or is it simply not implemented so
far? 😉
Best regards,
Markus
________________________________
Von: Christofer Dutz <[email protected]>
Gesendet: Dienstag, 30. November 2021 14:06
An: [email protected] <[email protected]>
Betreff: RE: Supported Datatypes for S7-1200 with PLC4J
Hi Markus,
BYTE, WORD and DWORD are intentionally implemented that way as in the IEC???
Spec that is how they are defined.
So if you read a USINT, SINT or BYTE should not matter on the protocol level,
In the PLCValue objects however it defines how the data is represented. So, a
BYTE being a bit-string should result in a PlcList with 8 PlcBool elements,
while one of the others should be a numeric value.
This would not be a bug, but a design decision we did to be compliant with the
specs.
So in your case, you would need to either initialize a List of PlcBool values
and write that, or you write the BYTE variable with an USINT or SINT value.
Chris
-----Original Message-----
From: Markus Franke <[email protected]>
Sent: Dienstag, 30. November 2021 13:41
To: [email protected]
Subject: AW: Supported Datatypes for S7-1200 with PLC4J
Hi Christofer,
thanks for your clarifications regarding the limitations of the current PLC4J
implementation on S7.
Regarding the bitfield datatypes such as BYTE, WORD and DWORD, so far I was
only able to read/write those bit-by-bit.
Suppose datablock 100, address 817 contains a BYTE variable. I was only able to
write to the individual bits by using the following address format
%DB100.DBX817.0:BOOL
...
%DB100.DBX817.7:BOOL
Trying to write the whole BYTE with a single operation like
%DB100.DBB817:BYTE
gives me a
---snip---
Exception in thread "main" java.lang.ClassCastException: class
org.apache.plc4x.java.spi.values.PlcBYTE cannot be cast to class
org.apache.plc4x.java.spi.values.PlcList
(org.apache.plc4x.java.spi.values.PlcBYTE and
org.apache.plc4x.java.spi.values.PlcList are in unnamed module of loader 'app')
at
org.apache.plc4x.java.s7.readwrite.io.DataItemIO.staticSerialize(DataItemIO.java:291)
at
org.apache.plc4x.java.s7.readwrite.io.DataItemIO.staticSerialize(DataItemIO.java:275)
at
org.apache.plc4x.java.s7.readwrite.protocol.S7ProtocolLogic.serializePlcValue(S7ProtocolLogic.java:862)
at
org.apache.plc4x.java.s7.readwrite.protocol.S7ProtocolLogic.write(S7ProtocolLogic.java:288)
at
org.apache.plc4x.java.spi.optimizer.BaseOptimizer.lambda$optimizedWrite$2(BaseOptimizer.java:114)
at
org.apache.plc4x.java.spi.optimizer.BaseOptimizer.send(BaseOptimizer.java:151)
at
org.apache.plc4x.java.spi.optimizer.BaseOptimizer.optimizedWrite(BaseOptimizer.java:114)
at
org.apache.plc4x.java.spi.connection.AbstractPlcConnection.write(AbstractPlcConnection.java:159)
at
org.apache.plc4x.java.spi.messages.DefaultPlcWriteRequest.execute(DefaultPlcWriteRequest.java:65)
at Siemens.main(Siemens.java:61)
---snap---
Similarily, for reading I receive the individual bits of the BYTE one-by-one.
However, I guess this is expected behaviour as we are dealing with a bit-field
datatype, right?
Best regards,
Markus
________________________________
Von: Christofer Dutz <[email protected]>
Gesendet: Dienstag, 30. November 2021 12:59
An: [email protected] <[email protected]>
Betreff: RE: Supported Datatypes for S7-1200 with PLC4J
Hi,
let me jump in here ;)
I know with strings there are currently issues. Especially with smaller S7
devices (which have smaller PDU Sizes).
The problem here is, that the default length of one string already exceeds the
PDU size of the S7 1200 devices I have.
So, you always must provide a max string length. As soon as you do that,
strings are unfortunately handled slightly differently.
To support normal strings with their full length, the Query optimizer in S7
would need to be extended with the ability to split up individual items into
multiple parts. This is something I haven't done yet.
To support normal strings on larger S7 devices (Where the PDU Size allows
fitting them into the request), we probably need more testing and for that I
would at least need access to such a device.
LREAL is unfortunately not supported on the S7-1200 devices that I have, and
therefore I could never really test that. Same with the Time datatypes.
So, all in all, I thank you for your list of things we need to improve. I
promise that we will work on this.
However, I can't give you an ETA on which I personally will be able to work on
this, as I'm currently working on other things. Perhaps someone in the
community can jump in. Or even you might be interested in helping. If you think
you are able to do that, I am more than willing to help mentor you.
Chris
-----Original Message-----
From: Markus Franke <[email protected]>
Sent: Dienstag, 30. November 2021 09:34
To: [email protected]
Subject: AW: Supported Datatypes for S7-1200 with PLC4J
Hi Cesar,
so far my experiences are as follows:
​datatype read write
=========================
BOOL ok ok
BYTE ok ok(only bitwise)
WORD ok ok(only bitwise)
DWORD ok ok(only bitwise)
SINT ok ok
USINT ok ok
INT ok ok
UINT ok ok
DINT ok ok
UDINT ok ok
REAL ok ok
LREAL nok nok
CHAR ok nok
WCHAR ok nok
STRING nok nok
WSTRING nok nok
TIME ok nok
DATE ok nok
TIME_OF_DAY ok nok
So it seems like writing is currently unsupported for quite a few datatypes.
Also reading (W)STRING and LREAL seems to be an issue currently.
Any comments on this?
Thanks in advance,
Markus
________________________________
Von: Cesar Garcia <[email protected]>
Gesendet: Montag, 29. November 2021 17:38
An: Apache PLC4X <[email protected]>
Betreff: Re: Supported Datatypes for S7-1200 with PLC4J
Hi Markus,
Can you put an example of the required formats?
Best regards,
El lun, 29 nov 2021 a las 11:27, Markus Franke (<[email protected]>)
escribió:
> Dear all,
>
> I am currently connecting to a S7-1200 by using PLC4J 0.9.0.
>
> As I have problems with reading/writing certain datatypes from a
> datablock, I was wondering whether there are currently any restriction
> what kind of datatypes are actually supported for reading/writing with
> this hardware setup?
>
> Thanks and best regards,
> Markus
>
--
*CEOS Automatización, C.A.*
*GALPON SERVICIO INDUSTRIALES Y NAVALES FA, C.A.,* *PISO 1, OFICINA 2, AV. RAUL
LEONI, SECTOR GUAMACHITO,*
*FRENTE A LA ASOCIACION DE GANADEROS,BARCELONA,EDO. ANZOATEGUI* *Ing. César
GarcÃa*
*Cel: +58 414-760.98.95*
*Hotline Técnica SIEMENS: 0800 1005080*
*Email: [email protected]
<[email protected]>*