Hi,
If you get the internal error, maybe try WireShark. He will tell you the exact 
error so you can know exactly where the problem is coming from.
Regards

Etienne

> Le 3 juil. 2020 à 17:32, Cesar Garcia <[email protected]> a écrit :
> 
> Hi Iñigo,
> 
> If you have the opportunity to test the previous version, it is currently
> under evaluation by the team (0.6.1 PR).
> 
> You can check the versión here
> 
> https://github.com/glcj/plc4x/tree/s7alarm
> 
> In addition to the examples placed in the official repository, here you
> will find a number of examples with native S7 types.
> 
> https://github.com/glcj/PLC4XS7Examples
> 
> I will be attentive to any request since it is in my interest that this
> version is very well debugged.
> 
> I hope it is useful for you
> 
> 
>> El vie., 3 jul. 2020 a las 3:24, Iñigo Angulo (<[email protected]>) escribió:
>> 
>> Hi Chris,
>> 
>> Yes, I was thinking about why those dataypes were returning a List, thanks
>> for the explanation
>> 
>> I tried the SINT access. For reading values works perfectly. But when
>> writing, Im afraid I am getting the same INTERNAL_ERROR message as for INT
>> and DINT. I will make further tests, and let you know of the progress i
>> make.
>> 
>> Thanks!
>> 
>> Iñigo
>> 
>> -----------------------------------------
>> Iñigo Angulo
>> 
>> ZYLK.net :: consultoría.openSource
>> Ribera de Axpe, 11
>> Edificio A, modulo 201-203
>> 48950 Erandio (Bizkaia)
>> +34 944272119
>> -----------------------------------------
>> 
>> ----- Mensaje original -----
>> De: "Christofer Dutz" <[email protected]>
>> Para: "dev" <[email protected]>
>> Enviados: Jueves, 2 de Julio 2020 16:42:16
>> Asunto: Re: S7 write test doubt
>> 
>> Hi Iñigo,
>> 
>> happy you made quite some progress.
>> 
>> If you were asking yourself why for BYTE, WORD and DWORD the driver is
>> returning a List ... these are considered Bit-Strings. If you want to
>> read/write a single byte as an integer value, please use SINT instead.
>> 
>> So regarding one of your questions ... could you instead of doing:
>>        builderWriter.addItem("mivariable", "%DB20:DBB06:BYTE", 127);
>> Please try:
>>        builderWriter.addItem("mivariable", "%DB20:DBB06:SINT", 127);
>> 
>> And if you're getting an INTERNAL_ERROR that's probably our fault. As I
>> mentioned, we haven't done too much writing as no one ever uses that ;-)
>> 
>> Chris
>> 
>> 
>> 
>> 
>> Am 02.07.20, 15:56 schrieb "Iñigo Angulo" <[email protected]>:
>> 
>>    Hi,
>> 
>>    I have been doing further tests with the S7 driver. I would like to
>> ask you some doubts, which i am not sure if relate to the PLC4X driver or
>> the actual hardware (Siemens S7-300) i am using (pretty novice in PLC data
>> access im afraid...)
>> 
>> 
>>    The "Read value" tests I have done work correctly for different
>> datatypes, for example:
>> 
>>        builderReader.addItem("mivariable", "%DB20:DBX5.0:BOOL"); //Single
>> boolean value
>>        builderReader.addItem("mivariable", "%DB20:DBB06:BYTE"); //returns
>> a PlcList (Array of 8 boolean values)
>>        builderReader.addItem("mivariable", "%DB20:DBW06:WORD"); //returns
>> a PlcList (Array of 16 boolean values)
>>        builderReader.addItem("mivariable", "%DB20:DBD06:DWORD");
>> //returns a PlcList (Array of 32 boolean values)
>>        builderReader.addItem("mivariable", "%DB20:DBW06:INT"); //returns
>> a PlcInteger (16 bit integer (signed))
>>        builderReader.addItem("mivariable", "%DB20:DBD06:DINT"); //returns
>> a PlcInteger (32 bit integer (signed))
>>        builderReader.addItem("mivariable", "%DB20:DBD06:REAL"); //returns
>> a PlcFloat (32 bit IEEE 754 full precision floating point value (signed))
>> 
>> 
>>    In the "Write value" tests, write request for all datatype seem to
>> work fine:
>> 
>>        builderWriter.addItem("mivariable", "%DB20:DBX6.1:BOOL", true);
>> //write response code "OK"
>>        builderWriter.addItem("mivariable", "%DB20:DBB06:BYTE", 127);
>> //write response code "OK"
>>        builderWriter.addItem("mivariable", "%DB20:DBW06:WORD", 7);
>> //write response code "OK"
>>        builderWriter.addItem("mivariable", "%DB20:DBD06:DWORD", 1);
>> //write response code "OK"
>> 
>> 
>>    Except for the 'INT' and 'DINT' datatypes, which return an
>> INTERNAL_ERROR response code
>> 
>>        builderWriter.addItem("mivariable", "%DB20:DBW06:INT", 1); //write
>> response code "INTERNAL_ERROR"
>>        builderWriter.addItem("mivariable", "%DB20:DBD06:DINT", 1);
>> //write response code "INTERNAL_ERROR"
>> 
>> 
>>    Is the INTERNAL_ERROR code a hardware issue? (Maybe a device
>> configuration problem?)
>> 
>>    ---
>> 
>>    Also, the other thing I found in the test:
>> 
>>    When I write a value different than BOOL, and then read the same
>> memory address, I dont get the actual value but a 'false' filled array. TO
>> give some examples,
>> 
>>    with BOOL values:
>> 
>>        builderWriter.addItem("mivariable", "%DB20:DBX6.1:BOOL", true);
>>        builderReader.addItem("mivariable", "%DB20:DBX6.1:BOOL"); //return
>> true
>> 
>>        builderWriter.addItem("mivariable", "%DB20:DBX6.1:BOOL", false);
>>        builderReader.addItem("mivariable", "%DB20:DBX6.1:BOOL"); //return
>> false
>> 
>>    The written value is "correctly updated" and read fine.
>> 
>>    with other datatypes:
>> 
>>        builderWriter.addItem("mivariable", "%DB20:DBB06:BYTE", 1);
>>        builderReader.addItem("mivariable", "%DB20:DBB06:BYTE"); //returns
>> [false, false, false, false, false, false, false, false]
>> 
>>        builderWriter.addItem("mivariable", "%DB20:DBB06:BYTE", 127);
>>        builderReader.addItem("mivariable", "%DB20:DBB06:BYTE"); //returns
>> [false, false, false, false, false, false, false, false]
>> 
>> 
>>    I have tried to combine write single bits and read other datatypes,
>> which seem to work fine:
>> 
>>        builderWriter.addItem("mivariable", "%DB20:DBX6.1:BOOL", true);
>>            builderReader.addItem("mivariable", "%DB20:DBB06:BYTE");
>> //returns [false, false, false, false, false, false, true, false]
>>        builderReader.addItem("mivariable", "%DB20:DBW06:INT"); //return
>> 512
>> 
>>    And the other way around, write a byte and read single bits
>> 
>>        builderWriter.addItem("mivariable", "%DB20:DBB06:BYTE", 127);
>>        builderReader.addItem("mivariable-0", "%DB20:DBX6.0:BOOL");
>> //returns false
>>        builderReader.addItem("mivariable-1", "%DB20:DBX6.1:BOOL");
>> //returns false
>>        builderReader.addItem("mivariable-2", "%DB20:DBX6.2:BOOL");
>> //returns false
>>        builderReader.addItem("mivariable-3", "%DB20:DBX6.3:BOOL");
>> //returns false
>>        builderReader.addItem("mivariable-4", "%DB20:DBX6.4:BOOL");
>> //returns false
>>        builderReader.addItem("mivariable-5", "%DB20:DBX6.5:BOOL");
>> //returns false
>>        builderReader.addItem("mivariable-6", "%DB20:DBX6.6:BOOL");
>> //returns false
>>        builderReader.addItem("mivariable-7", "%DB20:DBX6.7:BOOL");
>> //returns false
>> 
>>    Which leads me to think that could be a write issue, right?
>> 
>>    Again I understand that these issues could be an actual hardware
>> configuration problem.. but any help or advice would be much appreciated
>> 
>>    Thank you in advance!
>> 
>>    iñigo
>> 
>>    P.S. I attached the test classes if anyone wants to take a look.
>> 
>>    -----------------------------------------
>>    Iñigo Angulo
>> 
>>    ZYLK.net :: consultoría.openSource
>>    Ribera de Axpe, 11
>>    Edificio A, modulo 201-203
>>    48950 Erandio (Bizkaia)
>>    +34 944272119
>>    -----------------------------------------
>> 
>>    ----- Mensaje original -----
>>    De: "Iñigo Angulo Otegui" <[email protected]>
>>    Para: "dev" <[email protected]>
>>    Enviados: Jueves, 2 de Julio 2020 12:45:49
>>    Asunto: Re: S7 write test doubt
>> 
>>    Hi Julian,
>> 
>>    Yes, we saw the adopters page and were thinking to contribute there.
>> We will prepare a short text describing the work we are doing with the
>> project and send it to you soon.
>> 
>>    Thanks
>>    iñigo
>> 
>>    -----------------------------------------
>>    Iñigo Angulo
>> 
>>    ZYLK.net :: consultoría.openSource
>>    Ribera de Axpe, 11
>>    Edificio A, modulo 201-203
>>    48950 Erandio (Bizkaia)
>>    +34 944272119
>>    -----------------------------------------
>> 
>>    ----- Mensaje original -----
>>    De: "Julian Feinauer" <[email protected]>
>>    Para: "dev" <[email protected]>
>>    Enviados: Jueves, 2 de Julio 2020 12:00:53
>>    Asunto: Re: S7 write test doubt
>> 
>>    And, as i shortly checked your company profile which looks pretty
>> cool... if you like it, or use it, dont forget to enter your company on the
>> adopters page : )
>> 
>>    https://plc4x.apache.org/users/adopters.html
>> 
>>    Julian
>> 
>>    Am 02.07.20, 10:31 schrieb "Iñigo Angulo" <[email protected]>:
>> 
>>        Hi Chris,
>> 
>>        Yes, using the 0.8.0-SNAPSHOT with the update you did the problem
>> is solved now.
>> 
>>        Thank you for the help and the fast solution!
>> 
>>        Iñigo
>> 
>>        -----------------------------------------
>>        Iñigo Angulo
>> 
>>        ZYLK.net :: consultoría.openSource
>>        Ribera de Axpe, 11
>>        Edificio A, modulo 201-203
>>        48950 Erandio (Bizkaia)
>>        +34 944272119
>>        -----------------------------------------
>> 
>>        ----- Mensaje original -----
>>        De: "Christofer Dutz" <[email protected]>
>>        Para: "dev" <[email protected]>
>>        Enviados: Miércoles, 1 de Julio 2020 13:18:34
>>        Asunto: Re: S7 write test doubt
>> 
>>        Hi all,
>> 
>>        build passed locall, pushed the changes, build on ci passed ....
>> so you should be ready to give things a new try.
>> 
>>        However keep in mind, if you built with 0.8.0-SNAPSHOT once today,
>> please be sure to do a "mvn -U install" build or you won't get the update
>> today.
>> 
>>        Would be cool if you could reply if this helped.
>> 
>>        Chris
>> 
>> 
>> 
>>        Am 01.07.20, 12:30 schrieb "Julian Feinauer" <
>> [email protected]>:
>> 
>>            Thanks both of you!
>>            As I just wrote in Slack we can only grow and improve if we
>> get feedback, Bug reports and usage scenarios.
>>            And of course thanks Chris for that fast reply and fix <3
>> 
>>            Julian
>> 
>>            Am 01.07.20, 12:24 schrieb "Iñigo Angulo" <[email protected]>:
>> 
>>                Hi Chris,
>> 
>>                No problem. I will keep track of the issue in Jira, and
>> use the 0.8.0-SNAPSHOT version.
>> 
>>                Thank you for your help
>> 
>>                iñigo
>> 
>>                -----------------------------------------
>>                Iñigo Angulo
>> 
>>                ZYLK.net :: consultoría.openSource
>>                Ribera de Axpe, 11
>>                Edificio A, modulo 201-203
>>                48950 Erandio (Bizkaia)
>>                +34 944272119
>>                -----------------------------------------
>> 
>>                ----- Mensaje original -----
>>                De: "Christofer Dutz" <[email protected]>
>>                Para: "dev" <[email protected]>
>>                Enviados: Miércoles, 1 de Julio 2020 12:06:28
>>                Asunto: Re: S7 write test doubt
>> 
>>                Hi Iñigo,
>> 
>>                I will have to ask you to wait for a little while as you
>> stumbled over a problem which goes a little deeper and is related to a
>> major refactoring we did just before Christmas. I am pretty puzzled that no
>> one ever noticed this, but I'll immediately start working on fixing this.
>> 
>>                I'm tracking progress here:
>>                https://issues.apache.org/jira/browse/PLC4X-206
>> 
>> 
>>                If that's done I would like to ask you to use the
>> 0.8.0-SNAPSHOT till we've released the next version of PLC4X.
>> 
>>                Chris
>> 
>> 
>>                Am 01.07.20, 12:00 schrieb "Iñigo Angulo" <
>> [email protected]>:
>> 
>>                    Hi Chris,
>> 
>>                    Thanks for the fast answer!
>> 
>>                    I will keep your advice about not adding the cast to
>> the values, and letting the driver do its work.
>> 
>>                    If you want me to try to reproduce any other test just
>> let me know.
>> 
>>                    Iñigo
>> 
>> 
>>                    -----------------------------------------
>>                    Iñigo Angulo
>> 
>>                    ZYLK.net :: consultoría.openSource
>>                    Ribera de Axpe, 11
>>                    Edificio A, modulo 201-203
>>                    48950 Erandio (Bizkaia)
>>                    +34 944272119
>>                    -----------------------------------------
>> 
>>                    ----- Mensaje original -----
>>                    De: "Christofer Dutz" <[email protected]>
>>                    Para: "dev" <[email protected]>
>>                    Enviados: Miércoles, 1 de Julio 2020 11:48:48
>>                    Asunto: Re: S7 write test doubt
>> 
>>                    And let me give you a little more context ... with the
>> INT type in S7 you happen to know that there an INT is a 16 Bit signed
>> integer.
>> 
>>                    We wanted to abstract from that. Cause another PLC
>> could define INT as 32 bit integer ... So you can generally just work with
>> any numeric type and pass that in. The driver will inspect the value ranges
>> for that particular protocol and give some sensible error messages (At
>> least it should ;-) ).
>> 
>>                    But ... I just noticed that indeed I am seeing the
>> same problems you are seeing and that my suggestion just causes a different
>> error ... I'll get working on fixing this right away.
>> 
>>                    I'm really a bit confused about this ... but it does
>> prove that most people just care about reading ;-)
>> 
>>                    Will keep you and the others posted on any progress.
>> 
>>                    Chris
>> 
>> 
>> 
>>                    Am 01.07.20, 11:33 schrieb "Christofer Dutz" <
>> [email protected]>:
>> 
>>                        Hi Iñigo,
>> 
>>                        welcome to the party ... I really hope we'll be
>> able to get you started asap ...
>> 
>>                        I just had a look at the code and PlcInteger does
>> have the constructor ...
>> 
>>                            public PlcInteger(Short value) {
>>                                super(value.intValue(), true);
>>                            }
>> 
>>                        So I'll try to reproduce the problem ... but for
>> now ... could you just remove the cast from your items?
>> 
>>                            builderWriter.addItem("mivariable-1",
>> "%DB20:DBX6.7:BOOL", true);
>>                            builderWriter.addItem("mivariable-4",
>> "%DB20:DBW06.0:INT", 2);
>>                            builderWriter.addItem("mivariable-2",
>> "%DB20:DBB06:BYTE", 0);
>> 
>>                        Cause PLC4X internally already ensures everything
>> fits into the bounds and internally PLC4X handles the "(short) 2" as an
>> "(int) 2" anyway ;-)
>> 
>> 
>>                        Chris
>> 
>> 
>> 
>> 
>>                        Am 01.07.20, 11:19 schrieb "Iñigo Angulo" <
>> [email protected]>:
>> 
>>                            Hi,
>> 
>>                            I started doing some basic tests with the S7
>> protocol using a Siemens S7-300, and the latest 0.7.0 release. The tests
>> consist of reading and writing several DB variables. I was able to read
>> different datatypes, for instance:
>> 
>>                            builder.addItem("mivariable-1",
>> "%DB20:DBX05.0:BOOL");
>>                            builder.addItem("mivariable-4",
>> "%DB20:DBW06:INT");
>> 
>>                            However, when I try to write the same memory
>> addresses I only manage to write BOOL values, for example
>> 
>>                            builderWriter.addItem("mivariable-1",
>> "%DB20:DBX6.7:BOOL", true); //WORKS OK
>>                            builderWriter.addItem("mivariable-4",
>> "%DB20:DBW06.0:INT", (short)2); // FAILS
>>                            builderWriter.addItem("mivariable-2",
>> "%DB20:DBB06:BYTE", (byte)0); // FAILS
>> 
>>                            I am unable to write any datatype different
>> than BOOL.
>> 
>>                            I am facing the following Error message:
>> 
>>                            Exception in thread "main"
>> org.apache.plc4x.java.api.exceptions.PlcRuntimeException: Error
>> initializing field class PlcInteger
>>                            at
>> org.apache.plc4x.java.s7.readwrite.field.S7PlcFieldHandler.internalEncodeInteger(S7PlcFieldHandler.java:394)
>> 
>>                            at
>> org.apache.plc4x.java.s7.readwrite.field.S7PlcFieldHandler.encodeShort(S7PlcFieldHandler.java:86)
>> 
>>                            at
>> org.apache.plc4x.java.spi.messages.DefaultPlcWriteRequest$Builder.lambda$build$0(DefaultPlcWriteRequest.java:270)
>> 
>>                            at
>> java.base/java.util.TreeMap.forEach(TreeMap.java:1002)
>>                            at
>> org.apache.plc4x.java.spi.messages.DefaultPlcWriteRequest$Builder.build(DefaultPlcWriteRequest.java:265)
>> 
>>                            at
>> net.zylk.plc4x.test.protocols.WriteS7.main(WriteS7.java:102)
>>                            Caused by: java.lang.NoSuchMethodException:
>> org.apache.plc4x.java.api.value.PlcInteger.<init>([Ljava.lang.Short;)
>>                            at
>> java.base/java.lang.Class.getConstructor0(Class.java:3349)
>>                            at
>> java.base/java.lang.Class.getDeclaredConstructor(Class.java:2553)
>>                            at
>> org.apache.plc4x.java.s7.readwrite.field.S7PlcFieldHandler.internalEncodeInteger(S7PlcFieldHandler.java:392)
>> 
>>                            ... 5 more
>> 
>>                            Maybe I am misunderstanding the sintax and how
>> the values should be written?
>> 
>>                            ---
>>                            To try to offer some more information about
>> this error:
>>                            Digging into that class (S7PlcFieldHandler) I
>> saw that there are some fields that are initialized based on the value of
>> the datatype
>> 
>>                            case INT:
>>                            minValue =
>> BigInteger.valueOf(Short.MIN_VALUE);
>>                            maxValue =
>> BigInteger.valueOf(Short.MAX_VALUE);
>>                            fieldType = PlcInteger.class;
>>                            valueType = Short[].class;
>>                            castedValues = new Short[values.length];
>>                            break;
>> 
>>                            Then, the line that throws the Exception seems
>> to be trying to inferr a PlcInteger class constructor based on the datatype
>> 
>>                            // Create the field item.
>>                            try {
>>                            return
>> fieldType.getDeclaredConstructor(valueType).newInstance(castedValues);
>>                            } catch (InstantiationException |
>> IllegalAccessException | InvocationTargetException | NoSuchMethodException
>> e) {
>>                            throw new PlcRuntimeException("Error
>> initializing field class " + fieldType.getSimpleName(), e);
>>                            }
>> 
>>                            However there appears to be a "mismatch"
>> between the valueType (Short[]) and the constructor (Short) in the
>> PlcInteger class, which leads me to think i am missing something on the
>> write value sintax?
>> 
>>                            Thank you in advance, any help will be
>> welcome.
>> 
>>                            Iñigo
>> 
>> 
>> 
>>                            -----
>>                            the test class code:
>> 
>>                            public class WriteS7 {
>>                            private static final Logger _log =
>> LoggerFactory.getLogger(WriteS7.class);
>> 
>>                            public static void main(String[] args) throws
>> PlcConnectionException {
>> 
>>                            String connectionString = "s7://
>> 10.105.143.1:102?remote-rack=0&remote-slot=0&controller-type=S7_300";
>> 
>>                            _log.info(String.format("Establishing
>> connection to %s", connectionString));;
>> 
>>                            try (PlcConnection plcConnection = new
>> PlcDriverManager().getConnection(connectionString)) {
>>                            _log.info("Conecting... " +
>> connectionString);
>>                            if (!plcConnection.getMetadata().canWrite()) {
>>                            _log.error(String.format("Connection %s
>> doesn't support writing.", connectionString));
>>                            return;
>>                            }
>> 
>>                            PlcWriteRequest.Builder builderWriter = null;
>>                            builderWriter =
>> plcConnection.writeRequestBuilder();
>> 
>>                            // builderWriter.addItem("mivariable-26",
>> "%DB20:DBX6.7:BOOL", false); //OK
>>                            builderWriter.addItem("mivariable-2",
>> "%DB20:DBB06:BYTE", (byte)0); //FAILS
>>                            // builderWriter.addItem("mivariable-4",
>> "%DB20:DBW06.0:INT", (short)2); //FAILS
>> 
>> 
>>                            PlcWriteRequest writeRequest =
>> builderWriter.build();
>>                            PlcWriteResponse writeResponse =
>> writeRequest.execute().get();
>> 
>> 
>> GeneralFunctions.printPlc4XWriteReponse(writeResponse); //print response
>>                            }
>> 
>>                            }
>>                            }
>> 
>> 
>>                            -----------------------------------------
>>                            Iñigo Angulo
>> 
>>                            ZYLK.net :: consultoría.openSource
>>                            Ribera de Axpe, 11
>>                            Edificio A, modulo 201-203
>>                            48950 Erandio (Bizkaia)
>>                            +34 944272119
>>                            -----------------------------------------
>> 
> 
> 
> -- 
> *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]>*

Reply via email to