IsmoLeszczynski opened a new issue, #2328: URL: https://github.com/apache/plc4x/issues/2328
### What happened? I've been examining how the S7 driver handles STRING with a S7-1500, and it seems there are a few odd issues. I'm still using 0.13.0-SNAPSHOT due to a waiting PR, but I've checked that the logic is the same in newer versions. 1. The max STRING length can be defined as 254, both with the driver and the PLC. However, the S7 driver has defined a max length of 250 in [StaticHelper](https://github.com/apache/plc4x/blob/develop/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/utils/StaticHelper.java#L2693). This causes issues when defining a tag with a length of >250; the driver says in the packet that it's sending a higher amount of bytes than the actual pay load is due to truncation, to which the PLC responds with `0x07 Data type inconsistent`. The issue is resolved if I define the PLCTag with a max length of 250, but that again doesn't match the max length that can be defined on the PLC. Question: Why is the max length defined as 250 and not 254 in the StaticHelper? 254 should be the length of the string, leaving two bytes for the length information. 2. If I don't define the length and the driver uses `S7StringVarLengthTag`, the driver can only write as long STRING as what the current value in the PLC address is. This seems like an odd limitation, the driver reads the length of the current stored value and then trims the sent STRING to match - if any value written is shorter than the other one, the length is trimmed according to the shorter one when writing values. This logic also means that if the PLC tag is empty, the driver can't write anything to it. Somehow it feels weird to have a tag type that can reliably work only when the initial value is present on the PLC, and all values are exactly the same length. Question: What is the use case for such functionality? I'd expect that the driver would simply attempt to write the length of STRING that has been provided, with the max length handling for 254 chars. ### Version v0.13.0-SNAPSHOT ### Programming Languages - [ ] plc4c - [ ] plc4go - [x] plc4j - [ ] plc4net - [ ] plc4py ### Protocols - [ ] AB-Ethernet - [ ] ADS /AMS - [ ] BACnet/IP - [ ] C-Bus - [ ] CANopen - [ ] EtherNet/IP - [ ] Firmata - [ ] IEC-69870 - [ ] KNXnet/IP - [ ] Modbus - [ ] OPC-UA - [ ] Profinet - [x] S7 - [ ] S7-light -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
