Hi,

The original version only handled the binary types correctly (BYTE, WORD,
DWORD), for the rest it generates the problems that you point out.

I am working on the writing of CHAR and TIME types, etc. I indicate when
you finish these modifications.

On my fork of GitHub and mount the modification, I leave the link

https://github.com/glcj/plc4x/tree/s7alarm

Can you help me test these modifications? For me it is important that the
writing functions work 100%.

I don't know if this code could be part of the main branch, since it is
planned to be removed for the next release.

Chris, will it be possible to work with the modifications in the main
branch? Can it be a 0.6.X version, or something similar?

Best regards,


El mié., 26 feb. 2020 a las 4:12, Robinet, Etienne (<43...@etu.he2b.be>)
escribió:

> Hi all,
> Chris your solution worked for writing BOOL, that's the only thing I
> managed to do yesterday, but that's a start.
>
> Cesar, the BOOL also worked of course but I got some issues:
> -BYTE, WORD, DWORD: packet is sent but no data in it (Checked the log, the
> app is sending packet with correct size but data is {0},{0},... (but
> response code is OK and 0 is written to the PLC)
> -INT: Got error response code 7 (Data Size Mismatch), but the packet
> contains the correct data (from the log) at the right address. This is the
> query: builder.addItem("006","%MW10:INT", (short) 0x0210);
> -Other type: I get the message that the Transfert size code does not match
> the data type
> ( e.g.:  Transfer size code '68' doesn't match specified data type
> 'TIME_OF_DAY' invalid)
>
> Etienne
>
>
> Le mer. 26 févr. 2020 à 04:22, Cesar Garcia <cesar.gar...@ceos.com.ve> a
> écrit :
>
> > Hi Chris,
> >
> > I understand that the priority of the drivers in PLC4X is the reading
> > process, so writing to the PLC has not worked much.
> >
> > I have already made several corrections in the legacy driver for the S7,
> > which corrects the writing process, however there are still many types
> > (characters, strings and time) that are not written.
> >
> > I hope to upload the code tomorrow in such a way that it helps in the new
> > version of the driver for S7.
> >
> > Attach the test code.
> >
> > try (PlcConnection plcConnection = new
> > PlcDriverManager().getConnection("s7://192.168.1.23/0/2")){
> >             System.out.println("Write to MW200..2003, values 0x0001,
> > 0x0002, 0x0003...");
> >             PlcWriteRequest.Builder builder =
> > plcConnection.writeRequestBuilder();
> >
> >             /**
> >              * Test for S7300/S7400
> >              * Elementary Data Types
> >              * Bit Data Types
> >             **/
> >             builder.addItem("001","%MX200.0:BOOL", true);
> >             builder.addItem("002","%MB201:BYTE", (byte) 0x12);
> >             builder.addItem("003","%MW202:WORD", (short) 0x4321);
> >             builder.addItem("004","%MD204:DWORD", (int) 0x87654321);
> >
> >             /*
> >              * Character Types
> >              * TODO: Fail S7PlcFieldHandler, line 247
> >             */
> >             //builder.addItem("005","%MB208:CHAR", (byte) 0x32);
> >
> >             /*
> >              * Numeric Types
> >             */
> >             builder.addItem("006","%MW210:INT", (short) 0x0210);
> >             builder.addItem("007","%MD212:DINT", (int) 0x21200212);
> >             builder.addItem("008","%MD216:REAL", (float) 3.141516);
> >
> >             /*
> >              * Time Types
> >             */
> >             //builder.addItem("009","%MD220:TIME",
> > LocalDateTime.now().toLocalTime());
> >             //builder.addItem("010","%MW224:DATE",
> > LocalDateTime.now().toLocalDate());
> >             //builder.addItem("011","%MD226:TIME_OF_DAY",
> > LocalDateTime.now().toLocalTime());
> >
> >             /**
> >              * Test for S7300/S7400
> >              * Complex Data Types
> >             **/
> >             //builder.addItem("012","%MD230:DT", LocalDateTime.now());
> >             //builder.addItem("013","%MD234:DATE_AND_TIME",
> > LocalDateTime.now());
> >             //builder.addItem("014","%MD234:STRING", "VENEZUELA");
> >             //builder.addItem("015","%MB234:ARRAY",
> > (byte)[]({0x01,0x02,0x03}));
> >
> >             PlcWriteRequest request = builder.build();
> >
> >             PlcWriteResponse response = request.execute().get(2,
> > TimeUnit.SECONDS);
> >
> >             Collection<String> names = response.getFieldNames();
> >
> >             for (String name:names){
> >                 System.out.println("Index: " + name +
> >                         " Response code: " +
> > response.getResponseCode(name));
> >             }
> >
> >             plcConnection.close();
> >         } catch (Exception ex){
> >             LOGGER.info("Fail connection. Check IP address, rack, slot:
> " +
> > ex);
> >         }
> >
> > Best regards,
> >
> > El mar., 25 feb. 2020 a las 16:34, Christofer Dutz (<
> > christofer.d...@c-ware.de>) escribió:
> >
> > > Hi Etienne,
> > >
> > > yes indeed. The thing is none ever asked for writing even if we've
> > > implemented that.
> > > Try this code:
> > >
> > >             PlcWriteRequest.Builder writeBuilder =
> > > plcConnection.writeRequestBuilder();
> > >             writeBuilder.addItem("value-1", "%Q0.0:BOOL", true);
> > >             writeBuilder.addItem("value-2", "%Q0.1:BOOL", true);
> > >             writeBuilder.addItem("value-3", "%Q0.2:BOOL", true);
> > >             writeBuilder.addItem("value-4", "%Q0.3:BOOL", true);
> > >             final PlcWriteRequest writeRequest = writeBuilder.build();
> > >
> > >             final PlcWriteResponse plcWriteResponse =
> > > writeRequest.execute().get();
> > >             System.out.println(plcWriteResponse);
> > >
> > > At least that's the code I've used for testing the new write features
> of
> > > the new S7 driver.
> > >
> > > Chris
> > >
> > >
> > >
> > > Am 25.02.20, 14:25 schrieb "Etienne Robinet" <43...@etu.he2b.be>:
> > >
> > >     Hi all,
> > >     are there any example of writing to a S7 PLC? All the examples in
> the
> > > library are about READING from a PLC. Is the writing also implemented
> yet
> > > (seems like it).
> > >
> > >     I had some quick tries but nothing precise for now.
> > >
> > >     Regards,
> > >
> > >     Etienne
> > >
> > >
> > >
> >
> > --
> > *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: 0416-681.03.99*
> >
> > *Cel: 0414-760.98.95*
> >
> > *Hotline Técnica SIEMENS: 0800 1005080*
> >
> > *Email: support.aan.automat...@siemens.com
> > <support.aan.automat...@siemens.com>*
> >
>


-- 
*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: 0416-681.03.99*

*Cel: 0414-760.98.95*

*Hotline Técnica SIEMENS: 0800 1005080*

*Email: support.aan.automat...@siemens.com
<support.aan.automat...@siemens.com>*

Reply via email to