- Got a first working version of the dataIo generation working in C
(This is the first version actually returning data read from an s7 in a PLC4C client written in C)
diff --git a/build-utils/language-base-freemarker/src/main/java/org/apache/plc4x/plugins/codegenerator/protocol/freemarker/BaseFreemarkerLanguageTemplateHelper.java b/build-utils/language-base-freemarker/src/main/java/org/apache/plc4x/plugins/codegenerator/protocol/freemarker/BaseFreemarkerLanguageTemplateHelper.java
index af8fe22..80bd00e 100644
--- a/build-utils/language-base-freemarker/src/main/java/org/apache/plc4x/plugins/codegenerator/protocol/freemarker/BaseFreemarkerLanguageTemplateHelper.java
+++ b/build-utils/language-base-freemarker/src/main/java/org/apache/plc4x/plugins/codegenerator/protocol/freemarker/BaseFreemarkerLanguageTemplateHelper.java
@@ -89,11 +89,11 @@
return thisType;
}
- protected String getProtocolName() {
+ public String getProtocolName() {
return protocolName;
}
- protected String getFlavorName() {
+ public String getFlavorName() {
return flavorName;
}
diff --git a/build-utils/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageOutput.java b/build-utils/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageOutput.java
index 6aa840f..31c43d5 100644
--- a/build-utils/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageOutput.java
+++ b/build-utils/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageOutput.java
@@ -63,7 +63,9 @@
@Override
protected List<Template> getDataIoTemplates(Configuration freemarkerConfiguration) throws IOException {
- return Collections.emptyList();
+ return Arrays.asList(
+ freemarkerConfiguration.getTemplate("templates/c/data-io-template-h.ftlh"),
+ freemarkerConfiguration.getTemplate("templates/c/data-io-template-c.ftlh"));
}
@Override
diff --git a/build-utils/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageTemplateHelper.java b/build-utils/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageTemplateHelper.java
index e7ef5dc..8bcbb38 100644
--- a/build-utils/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageTemplateHelper.java
+++ b/build-utils/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageTemplateHelper.java
@@ -18,6 +18,7 @@
*/
package org.apache.plc4x.language.c;
+import jdk.nashorn.internal.runtime.regexp.joni.constants.StringType;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.plc4x.plugins.codegenerator.protocol.freemarker.BaseFreemarkerLanguageTemplateHelper;
import org.apache.plc4x.plugins.codegenerator.protocol.freemarker.FreemarkerException;
@@ -41,7 +42,7 @@
}
public String getIncludesDirectory() {
- return String.join("", getProtocolName().split("-")) + ".includes";
+ return String.join("", getProtocolName().split("-")) + ".include";
}
/**
@@ -222,11 +223,11 @@
case STRING:
return "char*";
case TIME:
- throw new FreemarkerException("Unsupported time type.");
+ return "time_t";//throw new FreemarkerException("Unsupported time type.");
case DATE:
- throw new FreemarkerException("Unsupported date type.");
+ return "time_t";//throw new FreemarkerException("Unsupported date type.");
case DATETIME:
- throw new FreemarkerException("Unsupported date-time type.");
+ return "time_t";//throw new FreemarkerException("Unsupported date-time type.");
}
throw new FreemarkerException("Unsupported simple type. " + simpleTypeReference.getBaseType());
} else {
@@ -349,48 +350,48 @@
public String getReadBufferReadMethodCall(SimpleTypeReference simpleTypeReference, String valueString) {
switch (simpleTypeReference.getBaseType()) {
case BIT:
- return "plc4c_spi_read_bit(buf, (bool*) " + valueString + ")";
+ return "plc4c_spi_read_bit(io, (bool*) " + valueString + ")";
case UINT:
IntegerTypeReference unsignedIntegerTypeReference = (IntegerTypeReference) simpleTypeReference;
if (unsignedIntegerTypeReference.getSizeInBits() <= 8) {
- return "plc4c_spi_read_unsigned_byte(buf, " + unsignedIntegerTypeReference.getSizeInBits() + ", (uint8_t*) " + valueString + ")";
+ return "plc4c_spi_read_unsigned_byte(io, " + unsignedIntegerTypeReference.getSizeInBits() + ", (uint8_t*) " + valueString + ")";
}
if (unsignedIntegerTypeReference.getSizeInBits() <= 16) {
- return "plc4c_spi_read_unsigned_short(buf, " + unsignedIntegerTypeReference.getSizeInBits() + ", (uint16_t*) " + valueString + ")";
+ return "plc4c_spi_read_unsigned_short(io, " + unsignedIntegerTypeReference.getSizeInBits() + ", (uint16_t*) " + valueString + ")";
}
if (unsignedIntegerTypeReference.getSizeInBits() <= 32) {
- return "plc4c_spi_read_unsigned_int(buf, " + unsignedIntegerTypeReference.getSizeInBits() + ", (uint32_t*) " + valueString + ")";
+ return "plc4c_spi_read_unsigned_int(io, " + unsignedIntegerTypeReference.getSizeInBits() + ", (uint32_t*) " + valueString + ")";
}
if (unsignedIntegerTypeReference.getSizeInBits() <= 64) {
- return "plc4c_spi_read_unsigned_long(buf, " + unsignedIntegerTypeReference.getSizeInBits() + ", (uint64_t*) " + valueString + ")";
+ return "plc4c_spi_read_unsigned_long(io, " + unsignedIntegerTypeReference.getSizeInBits() + ", (uint64_t*) " + valueString + ")";
}
throw new FreemarkerException("Unsupported unsigned integer type with " + unsignedIntegerTypeReference.getSizeInBits() + " bits");
case INT:
IntegerTypeReference integerTypeReference = (IntegerTypeReference) simpleTypeReference;
if (integerTypeReference.getSizeInBits() <= 8) {
- return "plc4c_spi_read_signed_byte(buf, " + integerTypeReference.getSizeInBits() + ", (int8_t*) " + valueString + ")";
+ return "plc4c_spi_read_signed_byte(io, " + integerTypeReference.getSizeInBits() + ", (int8_t*) " + valueString + ")";
}
if (integerTypeReference.getSizeInBits() <= 16) {
- return "plc4c_spi_read_signed_short(buf, " + integerTypeReference.getSizeInBits() + ", (int16_t*) " + valueString + ")";
+ return "plc4c_spi_read_signed_short(io, " + integerTypeReference.getSizeInBits() + ", (int16_t*) " + valueString + ")";
}
if (integerTypeReference.getSizeInBits() <= 32) {
- return "plc4c_spi_read_signed_int(buf, " + integerTypeReference.getSizeInBits() + ", (int32_t*) " + valueString + ")";
+ return "plc4c_spi_read_signed_int(io, " + integerTypeReference.getSizeInBits() + ", (int32_t*) " + valueString + ")";
}
if (integerTypeReference.getSizeInBits() <= 64) {
- return "plc4c_spi_read_signed_long(buf, " + integerTypeReference.getSizeInBits() + ", (int64_t*) " + valueString + ")";
+ return "plc4c_spi_read_signed_long(io, " + integerTypeReference.getSizeInBits() + ", (int64_t*) " + valueString + ")";
}
throw new FreemarkerException("Unsupported signed integer type with " + integerTypeReference.getSizeInBits() + " bits");
case FLOAT:
FloatTypeReference floatTypeReference = (FloatTypeReference) simpleTypeReference;
if (floatTypeReference.getSizeInBits() <= 32) {
- return "plc4c_spi_read_float(buf, " + floatTypeReference.getSizeInBits() + ", (float*) " + valueString + ")";
+ return "plc4c_spi_read_float(io, " + floatTypeReference.getSizeInBits() + ", (float*) " + valueString + ")";
} else if(floatTypeReference.getSizeInBits() <= 64) {
- return "plc4c_spi_read_double(buf, " + floatTypeReference.getSizeInBits() + ", (double*) " + valueString + ")";
+ return "plc4c_spi_read_double(io, " + floatTypeReference.getSizeInBits() + ", (double*) " + valueString + ")";
}
throw new FreemarkerException("Unsupported float type with " + floatTypeReference.getSizeInBits() + " bits");
case STRING:
StringTypeReference stringTypeReference = (StringTypeReference) simpleTypeReference;
- return "plc4c_spi_read_string(buf, " + stringTypeReference.getSizeInBits() + ", \"" +
+ return "plc4c_spi_read_string(io, " + stringTypeReference.getSizeInBits() + ", \"" +
stringTypeReference.getEncoding() + "\"" + ", (char**) " + valueString + ")";
default:
throw new FreemarkerException("Unsupported type " + simpleTypeReference.getBaseType().name());
@@ -401,48 +402,48 @@
public String getWriteBufferWriteMethodCall(SimpleTypeReference simpleTypeReference, String fieldName) {
switch (simpleTypeReference.getBaseType()) {
case BIT:
- return "plc4c_spi_write_bit(buf, " + fieldName + ")";
+ return "plc4c_spi_write_bit(io, " + fieldName + ")";
case UINT:
IntegerTypeReference unsignedIntegerTypeReference = (IntegerTypeReference) simpleTypeReference;
if (unsignedIntegerTypeReference.getSizeInBits() <= 8) {
- return "plc4c_spi_write_unsigned_byte(buf, " + unsignedIntegerTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "plc4c_spi_write_unsigned_byte(io, " + unsignedIntegerTypeReference.getSizeInBits() + ", " + fieldName + ")";
}
if (unsignedIntegerTypeReference.getSizeInBits() <= 16) {
- return "plc4c_spi_write_unsigned_short(buf, " + unsignedIntegerTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "plc4c_spi_write_unsigned_short(io, " + unsignedIntegerTypeReference.getSizeInBits() + ", " + fieldName + ")";
}
if (unsignedIntegerTypeReference.getSizeInBits() <= 32) {
- return "plc4c_spi_write_unsigned_int(buf, " + unsignedIntegerTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "plc4c_spi_write_unsigned_int(io, " + unsignedIntegerTypeReference.getSizeInBits() + ", " + fieldName + ")";
}
if (unsignedIntegerTypeReference.getSizeInBits() <= 64) {
- return "plc4c_spi_write_unsigned_long(buf, " + unsignedIntegerTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "plc4c_spi_write_unsigned_long(io, " + unsignedIntegerTypeReference.getSizeInBits() + ", " + fieldName + ")";
}
throw new FreemarkerException("Unsupported unsigned integer type with " + unsignedIntegerTypeReference.getSizeInBits() + " bits");
case INT:
IntegerTypeReference integerTypeReference = (IntegerTypeReference) simpleTypeReference;
if (integerTypeReference.getSizeInBits() <= 8) {
- return "plc4c_spi_write_signed_byte(buf, " + integerTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "plc4c_spi_write_signed_byte(io, " + integerTypeReference.getSizeInBits() + ", " + fieldName + ")";
}
if (integerTypeReference.getSizeInBits() <= 16) {
return "plc4c_spi_write_signed_short(buf, " + integerTypeReference.getSizeInBits() + ", " + fieldName + ")";
}
if (integerTypeReference.getSizeInBits() <= 32) {
- return "plc4c_spi_write_signed_int(buf, " + integerTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "plc4c_spi_write_signed_int(io, " + integerTypeReference.getSizeInBits() + ", " + fieldName + ")";
}
if (integerTypeReference.getSizeInBits() <= 64) {
- return "plc4c_spi_write_signed_long(buf, " + integerTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "plc4c_spi_write_signed_long(io, " + integerTypeReference.getSizeInBits() + ", " + fieldName + ")";
}
throw new FreemarkerException("Unsupported signed integer type with " + integerTypeReference.getSizeInBits() + " bits");
case FLOAT:
FloatTypeReference floatTypeReference = (FloatTypeReference) simpleTypeReference;
if (floatTypeReference.getSizeInBits() <= 32) {
- return "plc4c_spi_write_float(buf, " + floatTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "plc4c_spi_write_float(io, " + floatTypeReference.getSizeInBits() + ", " + fieldName + ")";
} else if(floatTypeReference.getSizeInBits() <= 64) {
- return "plc4c_spi_write_double(buf, " + floatTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "plc4c_spi_write_double(io, " + floatTypeReference.getSizeInBits() + ", " + fieldName + ")";
}
throw new FreemarkerException("Unsupported float type with " + floatTypeReference.getSizeInBits() + " bits");
case STRING:
StringTypeReference stringTypeReference = (StringTypeReference) simpleTypeReference;
- return "plc4c_spi_write_string(buf, " + stringTypeReference.getSizeInBits() + ", \"" +
+ return "plc4c_spi_write_string(io, " + stringTypeReference.getSizeInBits() + ", \"" +
stringTypeReference.getEncoding() + "\", " + fieldName + ")";
default:
throw new FreemarkerException("Unsupported type " + simpleTypeReference.getBaseType().name());
@@ -479,20 +480,28 @@
}
}
+ public String getReservedValue(ReservedField reservedField) {
+ final String languageTypeName = getLanguageTypeNameForTypeReference(reservedField.getType());
+ if("BigInteger".equals(languageTypeName)) {
+ return "BigInteger.valueOf(" + reservedField.getReferenceValue() + ")";
+ } else {
+ return "(" + languageTypeName + ") " + reservedField.getReferenceValue();
+ }
+ }
- public String toParseExpression(ComplexTypeDefinition baseType, Field field, Term term, Argument[] parserArguments) {
+ public String toParseExpression(TypeDefinition baseType, Field field, Term term, Argument[] parserArguments) {
return toExpression(baseType, field, term, term1 -> toVariableParseExpression(baseType, field, term1, parserArguments));
}
- public String toSerializationExpression(ComplexTypeDefinition baseType, Field field, Term term, Argument[] parserArguments) {
+ public String toSerializationExpression(TypeDefinition baseType, Field field, Term term, Argument[] parserArguments) {
return toExpression(baseType, field, term, term1 -> toVariableSerializationExpression(baseType, field, term1, parserArguments));
}
- private String toExpression(ComplexTypeDefinition baseType, Field field, Term term, Function<Term, String> variableExpressionGenerator) {
+ private String toExpression(TypeDefinition baseType, Field field, Term term, Function<Term, String> variableExpressionGenerator) {
if (term == null) {
return "";
}
@@ -508,17 +517,17 @@
} else if (term instanceof VariableLiteral) {
VariableLiteral variableLiteral = (VariableLiteral) term;
if(variableLiteral.contains("lengthInBytes")) {
- ComplexTypeDefinition lengthType;
+ TypeDefinition lengthType;
String lengthExpression;
if(variableLiteral.getName().equals("lengthInBytes")) {
lengthType = (baseType.getParentType() == null) ? baseType : (ComplexTypeDefinition) baseType.getParentType();
lengthExpression = "_message";
} else {
- final Optional<TypeReference> typeReferenceForProperty = getTypeReferenceForProperty(baseType, variableLiteral.getName());
+ final Optional<TypeReference> typeReferenceForProperty = getTypeReferenceForProperty( (ComplexTypeDefinition) baseType, variableLiteral.getName());
if(!typeReferenceForProperty.isPresent()) {
throw new FreemarkerException("Unknown type for property " + variableLiteral.getName());
}
- lengthType = (ComplexTypeDefinition) getTypeDefinitionForTypeReference(typeReferenceForProperty.get());
+ lengthType = getTypeDefinitionForTypeReference(typeReferenceForProperty.get());
lengthExpression = variableExpressionGenerator.apply(term);
}
return getCTypeName(lengthType.getName()) + "_length_in_bytes(" + lengthExpression + ")";
@@ -570,7 +579,7 @@
}
}
- public String toVariableParseExpression(ComplexTypeDefinition baseType, Field field, Term term, Argument[] parserArguments) {
+ public String toVariableParseExpression(TypeDefinition baseType, Field field, Term term, Argument[] parserArguments) {
VariableLiteral vl = (VariableLiteral) term;
if("CAST".equals(vl.getName())) {
@@ -600,15 +609,37 @@
appendVariableExpressionRest(sb, baseType, vl.getChild());
} else {
sb.append("->");
- appendVariableExpressionRest(sb, (ComplexTypeDefinition) castType, vl.getChild());
+ appendVariableExpressionRest(sb, castType, vl.getChild());
}
}
return sb.toString();
}
+ // STATIC_CALL implies that driver specific static logic should be called
+ if ("STATIC_CALL".equals(vl.getName())) {
+ String functionName = ((StringLiteral) vl.getArgs().get(0)).getValue();
+ // We'll cut off the java package structure and just take the segment after the last "."
+ functionName = functionName.substring(functionName.lastIndexOf('.') + 1, functionName.length() -1);
+ // But to make the function name unique, well add the driver prefix to it.
+ StringBuilder sb = new StringBuilder(getCTypeName(functionName));
+ if (vl.getArgs().size() > 1) {
+ sb.append("(");
+ boolean firstArg = true;
+ for (int i = 1; i < vl.getArgs().size(); i++) {
+ Term arg = vl.getArgs().get(i);
+ if (!firstArg) {
+ sb.append(", ");
+ }
+ sb.append(toParseExpression(baseType, field, arg, parserArguments));
+ firstArg = false;
+ }
+ sb.append(")");
+ }
+ return sb.toString();
+ }
// Any name that is full upper-case is considered a function call.
// These are generally defined in the spi file evaluation_helper.c.
// All should have a name prefix "plc4c_spi_evaluation_helper_".
- if (vl.getName().equals(vl.getName().toUpperCase())) {
+ else if (vl.getName().equals(vl.getName().toUpperCase())) {
StringBuilder sb = new StringBuilder("plc4c_spi_evaluation_helper_" + vl.getName().toLowerCase());
if (vl.getArgs() != null) {
sb.append("(");
@@ -630,13 +661,39 @@
appendVariableExpressionRest(sb, baseType, vl.getChild());
}
return sb.toString();
+ } else if("io".equals(vl.getName())) {
+ StringBuilder sb = new StringBuilder("io");
+ if(vl.getChild() != null) {
+ sb.append(".");
+ appendVariableExpressionRest(sb, baseType, vl.getChild());
+ }
+ return sb.toString();
+ } else if("_type".equals(vl.getName())) {
+ if((vl.getChild() != null) && "encoding".equals(vl.getChild().getName()) && (field instanceof TypedField) && (((TypedField) field).getType() instanceof StringTypeReference)) {
+ TypedField typedField = (TypedField) field;
+ StringTypeReference stringTypeReference = (StringTypeReference) typedField.getType();
+ return "\"" + stringTypeReference.getEncoding().substring(1, stringTypeReference.getEncoding().length() - 1) + "\"";
+ } else {
+ throw new FreemarkerException("_type is currently pretty much hard-coded for some usecases, please check CLanguageTemplateHelper.toVariableParseExpression");
+ }
}
final String name = vl.getName();
+ // In case of DataIo types, we'll just check the arguments.
+ if(baseType instanceof DataIoTypeDefinition) {
+ if(baseType.getParserArguments() != null) {
+ for (Argument parserArgument : baseType.getParserArguments()) {
+ if(parserArgument.getName().equals(name)) {
+ return name;
+ }
+ }
+ }
+ }
+
// Try to find the type of the addressed property.
final Optional<TypeReference> propertyTypeOptional =
- getTypeReferenceForProperty(baseType, name);
+ getTypeReferenceForProperty((ComplexTypeDefinition) baseType, name);
// If we couldn't find the type, we didn't find the property.
if(!propertyTypeOptional.isPresent()) {
@@ -687,7 +744,7 @@
return sb.toString();
}
- private String toVariableSerializationExpression(ComplexTypeDefinition baseType, Field field, Term term, Argument[] serialzerArguments) {
+ private String toVariableSerializationExpression(TypeDefinition baseType, Field field, Term term, Argument[] serialzerArguments) {
VariableLiteral vl = (VariableLiteral) term;
if ("STATIC_CALL".equals(vl.getName())) {
StringBuilder sb = new StringBuilder();
@@ -870,7 +927,7 @@
// If this expression references enum constants we need to do things differently
final Optional<TypeReference> typeReferenceForProperty =
- getTypeReferenceForProperty(baseType, vl.getName());
+ getTypeReferenceForProperty((ComplexTypeDefinition) baseType, vl.getName());
if(typeReferenceForProperty.isPresent()) {
final TypeReference typeReference = typeReferenceForProperty.get();
if(typeReference instanceof ComplexTypeReference) {
@@ -890,7 +947,7 @@
}
}
- private void appendVariableExpressionRest(StringBuilder sb, ComplexTypeDefinition baseType, VariableLiteral vl) {
+ private void appendVariableExpressionRest(StringBuilder sb, TypeDefinition baseType, VariableLiteral vl) {
if(vl.isIndexed()) {
sb.insert(0, "plc4c_utils_list_get_value(");
sb.append(camelCaseToSnakeCase(vl.getName()));
diff --git a/build-utils/language-c/src/main/resources/templates/c/data-io-template-c.ftlh b/build-utils/language-c/src/main/resources/templates/c/data-io-template-c.ftlh
new file mode 100644
index 0000000..602bb14
--- /dev/null
+++ b/build-utils/language-c/src/main/resources/templates/c/data-io-template-c.ftlh
@@ -0,0 +1,245 @@
+<#--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<#-- Prevent freemarker from escaping stuff -->
+<#outputformat "undefined">
+<#-- Declare the name and type of variables passed in to the template -->
+<#-- @ftlvariable name="languageName" type="java.lang.String" -->
+<#-- @ftlvariable name="protocolName" type="java.lang.String" -->
+<#-- @ftlvariable name="outputFlavor" type="java.lang.String" -->
+<#-- @ftlvariable name="helper" type="org.apache.plc4x.language.c.CLanguageTemplateHelper" -->
+<#-- @ftlvariable name="type" type="org.apache.plc4x.plugins.codegenerator.types.definitions.ComplexTypeDefinition" -->
+<#-- Declare the name and type of variables declared locally inside the template -->
+<#-- @ftlvariable name="arrayField" type="org.apache.plc4x.plugins.codegenerator.types.fields.ArrayField" -->
+<#-- @ftlvariable name="checksumField" type="org.apache.plc4x.plugins.codegenerator.types.fields.ChecksumField" -->
+<#-- @ftlvariable name="constField" type="org.apache.plc4x.plugins.codegenerator.types.fields.ConstField" -->
+<#-- @ftlvariable name="discriminatorField" type="org.apache.plc4x.plugins.codegenerator.types.fields.DiscriminatorField" -->
+<#-- @ftlvariable name="enumField" type="org.apache.plc4x.plugins.codegenerator.types.fields.EnumField" -->
+<#-- @ftlvariable name="implicitField" type="org.apache.plc4x.plugins.codegenerator.types.fields.ImplicitField" -->
+<#-- @ftlvariable name="manualArrayField" type="org.apache.plc4x.plugins.codegenerator.types.fields.ManualArrayField" -->
+<#-- @ftlvariable name="manualField" type="org.apache.plc4x.plugins.codegenerator.types.fields.ManualField" -->
+<#-- @ftlvariable name="optionalField" type="org.apache.plc4x.plugins.codegenerator.types.fields.OptionalField" -->
+<#-- @ftlvariable name="paddingField" type="org.apache.plc4x.plugins.codegenerator.types.fields.PaddingField" -->
+<#-- @ftlvariable name="reservedField" type="org.apache.plc4x.plugins.codegenerator.types.fields.ReservedField" -->
+<#-- @ftlvariable name="simpleField" type="org.apache.plc4x.plugins.codegenerator.types.fields.SimpleField" -->
+<#-- @ftlvariable name="switchField" type="org.apache.plc4x.plugins.codegenerator.types.fields.SwitchField" -->
+<#-- @ftlvariable name="virtualField" type="org.apache.plc4x.plugins.codegenerator.types.fields.VirtualField" -->
+<#-- @ftlvariable name="simpleTypeReference" type="org.apache.plc4x.plugins.codegenerator.types.references.SimpleTypeReference" -->
+<#-- @ftlvariable name="complexTypeReference" type="org.apache.plc4x.plugins.codegenerator.types.references.ComplexTypeReference" -->
+<#if !helper.isDiscriminatedChildTypeDefinition(type)>${helper.getSourceDirectory()?replace(".", "/")}/${helper.camelCaseToSnakeCase(type.name)}.c
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+#include <stdio.h>
+#include <time.h>
+#include <plc4c/data.h>
+#include <plc4c/spi/evaluation_helper.h>
+#include <plc4c/driver_${helper.getProtocolName()}.h>
+#include "${helper.camelCaseToSnakeCase(type.name)}.h"
+
+// Parse function.
+plc4c_return_code ${helper.getCTypeName(type.name)}_parse(plc4c_spi_read_buffer* io, <#if type.parserArguments?has_content><#list type.parserArguments as parserArgument>${helper.getLanguageTypeNameForTypeReference(parserArgument.type)}<#if !helper.isSimpleTypeReference(parserArgument.type)>*</#if> ${parserArgument.name}<#sep>, </#list>, </#if>plc4c_data** data_item) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
+ uint16_t curPos;
+ plc4c_return_code _res = OK;
+
+ <#list type.switchField.cases as case>
+ <#if case.discriminatorValues?has_content>if(<#list case.discriminatorValues as discriminatorValue><#if case.discriminatorValues?size > 1>(</#if>${helper.toParseExpression(type, null, type.switchField.discriminatorExpressions[discriminatorValue?index], type.parserArguments)} == ${discriminatorValue}<#if case.discriminatorValues?size > 1>)</#if><#sep> && </#sep></#list>) </#if>{ /* ${case.name} */
+<#-- (*_message)->_type = ${helper.getCTypeName(type.name)}_type_${helper.getCTypeName(case.name)};-->
+ <#assign skipReturn=false>
+ <#list case.fields as field>
+ <#switch field.typeName>
+ <#case "array">
+
+ // Array field (${field.name})
+ <#-- Only update curPos if the length expression uses it
+ <#if field.loopExpression.contains("curPos")>
+ curPos = io.getPos() - startPos;
+ </#if>
+ <#- If this is a count array, we can directly initialize an array with the given size ->
+ <#if helper.isCountArrayField(field)>
+ // Count array
+ if(${helper.toParseExpression(type, field, field.loopExpression, type.parserArguments)} > Integer.MAX_VALUE) {
+ throw new ParseException("Array count of " + (${helper.toParseExpression(type, field, field.loopExpression, type.parserArguments)}) + " exceeds the maximum allowed count of " + Integer.MAX_VALUE);
+ }
+ ${helper.getLanguageTypeNameForField(field)}[] ${field.name};
+ {
+ int itemCount = (int) ${helper.toParseExpression(type, field, field.loopExpression, type.parserArguments)};
+ ${field.name} = new ${helper.getLanguageTypeNameForField(field)}[itemCount];
+ for(int curItem = 0; curItem < itemCount; curItem++) {
+ ${field.name}[curItem] = <#if helper.isSimpleTypeReference(field.type)>${helper.getReadBufferReadMethodCall(field.type)}<#else>${field.type.name}IO.staticParse(io<#if field.params?has_content>, <#list field.params as parserArgument>(${helper.getLanguageTypeNameForTypeReference(helper.getArgumentType(field.type, parserArgument?index), true)}) (${helper.toParseExpression(type, field, parserArgument, type.parserArguments)})<#sep>, </#sep></#list></#if>)</#if>;
+ }
+ }
+ <#- In all other cases do we have to work with a list, that is later converted to an array ->
+ <#else>
+ <#- For a length array, we read data till the read position of the buffer reaches a given position ->
+ <#if helper.isLengthArrayField(field)>
+ // Length array
+ int _${field.name}Length = ${helper.toParseExpression(type, field, field.loopExpression, type.parserArguments)};
+ List<${helper.getLanguageTypeNameForField(field)}> _${field.name}List = new LinkedList<>();
+ int ${field.name}EndPos = io.getPos() + _${field.name}Length;
+ while(io.getPos() < ${field.name}EndPos) {
+ _${field.name}List.add(<#if helper.isSimpleTypeReference(field.type)>${helper.getReadBufferReadMethodCall(field.type)}<#else>${field.type.name}IO.staticParse(io<#if field.params?has_content>, <#list field.params as parserArgument>(${helper.getLanguageTypeNameForTypeReference(helper.getArgumentType(field.type, parserArgument?index), true)}) (${helper.toParseExpression(type, field, parserArgument, type.parserArguments)})<#sep>, </#sep></#list></#if>)</#if>);
+ <#- After parsing, update the current position, but only if it's needed ->
+ <#if field.loopExpression.contains("curPos")>
+ curPos = io.getPos() - startPos;
+ </#if>
+ }
+ <#- A terminated array keeps on reading data as long as the termination expression evaluates to false ->
+ <#elseif helper.isTerminatedArrayField(field)>
+ // Terminated array
+ List<${helper.getLanguageTypeNameForField(field)}> _${field.name}List = new LinkedList<>();
+ while(!((boolean) (${helper.toParseExpression(type, field, field.loopExpression, type.parserArguments)}))) {
+ _${field.name}List.add(<#if helper.isSimpleTypeReference(field.type)>${helper.getReadBufferReadMethodCall(field.type)}<#else>${field.type.name}IO.staticParse(io<#if field.params?has_content>, <#list field.params as parserArgument>(${helper.getLanguageTypeNameForTypeReference(helper.getArgumentType(field.type, parserArgument?index), true)}) (${helper.toParseExpression(type, field, parserArgument, type.parserArguments)})<#sep>, </#sep></#list></#if>)</#if>);
+
+ <#- After parsing, update the current position, but only if it's needed ->
+ <#if field.loopExpression.contains("curPos")>
+ curPos = io.getPos() - startPos;
+ </#if>
+ }
+ </#if>
+ <#-
+ Convert the list into an array. However if the array is of a primitive
+ type we have to iterate over it's elements and explicitly cast them.
+ Otherwise a simple toArray call is fine.
+ ->
+ <#if helper.isSimpleTypeReference(field.type)>
+ ${helper.getLanguageTypeNameForField(field)}[] ${field.name} = new ${helper.getLanguageTypeNameForField(field)}[_${field.name}List.size()];
+ for(int i = 0; i < _${field.name}List.size(); i++) {
+ ${field.name}[i] = (${helper.getLanguageTypeNameForField(field)}) _${field.name}List.get(i);
+ }
+ <#else>
+ ${helper.getLanguageTypeNameForField(field)}[] ${field.name} = _${field.name}List.toArray(new ${helper.getLanguageTypeNameForField(field)}[0]);
+ </#if>
+ </#if>
+ -->
+ <#break>
+ <#case "const">
+
+ // Const Field (${field.name})
+ ${helper.getLanguageTypeNameForField(field)} ${field.name} = ${helper.getReadBufferReadMethodCall(field.type)};
+ if(${field.name} != ${type.name}.${field.name?upper_case}) {
+ throw new ParseException("Expected constant value " + ${type.name}.${field.name?upper_case} + " but got " + ${field.name});
+ }
+ <#break>
+ <#case "enum">
+
+ // Enum field (${field.name})
+ ${helper.getLanguageTypeNameForField(field)} ${field.name} = ${helper.getLanguageTypeNameForField(field)}.valueOf(${helper.getReadBufferReadMethodCall(helper.getEnumBaseTypeReference(field.type))});
+ <#break>
+ <#case "manual">
+
+ // Manual Field (${field.name})
+ ${helper.getLanguageTypeNameForField(field)} ${field.name} = (${helper.getLanguageTypeNameForField(field)}) (${helper.toParseExpression(type, field, field.parseExpression, type.parserArguments)});
+ <#--<#switch case.name>
+ <#case "Time">
+ return new PlcTime(${field.name});
+ <#break>
+ <#case "Date">
+ return new PlcDate(${field.name});
+ <#break>
+ <#case "DateTime">
+ return new PlcDateTime(${field.name});
+ <#break>
+ <#case "Struct">
+ return new PlcStruct(${field.name});
+ <#break>
+ <#case "String">
+ return new PlcString(${field.name});
+ <#break>
+ <#default>
+ return new Plc${case.name}(${field.name});
+ </#switch>
+ <#assign skipReturn=true>
+ -->
+ <#break>
+ <#case "reserved">
+
+ // Reserved Field (Compartmentalized so the "reserved" variable can't leak)
+ {
+ ${helper.getLanguageTypeNameForField(field)} _reserved = ${helper.getNullValueForTypeReference(field.type)};
+ _res = ${helper.getReadBufferReadMethodCall(field.type, "&_reserved")};
+ if(_res != OK) {
+ return _res;
+ }
+ if(_reserved != ${field.referenceValue}) {
+ printf("Expected constant value '%d' but got '%d' for reserved field.", ${field.referenceValue}, _reserved);
+ }
+ }
+ <#break>
+ <#case "simple">
+
+ // Simple Field (${field.name})
+ <#-- Inizialize a local variable with the simple type (Intentionally keeping the java-style names so they can be used in expressions) -->
+ <#if helper.isSimpleTypeReference(field.type)>
+ ${helper.getLanguageTypeNameForField(field)} ${field.name} = ${helper.getNullValueForTypeReference(field.type)};
+ _res = ${helper.getReadBufferReadMethodCall(field.type, "&" + field.name)};
+ <#else>
+ <#-- Inizialize a local variable with the complex type (Intentionally keeping the java-style names so they can be used in expressions) -->
+ ${helper.getLanguageTypeNameForField(field)}* ${field.name};
+ _res = ${helper.getCTypeName(field.type.name)}_parse(io<#if field.params?has_content>, <#list field.params as parserTerm>${helper.toParseExpression(baseType, field, parserTerm, baseType.parserArguments)}<#sep>, </#sep></#list></#if>, (void*) &${field.name});
+ </#if>
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_${helper.getLanguageTypeNameForField(field)}_data(${field.name});
+
+ <#break>
+ </#switch>
+ </#list>
+ }<#sep> else </#sep>
+ </#list>
+
+ return OK;
+}
+
+plc4c_return_code ${helper.getCTypeName(type.name)}_serialize(plc4c_spi_write_buffer* io, plc4c_data** data_item<#if helper.getSerializerArguments(type.parserArguments)?has_content>, <#list helper.getSerializerArguments(type.parserArguments) as parserArgument>${helper.getLanguageTypeNameForTypeReference(parserArgument.type)} ${parserArgument.name}<#sep>, </#sep></#list></#if>) {
+ plc4c_return_code _res = OK;
+
+ return OK;
+}
+
+uint16_t ${helper.getCTypeName(type.name)}_length_in_bytes(plc4c_data* data_item) {
+ return ${helper.getCTypeName(type.name)}_length_in_bits(data_item) / 8;
+}
+
+uint16_t ${helper.getCTypeName(type.name)}_length_in_bits(plc4c_data* data_item) {
+ uint16_t lengthInBits = 0;
+
+ return lengthInBits;
+}
+
+</#if>
+</#outputformat>
\ No newline at end of file
diff --git a/build-utils/language-c/src/main/resources/templates/c/data-io-template-h.ftlh b/build-utils/language-c/src/main/resources/templates/c/data-io-template-h.ftlh
new file mode 100644
index 0000000..145df09
--- /dev/null
+++ b/build-utils/language-c/src/main/resources/templates/c/data-io-template-h.ftlh
@@ -0,0 +1,88 @@
+<#--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<#-- Prevent freemarker from escaping stuff -->
+<#outputformat "undefined">
+<#-- Declare the name and type of variables passed in to the template -->
+<#-- @ftlvariable name="languageName" type="java.lang.String" -->
+<#-- @ftlvariable name="protocolName" type="java.lang.String" -->
+<#-- @ftlvariable name="outputFlavor" type="java.lang.String" -->
+<#-- @ftlvariable name="helper" type="org.apache.plc4x.language.c.CLanguageTemplateHelper" -->
+<#-- @ftlvariable name="type" type="org.apache.plc4x.plugins.codegenerator.types.definitions.ComplexTypeDefinition" -->
+<#-- Declare the name and type of variables declared locally inside the template -->
+<#-- @ftlvariable name="field" type="org.apache.plc4x.plugins.codegenerator.types.fields.NamedField" -->
+<#if !helper.isDiscriminatedChildTypeDefinition(type)>${helper.getIncludesDirectory()?replace(".", "/")}/${helper.camelCaseToSnakeCase(type.name)}.h
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+#ifndef ${helper.getCTypeName(type.name)?upper_case}_H_
+#define ${helper.getCTypeName(type.name)?upper_case}_H_
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <plc4c/spi/read_buffer.h>
+#include <plc4c/spi/write_buffer.h>
+#include <plc4c/utils/list.h>
+<#--
+ Add any import statements for partent-types, complex types used in properties or parser arguments.
+-->
+<#if helper.getComplexTypeReferences()?has_content>
+ <#list helper.getComplexTypeReferences() as typeReference>
+#include "${helper.camelCaseToSnakeCase(typeReference)}.h"
+ </#list>
+</#if>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+<#--
+ Define the parse-method for elements of this tpye
+-->
+plc4c_return_code ${helper.getCTypeName(type.name)}_parse(plc4c_spi_read_buffer* buf, <#if type.parserArguments?has_content><#list type.parserArguments as parserArgument>${helper.getLanguageTypeNameForTypeReference(parserArgument.type)}<#if !helper.isSimpleTypeReference(parserArgument.type)>*</#if> ${parserArgument.name}<#sep>, </#list>, </#if>plc4c_data** data_item);
+
+<#--
+ Define the serialize-method for elements of this tpye
+-->
+plc4c_return_code ${helper.getCTypeName(type.name)}_serialize(plc4c_spi_write_buffer* buf, plc4c_data** data_item<#if helper.getSerializerArguments(type.parserArguments)?has_content>, <#list helper.getSerializerArguments(type.parserArguments) as parserArgument>${helper.getLanguageTypeNameForTypeReference(parserArgument.type)} ${parserArgument.name}<#sep>, </#sep></#list></#if>);
+
+uint16_t ${helper.getCTypeName(type.name)}_length_in_bytes(plc4c_data* data_item);
+
+uint16_t ${helper.getCTypeName(type.name)}_length_in_bits(plc4c_data* data_item);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // ${helper.getCTypeName(type.name)?upper_case}_H_
+</#if>
+</#outputformat>
\ No newline at end of file
diff --git a/build-utils/language-c/src/main/resources/templates/c/pojo-template-c.ftlh b/build-utils/language-c/src/main/resources/templates/c/pojo-template-c.ftlh
index 3516e3d..fb38e1a 100644
--- a/build-utils/language-c/src/main/resources/templates/c/pojo-template-c.ftlh
+++ b/build-utils/language-c/src/main/resources/templates/c/pojo-template-c.ftlh
@@ -105,8 +105,8 @@
</#if>
// Parse function.
-plc4c_return_code ${helper.getCTypeName(type.name)}_parse(plc4c_spi_read_buffer* buf, <#if type.parserArguments?has_content><#list type.parserArguments as parserArgument>${helper.getLanguageTypeNameForTypeReference(parserArgument.type)}<#if !helper.isSimpleTypeReference(parserArgument.type)>*</#if> ${parserArgument.name}<#sep>, </#list>, </#if>${helper.getCTypeName(type.name)}** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code ${helper.getCTypeName(type.name)}_parse(plc4c_spi_read_buffer* io, <#if type.parserArguments?has_content><#list type.parserArguments as parserArgument>${helper.getLanguageTypeNameForTypeReference(parserArgument.type)}<#if !helper.isSimpleTypeReference(parserArgument.type)>*</#if> ${parserArgument.name}<#sep>, </#list>, </#if>${helper.getCTypeName(type.name)}** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -124,7 +124,7 @@
<#if indentContent> </#if> // Array field (${arrayField.name})
<#-- Only update curPos if the length expression uses it -->
<#if arrayField.loopExpression.contains("curPos")>
-<#if indentContent> </#if> curPos = plc4c_spi_read_get_pos(buf) - startPos;
+<#if indentContent> </#if> curPos = plc4c_spi_read_get_pos(io) - startPos;
</#if>
<#-- In all other cases do we have to work with a list, that is later converted to an array -->
<#if indentContent> </#if> plc4c_list* ${arrayField.name} = NULL;
@@ -149,7 +149,7 @@
<#else>
<#-- Inizialize a local variable with the complex type (Intentionally keeping the java-style names so they can be used in expressions) -->
<#if indentContent> </#if> ${helper.getCTypeName(arrayField.type.name)}* _value = NULL;
-<#if indentContent> </#if> _res = ${helper.getCTypeName(arrayField.type.name)}_parse(buf<#if field.params?has_content>, <#list field.params as parserTerm>${helper.toParseExpression(baseType, field, parserTerm, baseType.parserArguments)}<#sep>, </#sep></#list></#if>, (void*) &_value);
+<#if indentContent> </#if> _res = ${helper.getCTypeName(arrayField.type.name)}_parse(io<#if field.params?has_content>, <#list field.params as parserTerm>${helper.toParseExpression(baseType, field, parserTerm, baseType.parserArguments)}<#sep>, </#sep></#list></#if>, (void*) &_value);
<#if indentContent> </#if> if(_res != OK) {
<#if indentContent> </#if> return _res;
<#if indentContent> </#if> }
@@ -160,8 +160,8 @@
<#elseif helper.isLengthArrayField(field)>
<#if indentContent> </#if> // Length array
<#if indentContent> </#if> uint8_t _${arrayField.name}Length = ${helper.toParseExpression(baseType, arrayField, arrayField.loopExpression, baseType.parserArguments)};
-<#if indentContent> </#if> uint8_t ${arrayField.name}EndPos = plc4c_spi_read_get_pos(buf) + _${arrayField.name}Length;
-<#if indentContent> </#if> while(plc4c_spi_read_get_pos(buf) < ${arrayField.name}EndPos) {
+<#if indentContent> </#if> uint8_t ${arrayField.name}EndPos = plc4c_spi_read_get_pos(io) + _${arrayField.name}Length;
+<#if indentContent> </#if> while(plc4c_spi_read_get_pos(io) < ${arrayField.name}EndPos) {
<#-- Inizialize a local variable with the simple type (Intentionally keeping the java-style names so they can be used in expressions) -->
<#if helper.isSimpleTypeReference(arrayField.type)>
<#if indentContent> </#if> ${helper.getLanguageTypeNameForTypeReference(arrayField.type)} _value = ${helper.getNullValueForTypeReference(arrayField.type)};
@@ -173,7 +173,7 @@
<#else>
<#-- Inizialize a local variable with the complex type (Intentionally keeping the java-style names so they can be used in expressions) -->
<#if indentContent> </#if> ${helper.getCTypeName(arrayField.type.name)}* _value = NULL;
-<#if indentContent> </#if> _res = ${helper.getCTypeName(arrayField.type.name)}_parse(buf<#if field.params?has_content>, <#list field.params as parserTerm>${helper.toParseExpression(baseType, field, parserTerm, baseType.parserArguments)}<#sep>, </#sep></#list></#if>, (void*) &_value);
+<#if indentContent> </#if> _res = ${helper.getCTypeName(arrayField.type.name)}_parse(io<#if field.params?has_content>, <#list field.params as parserTerm>${helper.toParseExpression(baseType, field, parserTerm, baseType.parserArguments)}<#sep>, </#sep></#list></#if>, (void*) &_value);
<#if indentContent> </#if> if(_res != OK) {
<#if indentContent> </#if> return _res;
<#if indentContent> </#if> }
@@ -181,7 +181,7 @@
</#if>
<#-- After parsing, update the current position, but only if it's needed -->
<#if arrayField.loopExpression.contains("curPos")>
-<#if indentContent> </#if> curPos = plc4c_spi_read_get_pos(buf) - startPos;
+<#if indentContent> </#if> curPos = plc4c_spi_read_get_pos(io) - startPos;
</#if>
<#if indentContent> </#if> }
<#-- A terminated array keeps on reading data as long as the termination expression evaluates to false -->
@@ -199,7 +199,7 @@
<#else>
<#-- Inizialize a local variable with the complex type (Intentionally keeping the java-style names so they can be used in expressions) -->
<#if indentContent> </#if> ${helper.getCTypeName(arrayField.type.name)}* _value = NULL;
-<#if indentContent> </#if> _res = ${helper.getCTypeName(arrayField.type.name)}_parse(buf<#if field.params?has_content>, <#list field.params as parserTerm>${helper.toParseExpression(baseType, field, parserTerm, baseType.parserArguments)}<#sep>, </#sep></#list></#if>, (void*) &_value);
+<#if indentContent> </#if> _res = ${helper.getCTypeName(arrayField.type.name)}_parse(io<#if field.params?has_content>, <#list field.params as parserTerm>${helper.toParseExpression(baseType, field, parserTerm, baseType.parserArguments)}<#sep>, </#sep></#list></#if>, (void*) &_value);
<#if indentContent> </#if> if(_res != OK) {
<#if indentContent> </#if> return _res;
<#if indentContent> </#if> }
@@ -207,7 +207,7 @@
</#if>
<#-- After parsing, update the current position, but only if it's needed -->
<#if arrayField.loopExpression.contains("curPos")>
-<#if indentContent> </#if> curPos = plc4c_spi_read_get_pos(buf) - startPos;
+<#if indentContent> </#if> curPos = plc4c_spi_read_get_pos(io) - startPos;
</#if>
<#if indentContent> </#if> }
</#if>
@@ -221,7 +221,7 @@
<#if indentContent> </#if> // Checksum Field (${checksumField.name})
<#if indentContent> </#if> {
<#if indentContent> </#if> // Create an array of all the bytes read in this message element so far.
-<#if indentContent> </#if> byte[] checksumRawData = plc4c_spi_read_get_bytes(buf, startPos, plc4c_spi_read_get_pos(buf));
+<#if indentContent> </#if> byte[] checksumRawData = plc4c_spi_read_get_bytes(io, startPos, plc4c_spi_read_get_pos(io));
<#if indentContent> </#if> ${helper.getLanguageTypeNameForField(field)} _checksumRef = ${helper.getNullValueForTypeReference(checksumField.type)};
<#if indentContent> </#if> _res = ${helper.getReadBufferReadMethodCall(checksumField.type, "&_checksumRef")};
<#if indentContent> </#if> if(_res != OK) {
@@ -299,7 +299,7 @@
<#if indentContent> </#if> // Optional Field (${optionalField.name}) (Can be skipped, if a given expression evaluates to false)
<#if optionalField.conditionExpression.contains("curPos")>
-<#if indentContent> </#if> curPos = plc4c_spi_read_get_pos(buf) - startPos;
+<#if indentContent> </#if> curPos = plc4c_spi_read_get_pos(io) - startPos;
</#if>
<#if indentContent> </#if> ${helper.getLanguageTypeNameForField(field)}* ${optionalField.name} = NULL;
<#if indentContent> </#if> if(${helper.toParseExpression(baseType, field, optionalField.conditionExpression, baseType.parserArguments)}) {
@@ -311,7 +311,7 @@
<#if indentContent> </#if> *${optionalField.name} = ${helper.getNullValueForTypeReference(optionalField.type)};
<#if indentContent> </#if> _res = ${helper.getReadBufferReadMethodCall(optionalField.type, optionalField.name)};
<#else>
-<#if indentContent> </#if> _res = ${helper.getCTypeName(optionalField.type.name)}_parse(buf<#if optionalField.params?has_content>, <#list optionalField.params as parserTerm>${helper.toParseExpression(baseType, optionalField, parserTerm, baseType.parserArguments)}<#sep>, </#sep></#list></#if>, &${optionalField.name});
+<#if indentContent> </#if> _res = ${helper.getCTypeName(optionalField.type.name)}_parse(io<#if optionalField.params?has_content>, <#list optionalField.params as parserTerm>${helper.toParseExpression(baseType, optionalField, parserTerm, baseType.parserArguments)}<#sep>, </#sep></#list></#if>, &${optionalField.name});
</#if>
<#if indentContent> </#if> if(_res != OK) {
<#if indentContent> </#if> return _res;
@@ -327,7 +327,7 @@
<#if indentContent> </#if> // Padding Field (padding)
<#if indentContent> </#if> {
-<#if indentContent> </#if> int _timesPadding = (int) ((plc4c_spi_read_has_more(buf, ${helper.getNumBits(paddingField.type)})) && (${helper.toParseExpression(baseType, paddingField, paddingField.paddingCondition, baseType.parserArguments)}));
+<#if indentContent> </#if> int _timesPadding = (int) ((plc4c_spi_read_has_more(io, ${helper.getNumBits(paddingField.type)})) && (${helper.toParseExpression(baseType, paddingField, paddingField.paddingCondition, baseType.parserArguments)}));
<#if indentContent> </#if> while (_timesPadding-- > 0) {
<#if indentContent> </#if> // Just read the padding data and ignore it
<#if indentContent> </#if> ${helper.getLanguageTypeNameForField(field)} _paddingValue = ${helper.getNullValueForTypeReference(paddingField.type)};
@@ -365,7 +365,7 @@
<#else>
<#-- Inizialize a local variable with the complex type (Intentionally keeping the java-style names so they can be used in expressions) -->
<#if indentContent> </#if> ${helper.getLanguageTypeNameForField(field)}* ${simpleField.name};
-<#if indentContent> </#if> _res = ${helper.getCTypeName(simpleField.type.name)}_parse(buf<#if simpleField.params?has_content>, <#list simpleField.params as parserTerm>${helper.toParseExpression(baseType, simpleField, parserTerm, baseType.parserArguments)}<#sep>, </#sep></#list></#if>, (void*) &${simpleField.name});
+<#if indentContent> </#if> _res = ${helper.getCTypeName(simpleField.type.name)}_parse(io<#if simpleField.params?has_content>, <#list simpleField.params as parserTerm>${helper.toParseExpression(baseType, simpleField, parserTerm, baseType.parserArguments)}<#sep>, </#sep></#list></#if>, (void*) &${simpleField.name});
</#if>
<#if indentContent> </#if> if(_res != OK) {
<#if indentContent> </#if> return _res;
@@ -402,7 +402,7 @@
return OK;
}
-plc4c_return_code ${helper.getCTypeName(type.name)}_serialize(plc4c_spi_write_buffer* buf, ${helper.getCTypeName(type.name)}* _message<#if helper.getSerializerArguments(type.parserArguments)?has_content>, <#list helper.getSerializerArguments(type.parserArguments) as parserArgument>${helper.getLanguageTypeNameForTypeReference(parserArgument.type)} ${parserArgument.name}<#sep>, </#sep></#list></#if>) {
+plc4c_return_code ${helper.getCTypeName(type.name)}_serialize(plc4c_spi_write_buffer* io, ${helper.getCTypeName(type.name)}* _message<#if helper.getSerializerArguments(type.parserArguments)?has_content>, <#list helper.getSerializerArguments(type.parserArguments) as parserArgument>${helper.getLanguageTypeNameForTypeReference(parserArgument.type)} ${parserArgument.name}<#sep>, </#sep></#list></#if>) {
plc4c_return_code _res = OK;
<#macro fieldSerializer baseType field indentContent>
<#switch field.typeName>
@@ -419,7 +419,7 @@
<#if helper.isSimpleTypeReference(arrayField.type)>
<#if indentContent> </#if> ${helper.getWriteBufferWriteMethodCall(arrayField.type, "*_value")};
<#else>
-<#if indentContent> </#if> _res = ${helper.getCTypeName(arrayField.type.name)}_serialize(buf, (void*) _value<#if helper.getSerializerTerms(field.params)?has_content>, <#list helper.getSerializerTerms(field.params) as serializerTerm>${helper.toSerializationExpression(baseType, field, serializerTerm, baseType.parserArguments)}<#sep>, </#sep></#list></#if>);
+<#if indentContent> </#if> _res = ${helper.getCTypeName(arrayField.type.name)}_serialize(io, (void*) _value<#if helper.getSerializerTerms(field.params)?has_content>, <#list helper.getSerializerTerms(field.params) as serializerTerm>${helper.toSerializationExpression(baseType, field, serializerTerm, baseType.parserArguments)}<#sep>, </#sep></#list></#if>);
<#if indentContent> </#if> if(_res != OK) {
<#if indentContent> </#if> return _res;
<#if indentContent> </#if> }
@@ -434,7 +434,7 @@
<#if indentContent> </#if> // Checksum Field (${checksumField.name})
<#if indentContent> </#if> {
<#if indentContent> </#if> // Create an array of all the bytes read in this message element so far.
-<#if indentContent> </#if> byte[] checksumRawData = plc4c_spi_read_get_bytes(buf, startPos, plc4c_spi_read_get_pos(buf));
+<#if indentContent> </#if> byte[] checksumRawData = plc4c_spi_read_get_bytes(io, startPos, plc4c_spi_read_get_pos(io));
<#if indentContent> </#if> ${helper.getLanguageTypeNameForField(field)} _checksumRef = ${helper.getReadBufferReadMethodCall(checksumField.type)};
<#if indentContent> </#if> ${helper.getLanguageTypeNameForField(field)} _checksum = (${helper.getLanguageTypeNameForField(field)}) (${helper.toParseExpression(baseType, checksumField, checksumField.checksumExpression, baseType.parserArguments)});
<#if indentContent> </#if> if(_checksum != _checksumRef) {
@@ -488,7 +488,7 @@
<#if helper.isSimpleTypeReference(manualField.type)>
<#if indentContent> </#if> _res = ${helper.getWriteBufferWriteMethodCall(manualField.type, "(${helper.getLanguageTypeNameForTypeReference(arrayField.type)}*) plc4c_utils_list_get_value(_message->" + helper.getFieldName(baseType, arrayField))};
<#else>
-<#if indentContent> </#if> _res = ${helper.getCTypeName(manualField.type.name)}_serialize(buf, (void*) &_value);
+<#if indentContent> </#if> _res = ${helper.getCTypeName(manualField.type.name)}_serialize(io, (void*) &_value);
</#if>
<#if indentContent> </#if> if(_res != OK) {
<#if indentContent> </#if> return _res;
@@ -502,7 +502,7 @@
<#if helper.isSimpleTypeReference(optionalField.type)>
<#if indentContent> </#if> _res = ${helper.getWriteBufferWriteMethodCall(optionalField.type, "*_message->" + helper.getFieldName(baseType, optionalField))};
<#else>
-<#if indentContent> </#if> _res = ${helper.getCTypeName(optionalField.type.name)}_serialize(buf, _message-><@fieldName baseType=baseType field=optionalField/>);
+<#if indentContent> </#if> _res = ${helper.getCTypeName(optionalField.type.name)}_serialize(io, _message-><@fieldName baseType=baseType field=optionalField/>);
</#if>
<#if indentContent> </#if> if(_res != OK) {
<#if indentContent> </#if> return _res;
@@ -543,7 +543,7 @@
<#if helper.isSimpleTypeReference(simpleField.type)>
<#if indentContent> </#if> _res = ${helper.getWriteBufferWriteMethodCall(simpleField.type, "_message->" + helper.getFieldName(baseType, simpleField))};
<#else>
-<#if indentContent> </#if> _res = ${helper.getCTypeName(simpleField.type.name)}_serialize(buf, _message-><@fieldName baseType=baseType field=simpleField/>);
+<#if indentContent> </#if> _res = ${helper.getCTypeName(simpleField.type.name)}_serialize(io, _message-><@fieldName baseType=baseType field=simpleField/>);
</#if>
<#if indentContent> </#if> if(_res != OK) {
<#if indentContent> </#if> return _res;
diff --git a/build-utils/language-c/src/main/resources/templates/c/pojo-template-h.ftlh b/build-utils/language-c/src/main/resources/templates/c/pojo-template-h.ftlh
index 6333bea..fc501e1 100644
--- a/build-utils/language-c/src/main/resources/templates/c/pojo-template-h.ftlh
+++ b/build-utils/language-c/src/main/resources/templates/c/pojo-template-h.ftlh
@@ -150,12 +150,12 @@
<#--
Define the parse-method for elements of this tpye
-->
-plc4c_return_code ${helper.getCTypeName(type.name)}_parse(plc4c_spi_read_buffer* buf, <#if type.parserArguments?has_content><#list type.parserArguments as parserArgument>${helper.getLanguageTypeNameForTypeReference(parserArgument.type)}<#if !helper.isSimpleTypeReference(parserArgument.type)>*</#if> ${parserArgument.name}<#sep>, </#list>, </#if>${helper.getCTypeName(type.name)}** message);
+plc4c_return_code ${helper.getCTypeName(type.name)}_parse(plc4c_spi_read_buffer* io, <#if type.parserArguments?has_content><#list type.parserArguments as parserArgument>${helper.getLanguageTypeNameForTypeReference(parserArgument.type)}<#if !helper.isSimpleTypeReference(parserArgument.type)>*</#if> ${parserArgument.name}<#sep>, </#list>, </#if>${helper.getCTypeName(type.name)}** message);
<#--
Define the serialize-method for elements of this tpye
-->
-plc4c_return_code ${helper.getCTypeName(type.name)}_serialize(plc4c_spi_write_buffer* buf, ${helper.getCTypeName(type.name)}* message<#if helper.getSerializerArguments(type.parserArguments)?has_content>, <#list helper.getSerializerArguments(type.parserArguments) as parserArgument>${helper.getLanguageTypeNameForTypeReference(parserArgument.type)} ${parserArgument.name}<#sep>, </#sep></#list></#if>);
+plc4c_return_code ${helper.getCTypeName(type.name)}_serialize(plc4c_spi_write_buffer* io, ${helper.getCTypeName(type.name)}* message<#if helper.getSerializerArguments(type.parserArguments)?has_content>, <#list helper.getSerializerArguments(type.parserArguments) as parserArgument>${helper.getLanguageTypeNameForTypeReference(parserArgument.type)} ${parserArgument.name}<#sep>, </#sep></#list></#if>);
uint16_t ${helper.getCTypeName(type.name)}_length_in_bytes(${helper.getCTypeName(type.name)}* message);
diff --git a/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultDataIoTypeDefinition.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultDataIoTypeDefinition.java
index bbc1480..0e6e2fd 100644
--- a/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultDataIoTypeDefinition.java
+++ b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultDataIoTypeDefinition.java
@@ -18,11 +18,9 @@
*/
package org.apache.plc4x.plugins.codegenerator.language.mspec.model.definitions;
-import org.apache.plc4x.plugins.codegenerator.language.mspec.model.references.DefaultComplexTypeReference;
import org.apache.plc4x.plugins.codegenerator.types.definitions.Argument;
import org.apache.plc4x.plugins.codegenerator.types.definitions.DataIoTypeDefinition;
import org.apache.plc4x.plugins.codegenerator.types.fields.SwitchField;
-import org.apache.plc4x.plugins.codegenerator.types.references.TypeReference;
public class DefaultDataIoTypeDefinition extends DefaultTypeDefinition implements DataIoTypeDefinition {
diff --git a/protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec b/protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec
index a0dc2df..0abe234 100644
--- a/protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec
+++ b/protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec
@@ -249,7 +249,7 @@
[type 'ModbusPDUReadFileRecordResponseItem'
[implicit uint 8 'dataLength' 'COUNT(data) + 1']
[simple uint 8 'referenceType']
- [array int 8 'data' length 'dataLength - 1']
+ [array int 8 'data' length 'dataLength - 1']
]
[type 'ModbusPDUWriteFileRecordRequestItem'
diff --git a/sandbox/plc4c/api/include/plc4c/data.h b/sandbox/plc4c/api/include/plc4c/data.h
index d35e77f..5facf13 100644
--- a/sandbox/plc4c/api/include/plc4c/data.h
+++ b/sandbox/plc4c/api/include/plc4c/data.h
@@ -40,49 +40,63 @@
* @param b the bool value
* @return pointer to plc4c_data
*/
-plc4c_data *plc4c_data_create_boolean_data(bool b);
+plc4c_data *plc4c_data_create_bool_data(bool b);
/**
* Creates a plc4c_data with char
* @param c the char value
* @return pointer to plc4c_data
*/
-plc4c_data *plc4c_data_create_char_data(char c);
+plc4c_data *plc4c_data_create_int8_t_data(int8_t c);
/**
* Creates a plc4c_data with unsigned char
* @param uc the unsigned char value
* @return pointer to plc4c_data
*/
-plc4c_data *plc4c_data_create_uchar_data(unsigned char uc);
+plc4c_data *plc4c_data_create_uint8_t_data(uint8_t uc);
/**
* Creates a plc4c_data with short
* @param s the short value
* @return pointer to plc4c_data
*/
-plc4c_data *plc4c_data_create_short_data(short s);
+plc4c_data *plc4c_data_create_int16_t_data(int16_t s);
/**
* Creates a plc4c_data with unsigned short
* @param us the unsigned short value
* @return pointer to plc4c_data
*/
-plc4c_data *plc4c_data_create_ushort_data(unsigned short us);
+plc4c_data *plc4c_data_create_uint16_t_data(uint16_t us);
/**
* Creates a plc4c_data with int
* @param i the int value
* @return pointer to plc4c_data
*/
-plc4c_data *plc4c_data_create_int_data(int i);
+plc4c_data *plc4c_data_create_int32_t_data(int32_t i);
/**
* Creates a plc4c_data with unsigned int
* @param ui the unsigned int value
* @return pointer to plc4c_data
*/
-plc4c_data *plc4c_data_create_uint_data(unsigned int ui);
+plc4c_data *plc4c_data_create_uint32_t_data(uint32_t ui);
+
+/**
+ * Creates a plc4c_data with int
+ * @param i the int value
+ * @return pointer to plc4c_data
+ */
+plc4c_data *plc4c_data_create_int64_t_data(int64_t i);
+
+/**
+ * Creates a plc4c_data with unsigned int
+ * @param ui the unsigned int value
+ * @return pointer to plc4c_data
+ */
+plc4c_data *plc4c_data_create_uint64_t_data(uint64_t ui);
/**
* Creates a plc4c_data with void*
@@ -99,6 +113,13 @@
plc4c_data *plc4c_data_create_float_data(float f);
/**
+ * Creates a plc4c_data with float
+ * @param f the float value
+ * @return pointer to plc4c_data
+ */
+plc4c_data *plc4c_data_create_double_data(double d);
+
+/**
* Creates a plc4c_data with char*
* @param size the size of the string
* @param s the char* value
diff --git a/sandbox/plc4c/api/include/plc4c/types.h b/sandbox/plc4c/api/include/plc4c/types.h
index cc2157f..fc10004 100644
--- a/sandbox/plc4c/api/include/plc4c/types.h
+++ b/sandbox/plc4c/api/include/plc4c/types.h
@@ -80,7 +80,10 @@
PLC4C_USHORT,
PLC4C_INT,
PLC4C_UINT,
+ PLC4C_LINT,
+ PLC4C_ULINT,
PLC4C_FLOAT,
+ PLC4C_DOUBLE,
PLC4C_STRING_POINTER,
PLC4C_CONSTANT_STRING,
PLC4C_VOID_POINTER
diff --git a/sandbox/plc4c/drivers/modbus/CMakeLists.txt b/sandbox/plc4c/drivers/modbus/CMakeLists.txt
index 464e8e6..08e206b 100644
--- a/sandbox/plc4c/drivers/modbus/CMakeLists.txt
+++ b/sandbox/plc4c/drivers/modbus/CMakeLists.txt
@@ -18,10 +18,10 @@
]]
include_directories("include" "../../api/include" "../../spi/include"
- "${PLC4C_ROOT_DIR}/generated-sources/modbus/includes")
+ "../../generated-sources/modbus/include")
# Add the generated sources
-file(GLOB generatedSources "${PLC4C_ROOT_DIR}/generated-sources/modbus/src/*.c")
+file(GLOB generatedSources "../../generated-sources/modbus/src/*.c")
add_library(plc4c-driver-modbus
src/driver_modbus.c
diff --git a/sandbox/plc4c/drivers/s7/CMakeLists.txt b/sandbox/plc4c/drivers/s7/CMakeLists.txt
index 28ca689..a2271b4 100644
--- a/sandbox/plc4c/drivers/s7/CMakeLists.txt
+++ b/sandbox/plc4c/drivers/s7/CMakeLists.txt
@@ -18,10 +18,10 @@
]]
include_directories("include" "../../api/include" "../../spi/include"
- "${PLC4C_ROOT_DIR}/generated-sources/s7/includes")
+ "../../generated-sources/s7/include")
# Add the generated sources
-file(GLOB generatedSources "${PLC4C_ROOT_DIR}/generated-sources/s7/src/*.c")
+file(GLOB generatedSources "../../generated-sources/s7/src/*.c")
add_library(plc4c-driver-s7
src/driver_s7.c
diff --git a/sandbox/plc4c/drivers/s7/include/plc4c/driver_s7.h b/sandbox/plc4c/drivers/s7/include/plc4c/driver_s7.h
index a0cb706..715a867 100644
--- a/sandbox/plc4c/drivers/s7/include/plc4c/driver_s7.h
+++ b/sandbox/plc4c/drivers/s7/include/plc4c/driver_s7.h
@@ -24,8 +24,10 @@
#include <plc4c/types.h>
#include <stdint.h>
+#include <time.h>
-#include "../../../../generated-sources/s7/includes/cotp_tpdu_size.h"
+#include "../../../../generated-sources/s7/include/cotp_tpdu_size.h"
+#include "../../../../spi/include/plc4c/spi/read_buffer.h"
enum plc4c_driver_s7_controller_type {
PLC4C_DRIVER_S7_CONTROLLER_TYPE_ANY = 0,
@@ -61,9 +63,28 @@
};
typedef struct plc4c_driver_s7_config plc4c_driver_s7_config;
-
plc4c_driver *plc4c_driver_s7_create();
+/*
+ *
+ * Static functions
+ *
+ */
+
+char* plc4c_s7_read_write_parse_s7_string(plc4c_spi_read_buffer* io, int32_t stringLength, char* encoding);
+
+time_t plc4c_s7_read_write_parse_tia_time(plc4c_spi_read_buffer* io);
+
+time_t plc4c_s7_read_write_parse_s5_time(plc4c_spi_read_buffer* io);
+
+time_t plc4c_s7_read_write_parse_tia_l_time(plc4c_spi_read_buffer* io);
+
+time_t plc4c_s7_read_write_parse_tia_date(plc4c_spi_read_buffer* io);
+
+time_t plc4c_s7_read_write_parse_tia_time_of_day(plc4c_spi_read_buffer* io);
+
+time_t plc4c_s7_read_write_parse_tia_date_time(plc4c_spi_read_buffer* io);
+
#ifdef __cplusplus
}
#endif
diff --git a/sandbox/plc4c/drivers/s7/src/driver_s7.c b/sandbox/plc4c/drivers/s7/src/driver_s7.c
index 8b83376..9f897db 100644
--- a/sandbox/plc4c/drivers/s7/src/driver_s7.c
+++ b/sandbox/plc4c/drivers/s7/src/driver_s7.c
@@ -63,3 +63,45 @@
driver->free_unsubscription_response_function = NULL;
return driver;
}
+
+/*
+ *
+ * Static functions
+ *
+ */
+
+char* plc4c_s7_read_write_parse_s7_string(plc4c_spi_read_buffer* io, int32_t stringLength, char* encoding) {
+ // TODO: Implement ...
+ return "";
+}
+
+time_t plc4c_s7_read_write_parse_tia_time(plc4c_spi_read_buffer* io) {
+ // TODO: Implement ...
+ return 0;
+}
+
+time_t plc4c_s7_read_write_parse_s5_time(plc4c_spi_read_buffer* io) {
+ // TODO: Implement ...
+ return 0;
+}
+
+time_t plc4c_s7_read_write_parse_tia_l_time(plc4c_spi_read_buffer* io) {
+ // TODO: Implement ...
+ return 0;
+}
+
+time_t plc4c_s7_read_write_parse_tia_date(plc4c_spi_read_buffer* io) {
+ // TODO: Implement ...
+ return 0;
+}
+
+time_t plc4c_s7_read_write_parse_tia_time_of_day(plc4c_spi_read_buffer* io) {
+ // TODO: Implement ...
+ return 0;
+}
+
+time_t plc4c_s7_read_write_parse_tia_date_time(plc4c_spi_read_buffer* io) {
+ // TODO: Implement ...
+ return 0;
+}
+
diff --git a/sandbox/plc4c/drivers/s7/src/driver_s7_sm_read.c b/sandbox/plc4c/drivers/s7/src/driver_s7_sm_read.c
index 94c7f31..64e9499 100644
--- a/sandbox/plc4c/drivers/s7/src/driver_s7_sm_read.c
+++ b/sandbox/plc4c/drivers/s7/src/driver_s7_sm_read.c
@@ -18,7 +18,6 @@
*/
#include <ctype.h>
-#include <plc4c/plc4c.h>
#include <plc4c/spi/types_private.h>
#include <stdlib.h>
#include <string.h>
@@ -27,12 +26,30 @@
#include "plc4c/driver_s7_packets.h"
#include "cotp_protocol_class.h"
#include "tpkt_packet.h"
+#include "data_item.h"
enum plc4c_driver_s7_read_states {
PLC4C_DRIVER_S7_READ_INIT,
PLC4C_DRIVER_S7_READ_FINISHED
};
+plc4c_return_code plc4c_driver_s7_read_list_to_byte_array(plc4c_list* list, uint8_t** array) {
+ size_t array_size = plc4c_utils_list_size(list);
+ uint8_t* byte_array = malloc(sizeof(uint8_t) * array_size);
+ if(byte_array == NULL) {
+ return NO_MEMORY;
+ }
+ uint8_t* cur_byte = byte_array;
+ plc4c_list_element* cur_element = list->tail;
+ for(int i = 0; i < array_size; i++) {
+ *cur_byte = (uint8_t) (cur_element->value);
+ cur_byte++;
+ cur_element = cur_element->next;
+ }
+ *array = byte_array;
+ return OK;
+}
+
plc4c_return_code plc4c_driver_s7_read_machine_function(
plc4c_system_task* task) {
plc4c_read_request_execution* read_request_execution = task->context;
@@ -90,6 +107,15 @@
if(parameter->s7_parameter_read_var_response_num_items != plc4c_utils_list_size(read_request->items)) {
return INTERNAL_ERROR;
}
+
+ plc4c_read_response* read_response = malloc(sizeof(plc4c_read_response));
+ if(read_response == NULL) {
+ return NO_MEMORY;
+ }
+ read_response->read_request = read_request;
+ read_request_execution->read_response = read_response;
+ plc4c_utils_list_create(&(read_response->items));
+
// Iterate over the request items and use the types to decode the
// response items.
plc4c_s7_read_write_s7_payload* payload = s7_read_response_packet->payload->payload->payload;
@@ -97,15 +123,48 @@
plc4c_list_element* cur_response_item_element = plc4c_utils_list_tail(payload->s7_payload_read_var_response_items);
while((cur_request_item_element != NULL) && (cur_response_item_element != NULL)) {
plc4c_item* cur_request_item = cur_request_item_element->value;
- plc4c_s7_read_write_s7_address* s7_address = cur_request_item->address;
- plc4c_s7_read_write_transport_size transport_size = s7_address->s7_address_any_transport_size;
- uint16_t num_elements = s7_address->s7_address_any_number_of_elements;
+ // Get the protocol id for the current item from the corresponding
+ // request item. Also get the number of elements, if it's an array.
+ plc4c_s7_read_write_s7_var_request_parameter_item* s7_address = cur_request_item->address;
+ plc4c_s7_read_write_transport_size transport_size = s7_address->s7_var_request_parameter_item_address_address->s7_address_any_transport_size;
+ uint8_t data_protocol_id = plc4c_s7_read_write_transport_size_get_data_protocol_id(transport_size);
+ uint16_t num_elements = s7_address->s7_var_request_parameter_item_address_address->s7_address_any_number_of_elements;
+ int32_t string_length = 0;
+
+ // Convert the linked list with uint8_t elements into an array of uint8_t.
plc4c_s7_read_write_s7_var_payload_data_item* cur_response_item = cur_response_item_element->value;
-
+ uint8_t* byte_array = NULL;
+ plc4c_return_code result = plc4c_driver_s7_read_list_to_byte_array(cur_response_item->data, &byte_array);
+ if(result != OK) {
+ return result;
+ }
+
+ // Create a new read-buffer for reading data from the uint8_t array.
+ plc4c_spi_read_buffer* read_buffer;
+ result = plc4c_spi_read_buffer_create(byte_array, plc4c_utils_list_size(cur_response_item->data), &read_buffer);
+ if(result != OK) {
+ return result;
+ }
+
+ // Parse the data item.
+ plc4c_data* data_item;
+ plc4c_s7_read_write_data_item_parse(read_buffer, data_protocol_id, string_length, &data_item);
+
+ // Create a new response value-item
+ plc4c_response_value_item* response_value_item = malloc(sizeof(plc4c_response_value_item));
+ if(response_value_item == NULL) {
+ return NO_MEMORY;
+ }
+ response_value_item->item = cur_request_item;
+ response_value_item->response_code = PLC4C_RESPONSE_CODE_OK;
+ response_value_item->value = data_item;
+
+ // Add the value-item to the list.
+ plc4c_utils_list_insert_head_value(read_response->items, response_value_item);
cur_request_item_element = cur_request_item_element->next;
- cur_request_item_element = cur_response_item_element->next;
+ cur_response_item_element = cur_response_item_element->next;
}
// TODO: Return the results to the API ...
diff --git a/sandbox/plc4c/drivers/simulated/src/driver_simulated.c b/sandbox/plc4c/drivers/simulated/src/driver_simulated.c
index 13311ac..8346ae9 100644
--- a/sandbox/plc4c/drivers/simulated/src/driver_simulated.c
+++ b/sandbox/plc4c/drivers/simulated/src/driver_simulated.c
@@ -133,7 +133,7 @@
* we can also set a custom printf method
* right , now just create a new random value
*/
- value_item->value = plc4c_data_create_uint_data(rand());
+ value_item->value = plc4c_data_create_uint32_t_data(rand());
// Add the value to the response.
plc4c_utils_list_insert_tail_value(read_response->items, value_item);
diff --git a/sandbox/plc4c/examples/hello-world/src/hello_world.c b/sandbox/plc4c/examples/hello-world/src/hello_world.c
index 5ed9357..f809b26 100644
--- a/sandbox/plc4c/examples/hello-world/src/hello_world.c
+++ b/sandbox/plc4c/examples/hello-world/src/hello_world.c
@@ -242,7 +242,7 @@
// Iterate over all returned items.
plc4c_list_element *cur_element =
- plc4c_utils_list_head(read_response->items);
+ plc4c_utils_list_tail(read_response->items);
while (cur_element != NULL) {
plc4c_response_value_item *value_item = cur_element->value;
@@ -259,8 +259,18 @@
plc4c_read_request_execution_destroy(read_request_execution);
plc4c_read_request_destroy(read_request);
+ // TODO: Comment out after implementing the write functionality.
+ // Disconnect.
+ printf("Disconnecting ... ");
+ result = plc4c_connection_disconnect(connection);
+ if (result != OK) {
+ printf("FAILED");
+ return -1;
+ }
+ state = DISCONNECTING;
+
// Create a new write-request.
- printf("Preparing a write-request ... ");
+/* printf("Preparing a write-request ... ");
char value[] = "bar";
result =
plc4c_connection_create_write_request(connection, &write_request);
@@ -289,7 +299,7 @@
return -1;
} else {
state = WRITE_REQUEST_SENT;
- }
+ }*/
break;
}
// Wait until the write-request execution is finished.
diff --git a/sandbox/plc4c/generated-sources/modbus/include/data_item.h b/sandbox/plc4c/generated-sources/modbus/include/data_item.h
new file mode 100644
index 0000000..4a7353a
--- /dev/null
+++ b/sandbox/plc4c/generated-sources/modbus/include/data_item.h
@@ -0,0 +1,43 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+#ifndef PLC4C_MODBUS_READ_WRITE_DATA_ITEM_H_
+#define PLC4C_MODBUS_READ_WRITE_DATA_ITEM_H_
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <plc4c/spi/read_buffer.h>
+#include <plc4c/spi/write_buffer.h>
+#include <plc4c/utils/list.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4c_spi_read_buffer* buf, uint8_t dataType, uint8_t numberOfValues, plc4c_data** data_item);
+
+plc4c_return_code plc4c_modbus_read_write_data_item_serialize(plc4c_spi_write_buffer* buf, plc4c_data** data_item);
+
+uint16_t plc4c_modbus_read_write_data_item_length_in_bytes(plc4c_data* data_item);
+
+uint16_t plc4c_modbus_read_write_data_item_length_in_bits(plc4c_data* data_item);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // PLC4C_MODBUS_READ_WRITE_DATA_ITEM_H_
diff --git a/sandbox/plc4c/generated-sources/modbus/includes/modbus_constants.h b/sandbox/plc4c/generated-sources/modbus/include/modbus_constants.h
similarity index 91%
rename from sandbox/plc4c/generated-sources/modbus/includes/modbus_constants.h
rename to sandbox/plc4c/generated-sources/modbus/include/modbus_constants.h
index 5504e8f..60c1a43 100644
--- a/sandbox/plc4c/generated-sources/modbus/includes/modbus_constants.h
+++ b/sandbox/plc4c/generated-sources/modbus/include/modbus_constants.h
@@ -42,9 +42,9 @@
// Create an empty NULL-struct
plc4c_modbus_read_write_modbus_constants plc4c_modbus_read_write_modbus_constants_null();
-plc4c_return_code plc4c_modbus_read_write_modbus_constants_parse(plc4c_spi_read_buffer* buf, plc4c_modbus_read_write_modbus_constants** message);
+plc4c_return_code plc4c_modbus_read_write_modbus_constants_parse(plc4c_spi_read_buffer* io, plc4c_modbus_read_write_modbus_constants** message);
-plc4c_return_code plc4c_modbus_read_write_modbus_constants_serialize(plc4c_spi_write_buffer* buf, plc4c_modbus_read_write_modbus_constants* message);
+plc4c_return_code plc4c_modbus_read_write_modbus_constants_serialize(plc4c_spi_write_buffer* io, plc4c_modbus_read_write_modbus_constants* message);
uint16_t plc4c_modbus_read_write_modbus_constants_length_in_bytes(plc4c_modbus_read_write_modbus_constants* message);
diff --git a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu.h b/sandbox/plc4c/generated-sources/modbus/include/modbus_pdu.h
similarity index 98%
rename from sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu.h
rename to sandbox/plc4c/generated-sources/modbus/include/modbus_pdu.h
index 2011d29..08adfa5 100644
--- a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu.h
+++ b/sandbox/plc4c/generated-sources/modbus/include/modbus_pdu.h
@@ -227,9 +227,9 @@
// Create an empty NULL-struct
plc4c_modbus_read_write_modbus_pdu plc4c_modbus_read_write_modbus_pdu_null();
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu** message);
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer* io, bool response, plc4c_modbus_read_write_modbus_pdu** message);
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_serialize(plc4c_spi_write_buffer* buf, plc4c_modbus_read_write_modbus_pdu* message);
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_serialize(plc4c_spi_write_buffer* io, plc4c_modbus_read_write_modbus_pdu* message);
uint16_t plc4c_modbus_read_write_modbus_pdu_length_in_bytes(plc4c_modbus_read_write_modbus_pdu* message);
diff --git a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_read_file_record_request_item.h b/sandbox/plc4c/generated-sources/modbus/include/modbus_pdu_read_file_record_request_item.h
similarity index 89%
rename from sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_read_file_record_request_item.h
rename to sandbox/plc4c/generated-sources/modbus/include/modbus_pdu_read_file_record_request_item.h
index 8e2d438..3b3ad03 100644
--- a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_read_file_record_request_item.h
+++ b/sandbox/plc4c/generated-sources/modbus/include/modbus_pdu_read_file_record_request_item.h
@@ -42,9 +42,9 @@
// Create an empty NULL-struct
plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item_null();
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item_parse(plc4c_spi_read_buffer* buf, plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item** message);
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item_parse(plc4c_spi_read_buffer* io, plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item** message);
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item_serialize(plc4c_spi_write_buffer* buf, plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item* message);
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item_serialize(plc4c_spi_write_buffer* io, plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item* message);
uint16_t plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item_length_in_bytes(plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item* message);
diff --git a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_read_file_record_response_item.h b/sandbox/plc4c/generated-sources/modbus/include/modbus_pdu_read_file_record_response_item.h
similarity index 88%
rename from sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_read_file_record_response_item.h
rename to sandbox/plc4c/generated-sources/modbus/include/modbus_pdu_read_file_record_response_item.h
index 4071a22..5fc5233 100644
--- a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_read_file_record_response_item.h
+++ b/sandbox/plc4c/generated-sources/modbus/include/modbus_pdu_read_file_record_response_item.h
@@ -40,9 +40,9 @@
// Create an empty NULL-struct
plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item_null();
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item_parse(plc4c_spi_read_buffer* buf, plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item** message);
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item_parse(plc4c_spi_read_buffer* io, plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item** message);
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item_serialize(plc4c_spi_write_buffer* buf, plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item* message);
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item_serialize(plc4c_spi_write_buffer* io, plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item* message);
uint16_t plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item_length_in_bytes(plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item* message);
diff --git a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_write_file_record_request_item.h b/sandbox/plc4c/generated-sources/modbus/include/modbus_pdu_write_file_record_request_item.h
similarity index 89%
rename from sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_write_file_record_request_item.h
rename to sandbox/plc4c/generated-sources/modbus/include/modbus_pdu_write_file_record_request_item.h
index a781f77..b32f2b3 100644
--- a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_write_file_record_request_item.h
+++ b/sandbox/plc4c/generated-sources/modbus/include/modbus_pdu_write_file_record_request_item.h
@@ -42,9 +42,9 @@
// Create an empty NULL-struct
plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item_null();
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item_parse(plc4c_spi_read_buffer* buf, plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item** message);
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item_parse(plc4c_spi_read_buffer* io, plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item** message);
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item_serialize(plc4c_spi_write_buffer* buf, plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item* message);
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item_serialize(plc4c_spi_write_buffer* io, plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item* message);
uint16_t plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item_length_in_bytes(plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item* message);
diff --git a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_write_file_record_response_item.h b/sandbox/plc4c/generated-sources/modbus/include/modbus_pdu_write_file_record_response_item.h
similarity index 89%
rename from sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_write_file_record_response_item.h
rename to sandbox/plc4c/generated-sources/modbus/include/modbus_pdu_write_file_record_response_item.h
index acb7ad6..81d20e6 100644
--- a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_write_file_record_response_item.h
+++ b/sandbox/plc4c/generated-sources/modbus/include/modbus_pdu_write_file_record_response_item.h
@@ -42,9 +42,9 @@
// Create an empty NULL-struct
plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item_null();
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item_parse(plc4c_spi_read_buffer* buf, plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item** message);
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item_parse(plc4c_spi_read_buffer* io, plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item** message);
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item_serialize(plc4c_spi_write_buffer* buf, plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item* message);
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item_serialize(plc4c_spi_write_buffer* io, plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item* message);
uint16_t plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item_length_in_bytes(plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item* message);
diff --git a/sandbox/plc4c/generated-sources/modbus/includes/modbus_serial_adu.h b/sandbox/plc4c/generated-sources/modbus/include/modbus_serial_adu.h
similarity index 91%
rename from sandbox/plc4c/generated-sources/modbus/includes/modbus_serial_adu.h
rename to sandbox/plc4c/generated-sources/modbus/include/modbus_serial_adu.h
index f0360db..9a280c0 100644
--- a/sandbox/plc4c/generated-sources/modbus/includes/modbus_serial_adu.h
+++ b/sandbox/plc4c/generated-sources/modbus/include/modbus_serial_adu.h
@@ -43,9 +43,9 @@
// Create an empty NULL-struct
plc4c_modbus_read_write_modbus_serial_adu plc4c_modbus_read_write_modbus_serial_adu_null();
-plc4c_return_code plc4c_modbus_read_write_modbus_serial_adu_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_serial_adu** message);
+plc4c_return_code plc4c_modbus_read_write_modbus_serial_adu_parse(plc4c_spi_read_buffer* io, bool response, plc4c_modbus_read_write_modbus_serial_adu** message);
-plc4c_return_code plc4c_modbus_read_write_modbus_serial_adu_serialize(plc4c_spi_write_buffer* buf, plc4c_modbus_read_write_modbus_serial_adu* message);
+plc4c_return_code plc4c_modbus_read_write_modbus_serial_adu_serialize(plc4c_spi_write_buffer* io, plc4c_modbus_read_write_modbus_serial_adu* message);
uint16_t plc4c_modbus_read_write_modbus_serial_adu_length_in_bytes(plc4c_modbus_read_write_modbus_serial_adu* message);
diff --git a/sandbox/plc4c/generated-sources/modbus/includes/modbus_tcp_adu.h b/sandbox/plc4c/generated-sources/modbus/include/modbus_tcp_adu.h
similarity index 91%
rename from sandbox/plc4c/generated-sources/modbus/includes/modbus_tcp_adu.h
rename to sandbox/plc4c/generated-sources/modbus/include/modbus_tcp_adu.h
index dfa1783..ca9ef93 100644
--- a/sandbox/plc4c/generated-sources/modbus/includes/modbus_tcp_adu.h
+++ b/sandbox/plc4c/generated-sources/modbus/include/modbus_tcp_adu.h
@@ -46,9 +46,9 @@
// Create an empty NULL-struct
plc4c_modbus_read_write_modbus_tcp_adu plc4c_modbus_read_write_modbus_tcp_adu_null();
-plc4c_return_code plc4c_modbus_read_write_modbus_tcp_adu_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_tcp_adu** message);
+plc4c_return_code plc4c_modbus_read_write_modbus_tcp_adu_parse(plc4c_spi_read_buffer* io, bool response, plc4c_modbus_read_write_modbus_tcp_adu** message);
-plc4c_return_code plc4c_modbus_read_write_modbus_tcp_adu_serialize(plc4c_spi_write_buffer* buf, plc4c_modbus_read_write_modbus_tcp_adu* message);
+plc4c_return_code plc4c_modbus_read_write_modbus_tcp_adu_serialize(plc4c_spi_write_buffer* io, plc4c_modbus_read_write_modbus_tcp_adu* message);
uint16_t plc4c_modbus_read_write_modbus_tcp_adu_length_in_bytes(plc4c_modbus_read_write_modbus_tcp_adu* message);
diff --git a/sandbox/plc4c/generated-sources/modbus/src/data_item.c b/sandbox/plc4c/generated-sources/modbus/src/data_item.c
new file mode 100644
index 0000000..a825905
--- /dev/null
+++ b/sandbox/plc4c/generated-sources/modbus/src/data_item.c
@@ -0,0 +1,96 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+#include <stdio.h>
+#include <time.h>
+#include <plc4c/data.h>
+#include <plc4c/spi/evaluation_helper.h>
+#include <plc4c/driver_modbus.h>
+#include "data_item.h"
+
+// Parse function.
+plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4c_spi_read_buffer* io, uint8_t dataType, uint8_t numberOfValues, plc4c_data** data_item) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
+ uint16_t curPos;
+ plc4c_return_code _res = OK;
+
+ if((dataType == 1) && (numberOfValues == 1)) { /* Boolean */
+
+ // Reserved Field (Compartmentalized so the "reserved" variable can't leak)
+ {
+ unsigned int _reserved = 0;
+ _res = plc4c_spi_read_unsigned_byte(io, 7, (uint8_t*) &_reserved);
+ if(_res != OK) {
+ return _res;
+ }
+ if(_reserved != 0x00) {
+ printf("Expected constant value '%d' but got '%d' for reserved field.", 0x00, _reserved);
+ }
+ }
+
+ // Simple Field (value)
+ bool value = false;
+ _res = plc4c_spi_read_bit(io, (bool*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_bool_data(value);
+
+ } else
+ if(dataType == 1) { /* List */
+
+ // Array field (value)
+ } else
+ if((dataType == 2) && (numberOfValues == 1)) { /* Integer */
+
+ // Simple Field (value)
+ int16_t value = 0;
+ _res = plc4c_spi_read_signed_short(io, 16, (int16_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_int16_t_data(value);
+
+ } else
+ if(dataType == 2) { /* List */
+
+ // Array field (value)
+ }
+
+ return OK;
+}
+
+plc4c_return_code plc4c_modbus_read_write_data_item_serialize(plc4c_spi_write_buffer* io, plc4c_data** data_item) {
+ plc4c_return_code _res = OK;
+
+ return OK;
+}
+
+uint16_t plc4c_modbus_read_write_data_item_length_in_bytes(plc4c_data* data_item) {
+ return plc4c_modbus_read_write_data_item_length_in_bits(data_item) / 8;
+}
+
+uint16_t plc4c_modbus_read_write_data_item_length_in_bits(plc4c_data* data_item) {
+ uint16_t lengthInBits = 0;
+
+ return lengthInBits;
+}
+
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_constants.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_constants.c
index d4abb8b..826e276 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_constants.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_constants.c
@@ -29,8 +29,8 @@
}
// Parse function.
-plc4c_return_code plc4c_modbus_read_write_modbus_constants_parse(plc4c_spi_read_buffer* buf, plc4c_modbus_read_write_modbus_constants** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_modbus_read_write_modbus_constants_parse(plc4c_spi_read_buffer* io, plc4c_modbus_read_write_modbus_constants** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -42,7 +42,7 @@
// Const Field (modbusTcpDefaultPort)
uint16_t modbusTcpDefaultPort = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &modbusTcpDefaultPort);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &modbusTcpDefaultPort);
if(_res != OK) {
return _res;
}
@@ -54,11 +54,11 @@
return OK;
}
-plc4c_return_code plc4c_modbus_read_write_modbus_constants_serialize(plc4c_spi_write_buffer* buf, plc4c_modbus_read_write_modbus_constants* _message) {
+plc4c_return_code plc4c_modbus_read_write_modbus_constants_serialize(plc4c_spi_write_buffer* io, plc4c_modbus_read_write_modbus_constants* _message) {
plc4c_return_code _res = OK;
// Const Field (modbusTcpDefaultPort)
- plc4c_spi_write_unsigned_short(buf, 16, PLC4C_MODBUS_READ_WRITE_MODBUS_CONSTANTS_MODBUS_TCP_DEFAULT_PORT());
+ plc4c_spi_write_unsigned_short(io, 16, PLC4C_MODBUS_READ_WRITE_MODBUS_CONSTANTS_MODBUS_TCP_DEFAULT_PORT());
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu.c
index 350b6d0..b29b90d 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu.c
@@ -113,8 +113,8 @@
// Parse function.
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer* io, bool response, plc4c_modbus_read_write_modbus_pdu** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -126,14 +126,14 @@
// Discriminator Field (error) (Used as input to a switch field)
bool error = false;
- _res = plc4c_spi_read_bit(buf, (bool*) &error);
+ _res = plc4c_spi_read_bit(io, (bool*) &error);
if(_res != OK) {
return _res;
}
// Discriminator Field (function) (Used as input to a switch field)
unsigned int function = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 7, (uint8_t*) &function);
+ _res = plc4c_spi_read_unsigned_byte(io, 7, (uint8_t*) &function);
if(_res != OK) {
return _res;
}
@@ -144,7 +144,7 @@
// Simple Field (exceptionCode)
uint8_t exceptionCode = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &exceptionCode);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &exceptionCode);
if(_res != OK) {
return _res;
}
@@ -156,7 +156,7 @@
// Simple Field (startingAddress)
uint16_t startingAddress = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &startingAddress);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &startingAddress);
if(_res != OK) {
return _res;
}
@@ -166,7 +166,7 @@
// Simple Field (quantity)
uint16_t quantity = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &quantity);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &quantity);
if(_res != OK) {
return _res;
}
@@ -178,7 +178,7 @@
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t byteCount = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &byteCount);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &byteCount);
if(_res != OK) {
return _res;
}
@@ -197,7 +197,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = malloc(sizeof(int8_t));
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) _value);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) _value);
if(_res != OK) {
return _res;
}
@@ -212,7 +212,7 @@
// Simple Field (startingAddress)
uint16_t startingAddress = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &startingAddress);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &startingAddress);
if(_res != OK) {
return _res;
}
@@ -222,7 +222,7 @@
// Simple Field (quantity)
uint16_t quantity = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &quantity);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &quantity);
if(_res != OK) {
return _res;
}
@@ -234,7 +234,7 @@
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t byteCount = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &byteCount);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &byteCount);
if(_res != OK) {
return _res;
}
@@ -253,7 +253,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = malloc(sizeof(int8_t));
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) _value);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) _value);
if(_res != OK) {
return _res;
}
@@ -268,7 +268,7 @@
// Simple Field (address)
uint16_t address = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &address);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &address);
if(_res != OK) {
return _res;
}
@@ -278,7 +278,7 @@
// Simple Field (value)
uint16_t value = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &value);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &value);
if(_res != OK) {
return _res;
}
@@ -290,7 +290,7 @@
// Simple Field (address)
uint16_t address = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &address);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &address);
if(_res != OK) {
return _res;
}
@@ -300,7 +300,7 @@
// Simple Field (value)
uint16_t value = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &value);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &value);
if(_res != OK) {
return _res;
}
@@ -312,7 +312,7 @@
// Simple Field (startingAddress)
uint16_t startingAddress = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &startingAddress);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &startingAddress);
if(_res != OK) {
return _res;
}
@@ -322,7 +322,7 @@
// Simple Field (quantity)
uint16_t quantity = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &quantity);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &quantity);
if(_res != OK) {
return _res;
}
@@ -332,7 +332,7 @@
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t byteCount = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &byteCount);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &byteCount);
if(_res != OK) {
return _res;
}
@@ -351,7 +351,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = malloc(sizeof(int8_t));
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) _value);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) _value);
if(_res != OK) {
return _res;
}
@@ -366,7 +366,7 @@
// Simple Field (startingAddress)
uint16_t startingAddress = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &startingAddress);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &startingAddress);
if(_res != OK) {
return _res;
}
@@ -376,7 +376,7 @@
// Simple Field (quantity)
uint16_t quantity = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &quantity);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &quantity);
if(_res != OK) {
return _res;
}
@@ -388,7 +388,7 @@
// Simple Field (startingAddress)
uint16_t startingAddress = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &startingAddress);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &startingAddress);
if(_res != OK) {
return _res;
}
@@ -398,7 +398,7 @@
// Simple Field (quantity)
uint16_t quantity = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &quantity);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &quantity);
if(_res != OK) {
return _res;
}
@@ -410,7 +410,7 @@
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t byteCount = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &byteCount);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &byteCount);
if(_res != OK) {
return _res;
}
@@ -429,7 +429,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = malloc(sizeof(int8_t));
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) _value);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) _value);
if(_res != OK) {
return _res;
}
@@ -444,7 +444,7 @@
// Simple Field (startingAddress)
uint16_t startingAddress = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &startingAddress);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &startingAddress);
if(_res != OK) {
return _res;
}
@@ -454,7 +454,7 @@
// Simple Field (quantity)
uint16_t quantity = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &quantity);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &quantity);
if(_res != OK) {
return _res;
}
@@ -466,7 +466,7 @@
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t byteCount = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &byteCount);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &byteCount);
if(_res != OK) {
return _res;
}
@@ -485,7 +485,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = malloc(sizeof(int8_t));
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) _value);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) _value);
if(_res != OK) {
return _res;
}
@@ -500,7 +500,7 @@
// Simple Field (address)
uint16_t address = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &address);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &address);
if(_res != OK) {
return _res;
}
@@ -510,7 +510,7 @@
// Simple Field (value)
uint16_t value = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &value);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &value);
if(_res != OK) {
return _res;
}
@@ -522,7 +522,7 @@
// Simple Field (address)
uint16_t address = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &address);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &address);
if(_res != OK) {
return _res;
}
@@ -532,7 +532,7 @@
// Simple Field (value)
uint16_t value = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &value);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &value);
if(_res != OK) {
return _res;
}
@@ -544,7 +544,7 @@
// Simple Field (startingAddress)
uint16_t startingAddress = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &startingAddress);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &startingAddress);
if(_res != OK) {
return _res;
}
@@ -554,7 +554,7 @@
// Simple Field (quantity)
uint16_t quantity = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &quantity);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &quantity);
if(_res != OK) {
return _res;
}
@@ -564,7 +564,7 @@
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t byteCount = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &byteCount);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &byteCount);
if(_res != OK) {
return _res;
}
@@ -583,7 +583,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = malloc(sizeof(int8_t));
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) _value);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) _value);
if(_res != OK) {
return _res;
}
@@ -598,7 +598,7 @@
// Simple Field (startingAddress)
uint16_t startingAddress = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &startingAddress);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &startingAddress);
if(_res != OK) {
return _res;
}
@@ -608,7 +608,7 @@
// Simple Field (quantity)
uint16_t quantity = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &quantity);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &quantity);
if(_res != OK) {
return _res;
}
@@ -620,7 +620,7 @@
// Simple Field (readStartingAddress)
uint16_t readStartingAddress = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &readStartingAddress);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &readStartingAddress);
if(_res != OK) {
return _res;
}
@@ -630,7 +630,7 @@
// Simple Field (readQuantity)
uint16_t readQuantity = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &readQuantity);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &readQuantity);
if(_res != OK) {
return _res;
}
@@ -640,7 +640,7 @@
// Simple Field (writeStartingAddress)
uint16_t writeStartingAddress = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &writeStartingAddress);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &writeStartingAddress);
if(_res != OK) {
return _res;
}
@@ -650,7 +650,7 @@
// Simple Field (writeQuantity)
uint16_t writeQuantity = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &writeQuantity);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &writeQuantity);
if(_res != OK) {
return _res;
}
@@ -660,7 +660,7 @@
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t byteCount = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &byteCount);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &byteCount);
if(_res != OK) {
return _res;
}
@@ -679,7 +679,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = malloc(sizeof(int8_t));
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) _value);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) _value);
if(_res != OK) {
return _res;
}
@@ -694,7 +694,7 @@
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t byteCount = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &byteCount);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &byteCount);
if(_res != OK) {
return _res;
}
@@ -713,7 +713,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = malloc(sizeof(int8_t));
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) _value);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) _value);
if(_res != OK) {
return _res;
}
@@ -728,7 +728,7 @@
// Simple Field (referenceAddress)
uint16_t referenceAddress = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &referenceAddress);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &referenceAddress);
if(_res != OK) {
return _res;
}
@@ -738,7 +738,7 @@
// Simple Field (andMask)
uint16_t andMask = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &andMask);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &andMask);
if(_res != OK) {
return _res;
}
@@ -748,7 +748,7 @@
// Simple Field (orMask)
uint16_t orMask = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &orMask);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &orMask);
if(_res != OK) {
return _res;
}
@@ -760,7 +760,7 @@
// Simple Field (referenceAddress)
uint16_t referenceAddress = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &referenceAddress);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &referenceAddress);
if(_res != OK) {
return _res;
}
@@ -770,7 +770,7 @@
// Simple Field (andMask)
uint16_t andMask = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &andMask);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &andMask);
if(_res != OK) {
return _res;
}
@@ -780,7 +780,7 @@
// Simple Field (orMask)
uint16_t orMask = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &orMask);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &orMask);
if(_res != OK) {
return _res;
}
@@ -792,7 +792,7 @@
// Simple Field (fifoPointerAddress)
uint16_t fifoPointerAddress = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &fifoPointerAddress);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &fifoPointerAddress);
if(_res != OK) {
return _res;
}
@@ -804,7 +804,7 @@
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint16_t byteCount = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &byteCount);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &byteCount);
if(_res != OK) {
return _res;
}
@@ -813,7 +813,7 @@
// Implicit Field (fifoCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint16_t fifoCount = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &fifoCount);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &fifoCount);
if(_res != OK) {
return _res;
}
@@ -832,7 +832,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
uint16_t* _value = malloc(sizeof(uint16_t));
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) _value);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) _value);
if(_res != OK) {
return _res;
}
@@ -847,7 +847,7 @@
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t byteCount = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &byteCount);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &byteCount);
if(_res != OK) {
return _res;
}
@@ -863,10 +863,10 @@
{
// Length array
uint8_t _itemsLength = byteCount;
- uint8_t itemsEndPos = plc4c_spi_read_get_pos(buf) + _itemsLength;
- while(plc4c_spi_read_get_pos(buf) < itemsEndPos) {
+ uint8_t itemsEndPos = plc4c_spi_read_get_pos(io) + _itemsLength;
+ while(plc4c_spi_read_get_pos(io) < itemsEndPos) {
plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item* _value = NULL;
- _res = plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item_parse(buf, (void*) &_value);
+ _res = plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item_parse(io, (void*) &_value);
if(_res != OK) {
return _res;
}
@@ -881,7 +881,7 @@
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t byteCount = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &byteCount);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &byteCount);
if(_res != OK) {
return _res;
}
@@ -897,10 +897,10 @@
{
// Length array
uint8_t _itemsLength = byteCount;
- uint8_t itemsEndPos = plc4c_spi_read_get_pos(buf) + _itemsLength;
- while(plc4c_spi_read_get_pos(buf) < itemsEndPos) {
+ uint8_t itemsEndPos = plc4c_spi_read_get_pos(io) + _itemsLength;
+ while(plc4c_spi_read_get_pos(io) < itemsEndPos) {
plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item* _value = NULL;
- _res = plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item_parse(buf, (void*) &_value);
+ _res = plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item_parse(io, (void*) &_value);
if(_res != OK) {
return _res;
}
@@ -915,7 +915,7 @@
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t byteCount = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &byteCount);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &byteCount);
if(_res != OK) {
return _res;
}
@@ -931,10 +931,10 @@
{
// Length array
uint8_t _itemsLength = byteCount;
- uint8_t itemsEndPos = plc4c_spi_read_get_pos(buf) + _itemsLength;
- while(plc4c_spi_read_get_pos(buf) < itemsEndPos) {
+ uint8_t itemsEndPos = plc4c_spi_read_get_pos(io) + _itemsLength;
+ while(plc4c_spi_read_get_pos(io) < itemsEndPos) {
plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item* _value = NULL;
- _res = plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item_parse(buf, (void*) &_value);
+ _res = plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item_parse(io, (void*) &_value);
if(_res != OK) {
return _res;
}
@@ -949,7 +949,7 @@
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t byteCount = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &byteCount);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &byteCount);
if(_res != OK) {
return _res;
}
@@ -965,10 +965,10 @@
{
// Length array
uint8_t _itemsLength = byteCount;
- uint8_t itemsEndPos = plc4c_spi_read_get_pos(buf) + _itemsLength;
- while(plc4c_spi_read_get_pos(buf) < itemsEndPos) {
+ uint8_t itemsEndPos = plc4c_spi_read_get_pos(io) + _itemsLength;
+ while(plc4c_spi_read_get_pos(io) < itemsEndPos) {
plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item* _value = NULL;
- _res = plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item_parse(buf, (void*) &_value);
+ _res = plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item_parse(io, (void*) &_value);
if(_res != OK) {
return _res;
}
@@ -986,7 +986,7 @@
// Simple Field (value)
uint8_t value = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &value);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &value);
if(_res != OK) {
return _res;
}
@@ -998,7 +998,7 @@
// Simple Field (status)
uint16_t status = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &status);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &status);
if(_res != OK) {
return _res;
}
@@ -1008,7 +1008,7 @@
// Simple Field (eventCount)
uint16_t eventCount = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &eventCount);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &eventCount);
if(_res != OK) {
return _res;
}
@@ -1023,7 +1023,7 @@
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t byteCount = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &byteCount);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &byteCount);
if(_res != OK) {
return _res;
}
@@ -1032,7 +1032,7 @@
// Simple Field (status)
uint16_t status = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &status);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &status);
if(_res != OK) {
return _res;
}
@@ -1042,7 +1042,7 @@
// Simple Field (eventCount)
uint16_t eventCount = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &eventCount);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &eventCount);
if(_res != OK) {
return _res;
}
@@ -1052,7 +1052,7 @@
// Simple Field (messageCount)
uint16_t messageCount = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &messageCount);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &messageCount);
if(_res != OK) {
return _res;
}
@@ -1072,7 +1072,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = malloc(sizeof(int8_t));
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) _value);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) _value);
if(_res != OK) {
return _res;
}
@@ -1090,7 +1090,7 @@
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t byteCount = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &byteCount);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &byteCount);
if(_res != OK) {
return _res;
}
@@ -1109,7 +1109,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = malloc(sizeof(int8_t));
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) _value);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) _value);
if(_res != OK) {
return _res;
}
@@ -1129,21 +1129,21 @@
return OK;
}
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_serialize(plc4c_spi_write_buffer* buf, plc4c_modbus_read_write_modbus_pdu* _message) {
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_serialize(plc4c_spi_write_buffer* io, plc4c_modbus_read_write_modbus_pdu* _message) {
plc4c_return_code _res = OK;
// Discriminator Field (error)
- plc4c_spi_write_bit(buf, plc4c_modbus_read_write_modbus_pdu_get_discriminator(_message->_type).error);
+ plc4c_spi_write_bit(io, plc4c_modbus_read_write_modbus_pdu_get_discriminator(_message->_type).error);
// Discriminator Field (function)
- plc4c_spi_write_unsigned_byte(buf, 7, plc4c_modbus_read_write_modbus_pdu_get_discriminator(_message->_type).function);
+ plc4c_spi_write_unsigned_byte(io, 7, plc4c_modbus_read_write_modbus_pdu_get_discriminator(_message->_type).function);
// Switch Field (Depending of the current type, serialize the sub-type elements)
switch(_message->_type) {
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_error: {
// Simple Field (exceptionCode)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, _message->modbus_pdu_error_exception_code);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->modbus_pdu_error_exception_code);
if(_res != OK) {
return _res;
}
@@ -1153,13 +1153,13 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_discrete_inputs_request: {
// Simple Field (startingAddress)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_read_discrete_inputs_request_starting_address);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_read_discrete_inputs_request_starting_address);
if(_res != OK) {
return _res;
}
// Simple Field (quantity)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_read_discrete_inputs_request_quantity);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_read_discrete_inputs_request_quantity);
if(_res != OK) {
return _res;
}
@@ -1169,7 +1169,7 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_discrete_inputs_response: {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, plc4c_spi_evaluation_helper_count(_message->modbus_pdu_read_discrete_inputs_response_value));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, plc4c_spi_evaluation_helper_count(_message->modbus_pdu_read_discrete_inputs_response_value));
if(_res != OK) {
return _res;
}
@@ -1180,7 +1180,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = (int8_t*) plc4c_utils_list_get_value(_message->modbus_pdu_read_discrete_inputs_response_value, curItem);
- plc4c_spi_write_signed_byte(buf, 8, *_value);
+ plc4c_spi_write_signed_byte(io, 8, *_value);
}
}
@@ -1189,13 +1189,13 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_coils_request: {
// Simple Field (startingAddress)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_read_coils_request_starting_address);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_read_coils_request_starting_address);
if(_res != OK) {
return _res;
}
// Simple Field (quantity)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_read_coils_request_quantity);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_read_coils_request_quantity);
if(_res != OK) {
return _res;
}
@@ -1205,7 +1205,7 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_coils_response: {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, plc4c_spi_evaluation_helper_count(_message->modbus_pdu_read_coils_response_value));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, plc4c_spi_evaluation_helper_count(_message->modbus_pdu_read_coils_response_value));
if(_res != OK) {
return _res;
}
@@ -1216,7 +1216,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = (int8_t*) plc4c_utils_list_get_value(_message->modbus_pdu_read_coils_response_value, curItem);
- plc4c_spi_write_signed_byte(buf, 8, *_value);
+ plc4c_spi_write_signed_byte(io, 8, *_value);
}
}
@@ -1225,13 +1225,13 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_single_coil_request: {
// Simple Field (address)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_write_single_coil_request_address);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_write_single_coil_request_address);
if(_res != OK) {
return _res;
}
// Simple Field (value)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_write_single_coil_request_value);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_write_single_coil_request_value);
if(_res != OK) {
return _res;
}
@@ -1241,13 +1241,13 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_single_coil_response: {
// Simple Field (address)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_write_single_coil_response_address);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_write_single_coil_response_address);
if(_res != OK) {
return _res;
}
// Simple Field (value)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_write_single_coil_response_value);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_write_single_coil_response_value);
if(_res != OK) {
return _res;
}
@@ -1257,19 +1257,19 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_multiple_coils_request: {
// Simple Field (startingAddress)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_write_multiple_coils_request_starting_address);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_write_multiple_coils_request_starting_address);
if(_res != OK) {
return _res;
}
// Simple Field (quantity)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_write_multiple_coils_request_quantity);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_write_multiple_coils_request_quantity);
if(_res != OK) {
return _res;
}
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, plc4c_spi_evaluation_helper_count(_message->modbus_pdu_write_multiple_coils_request_value));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, plc4c_spi_evaluation_helper_count(_message->modbus_pdu_write_multiple_coils_request_value));
if(_res != OK) {
return _res;
}
@@ -1280,7 +1280,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = (int8_t*) plc4c_utils_list_get_value(_message->modbus_pdu_write_multiple_coils_request_value, curItem);
- plc4c_spi_write_signed_byte(buf, 8, *_value);
+ plc4c_spi_write_signed_byte(io, 8, *_value);
}
}
@@ -1289,13 +1289,13 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_multiple_coils_response: {
// Simple Field (startingAddress)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_write_multiple_coils_response_starting_address);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_write_multiple_coils_response_starting_address);
if(_res != OK) {
return _res;
}
// Simple Field (quantity)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_write_multiple_coils_response_quantity);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_write_multiple_coils_response_quantity);
if(_res != OK) {
return _res;
}
@@ -1305,13 +1305,13 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_input_registers_request: {
// Simple Field (startingAddress)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_read_input_registers_request_starting_address);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_read_input_registers_request_starting_address);
if(_res != OK) {
return _res;
}
// Simple Field (quantity)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_read_input_registers_request_quantity);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_read_input_registers_request_quantity);
if(_res != OK) {
return _res;
}
@@ -1321,7 +1321,7 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_input_registers_response: {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, plc4c_spi_evaluation_helper_count(_message->modbus_pdu_read_input_registers_response_value));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, plc4c_spi_evaluation_helper_count(_message->modbus_pdu_read_input_registers_response_value));
if(_res != OK) {
return _res;
}
@@ -1332,7 +1332,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = (int8_t*) plc4c_utils_list_get_value(_message->modbus_pdu_read_input_registers_response_value, curItem);
- plc4c_spi_write_signed_byte(buf, 8, *_value);
+ plc4c_spi_write_signed_byte(io, 8, *_value);
}
}
@@ -1341,13 +1341,13 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_holding_registers_request: {
// Simple Field (startingAddress)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_read_holding_registers_request_starting_address);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_read_holding_registers_request_starting_address);
if(_res != OK) {
return _res;
}
// Simple Field (quantity)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_read_holding_registers_request_quantity);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_read_holding_registers_request_quantity);
if(_res != OK) {
return _res;
}
@@ -1357,7 +1357,7 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_holding_registers_response: {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, plc4c_spi_evaluation_helper_count(_message->modbus_pdu_read_holding_registers_response_value));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, plc4c_spi_evaluation_helper_count(_message->modbus_pdu_read_holding_registers_response_value));
if(_res != OK) {
return _res;
}
@@ -1368,7 +1368,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = (int8_t*) plc4c_utils_list_get_value(_message->modbus_pdu_read_holding_registers_response_value, curItem);
- plc4c_spi_write_signed_byte(buf, 8, *_value);
+ plc4c_spi_write_signed_byte(io, 8, *_value);
}
}
@@ -1377,13 +1377,13 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_single_register_request: {
// Simple Field (address)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_write_single_register_request_address);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_write_single_register_request_address);
if(_res != OK) {
return _res;
}
// Simple Field (value)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_write_single_register_request_value);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_write_single_register_request_value);
if(_res != OK) {
return _res;
}
@@ -1393,13 +1393,13 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_single_register_response: {
// Simple Field (address)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_write_single_register_response_address);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_write_single_register_response_address);
if(_res != OK) {
return _res;
}
// Simple Field (value)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_write_single_register_response_value);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_write_single_register_response_value);
if(_res != OK) {
return _res;
}
@@ -1409,19 +1409,19 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_multiple_holding_registers_request: {
// Simple Field (startingAddress)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_write_multiple_holding_registers_request_starting_address);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_write_multiple_holding_registers_request_starting_address);
if(_res != OK) {
return _res;
}
// Simple Field (quantity)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_write_multiple_holding_registers_request_quantity);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_write_multiple_holding_registers_request_quantity);
if(_res != OK) {
return _res;
}
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, plc4c_spi_evaluation_helper_count(_message->modbus_pdu_write_multiple_holding_registers_request_value));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, plc4c_spi_evaluation_helper_count(_message->modbus_pdu_write_multiple_holding_registers_request_value));
if(_res != OK) {
return _res;
}
@@ -1432,7 +1432,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = (int8_t*) plc4c_utils_list_get_value(_message->modbus_pdu_write_multiple_holding_registers_request_value, curItem);
- plc4c_spi_write_signed_byte(buf, 8, *_value);
+ plc4c_spi_write_signed_byte(io, 8, *_value);
}
}
@@ -1441,13 +1441,13 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_multiple_holding_registers_response: {
// Simple Field (startingAddress)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_write_multiple_holding_registers_response_starting_address);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_write_multiple_holding_registers_response_starting_address);
if(_res != OK) {
return _res;
}
// Simple Field (quantity)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_write_multiple_holding_registers_response_quantity);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_write_multiple_holding_registers_response_quantity);
if(_res != OK) {
return _res;
}
@@ -1457,31 +1457,31 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_request: {
// Simple Field (readStartingAddress)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_read_write_multiple_holding_registers_request_read_starting_address);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_read_write_multiple_holding_registers_request_read_starting_address);
if(_res != OK) {
return _res;
}
// Simple Field (readQuantity)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_read_write_multiple_holding_registers_request_read_quantity);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_read_write_multiple_holding_registers_request_read_quantity);
if(_res != OK) {
return _res;
}
// Simple Field (writeStartingAddress)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_read_write_multiple_holding_registers_request_write_starting_address);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_read_write_multiple_holding_registers_request_write_starting_address);
if(_res != OK) {
return _res;
}
// Simple Field (writeQuantity)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_read_write_multiple_holding_registers_request_write_quantity);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_read_write_multiple_holding_registers_request_write_quantity);
if(_res != OK) {
return _res;
}
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, plc4c_spi_evaluation_helper_count(_message->modbus_pdu_read_write_multiple_holding_registers_request_value));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, plc4c_spi_evaluation_helper_count(_message->modbus_pdu_read_write_multiple_holding_registers_request_value));
if(_res != OK) {
return _res;
}
@@ -1492,7 +1492,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = (int8_t*) plc4c_utils_list_get_value(_message->modbus_pdu_read_write_multiple_holding_registers_request_value, curItem);
- plc4c_spi_write_signed_byte(buf, 8, *_value);
+ plc4c_spi_write_signed_byte(io, 8, *_value);
}
}
@@ -1501,7 +1501,7 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_response: {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, plc4c_spi_evaluation_helper_count(_message->modbus_pdu_read_write_multiple_holding_registers_response_value));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, plc4c_spi_evaluation_helper_count(_message->modbus_pdu_read_write_multiple_holding_registers_response_value));
if(_res != OK) {
return _res;
}
@@ -1512,7 +1512,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = (int8_t*) plc4c_utils_list_get_value(_message->modbus_pdu_read_write_multiple_holding_registers_response_value, curItem);
- plc4c_spi_write_signed_byte(buf, 8, *_value);
+ plc4c_spi_write_signed_byte(io, 8, *_value);
}
}
@@ -1521,19 +1521,19 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_mask_write_holding_register_request: {
// Simple Field (referenceAddress)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_mask_write_holding_register_request_reference_address);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_mask_write_holding_register_request_reference_address);
if(_res != OK) {
return _res;
}
// Simple Field (andMask)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_mask_write_holding_register_request_and_mask);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_mask_write_holding_register_request_and_mask);
if(_res != OK) {
return _res;
}
// Simple Field (orMask)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_mask_write_holding_register_request_or_mask);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_mask_write_holding_register_request_or_mask);
if(_res != OK) {
return _res;
}
@@ -1543,19 +1543,19 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_mask_write_holding_register_response: {
// Simple Field (referenceAddress)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_mask_write_holding_register_response_reference_address);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_mask_write_holding_register_response_reference_address);
if(_res != OK) {
return _res;
}
// Simple Field (andMask)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_mask_write_holding_register_response_and_mask);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_mask_write_holding_register_response_and_mask);
if(_res != OK) {
return _res;
}
// Simple Field (orMask)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_mask_write_holding_register_response_or_mask);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_mask_write_holding_register_response_or_mask);
if(_res != OK) {
return _res;
}
@@ -1565,7 +1565,7 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_fifo_queue_request: {
// Simple Field (fifoPointerAddress)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_read_fifo_queue_request_fifo_pointer_address);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_read_fifo_queue_request_fifo_pointer_address);
if(_res != OK) {
return _res;
}
@@ -1575,13 +1575,13 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_fifo_queue_response: {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_short(buf, 16, (((plc4c_spi_evaluation_helper_count(_message->modbus_pdu_read_fifo_queue_response_fifo_value)) * (2))) + (2));
+ _res = plc4c_spi_write_unsigned_short(io, 16, (((plc4c_spi_evaluation_helper_count(_message->modbus_pdu_read_fifo_queue_response_fifo_value)) * (2))) + (2));
if(_res != OK) {
return _res;
}
// Implicit Field (fifoCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_short(buf, 16, (((plc4c_spi_evaluation_helper_count(_message->modbus_pdu_read_fifo_queue_response_fifo_value)) * (2))) / (2));
+ _res = plc4c_spi_write_unsigned_short(io, 16, (((plc4c_spi_evaluation_helper_count(_message->modbus_pdu_read_fifo_queue_response_fifo_value)) * (2))) / (2));
if(_res != OK) {
return _res;
}
@@ -1592,7 +1592,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
uint16_t* _value = (uint16_t*) plc4c_utils_list_get_value(_message->modbus_pdu_read_fifo_queue_response_fifo_value, curItem);
- plc4c_spi_write_unsigned_short(buf, 16, *_value);
+ plc4c_spi_write_unsigned_short(io, 16, *_value);
}
}
@@ -1601,7 +1601,7 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_file_record_request: {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, plc4c_spi_evaluation_helper_array_size_in_bytes(_message->modbus_pdu_read_file_record_request_items));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, plc4c_spi_evaluation_helper_array_size_in_bytes(_message->modbus_pdu_read_file_record_request_items));
if(_res != OK) {
return _res;
}
@@ -1612,7 +1612,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item* _value = (plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item*) plc4c_utils_list_get_value(_message->modbus_pdu_read_file_record_request_items, curItem);
- _res = plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item_serialize(buf, (void*) _value);
+ _res = plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item_serialize(io, (void*) _value);
if(_res != OK) {
return _res;
}
@@ -1624,7 +1624,7 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_file_record_response: {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, plc4c_spi_evaluation_helper_array_size_in_bytes(_message->modbus_pdu_read_file_record_response_items));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, plc4c_spi_evaluation_helper_array_size_in_bytes(_message->modbus_pdu_read_file_record_response_items));
if(_res != OK) {
return _res;
}
@@ -1635,7 +1635,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item* _value = (plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item*) plc4c_utils_list_get_value(_message->modbus_pdu_read_file_record_response_items, curItem);
- _res = plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item_serialize(buf, (void*) _value);
+ _res = plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item_serialize(io, (void*) _value);
if(_res != OK) {
return _res;
}
@@ -1647,7 +1647,7 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_file_record_request: {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, plc4c_spi_evaluation_helper_array_size_in_bytes(_message->modbus_pdu_write_file_record_request_items));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, plc4c_spi_evaluation_helper_array_size_in_bytes(_message->modbus_pdu_write_file_record_request_items));
if(_res != OK) {
return _res;
}
@@ -1658,7 +1658,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item* _value = (plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item*) plc4c_utils_list_get_value(_message->modbus_pdu_write_file_record_request_items, curItem);
- _res = plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item_serialize(buf, (void*) _value);
+ _res = plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item_serialize(io, (void*) _value);
if(_res != OK) {
return _res;
}
@@ -1670,7 +1670,7 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_file_record_response: {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, plc4c_spi_evaluation_helper_array_size_in_bytes(_message->modbus_pdu_write_file_record_response_items));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, plc4c_spi_evaluation_helper_array_size_in_bytes(_message->modbus_pdu_write_file_record_response_items));
if(_res != OK) {
return _res;
}
@@ -1681,7 +1681,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item* _value = (plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item*) plc4c_utils_list_get_value(_message->modbus_pdu_write_file_record_response_items, curItem);
- _res = plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item_serialize(buf, (void*) _value);
+ _res = plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item_serialize(io, (void*) _value);
if(_res != OK) {
return _res;
}
@@ -1697,7 +1697,7 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_exception_status_response: {
// Simple Field (value)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, _message->modbus_pdu_read_exception_status_response_value);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->modbus_pdu_read_exception_status_response_value);
if(_res != OK) {
return _res;
}
@@ -1707,13 +1707,13 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_diagnostic_request: {
// Simple Field (status)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_diagnostic_request_status);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_diagnostic_request_status);
if(_res != OK) {
return _res;
}
// Simple Field (eventCount)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_diagnostic_request_event_count);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_diagnostic_request_event_count);
if(_res != OK) {
return _res;
}
@@ -1727,25 +1727,25 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_get_com_event_log_response: {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, (plc4c_spi_evaluation_helper_count(_message->modbus_pdu_get_com_event_log_response_events)) + (6));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, (plc4c_spi_evaluation_helper_count(_message->modbus_pdu_get_com_event_log_response_events)) + (6));
if(_res != OK) {
return _res;
}
// Simple Field (status)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_get_com_event_log_response_status);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_get_com_event_log_response_status);
if(_res != OK) {
return _res;
}
// Simple Field (eventCount)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_get_com_event_log_response_event_count);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_get_com_event_log_response_event_count);
if(_res != OK) {
return _res;
}
// Simple Field (messageCount)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->modbus_pdu_get_com_event_log_response_message_count);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->modbus_pdu_get_com_event_log_response_message_count);
if(_res != OK) {
return _res;
}
@@ -1756,7 +1756,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = (int8_t*) plc4c_utils_list_get_value(_message->modbus_pdu_get_com_event_log_response_events, curItem);
- plc4c_spi_write_signed_byte(buf, 8, *_value);
+ plc4c_spi_write_signed_byte(io, 8, *_value);
}
}
@@ -1769,7 +1769,7 @@
case plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_report_server_id_response: {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, plc4c_spi_evaluation_helper_count(_message->modbus_pdu_report_server_id_response_value));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, plc4c_spi_evaluation_helper_count(_message->modbus_pdu_report_server_id_response_value));
if(_res != OK) {
return _res;
}
@@ -1780,7 +1780,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = (int8_t*) plc4c_utils_list_get_value(_message->modbus_pdu_report_server_id_response_value, curItem);
- plc4c_spi_write_signed_byte(buf, 8, *_value);
+ plc4c_spi_write_signed_byte(io, 8, *_value);
}
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_file_record_request_item.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_file_record_request_item.c
index b11214e..a4cf978 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_file_record_request_item.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_file_record_request_item.c
@@ -23,8 +23,8 @@
// Parse function.
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item_parse(plc4c_spi_read_buffer* buf, plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item_parse(plc4c_spi_read_buffer* io, plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -36,7 +36,7 @@
// Simple Field (referenceType)
uint8_t referenceType = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &referenceType);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &referenceType);
if(_res != OK) {
return _res;
}
@@ -44,7 +44,7 @@
// Simple Field (fileNumber)
uint16_t fileNumber = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &fileNumber);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &fileNumber);
if(_res != OK) {
return _res;
}
@@ -52,7 +52,7 @@
// Simple Field (recordNumber)
uint16_t recordNumber = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &recordNumber);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &recordNumber);
if(_res != OK) {
return _res;
}
@@ -60,7 +60,7 @@
// Simple Field (recordLength)
uint16_t recordLength = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &recordLength);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &recordLength);
if(_res != OK) {
return _res;
}
@@ -69,29 +69,29 @@
return OK;
}
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item_serialize(plc4c_spi_write_buffer* buf, plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item* _message) {
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item_serialize(plc4c_spi_write_buffer* io, plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item* _message) {
plc4c_return_code _res = OK;
// Simple Field (referenceType)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, _message->reference_type);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->reference_type);
if(_res != OK) {
return _res;
}
// Simple Field (fileNumber)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->file_number);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->file_number);
if(_res != OK) {
return _res;
}
// Simple Field (recordNumber)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->record_number);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->record_number);
if(_res != OK) {
return _res;
}
// Simple Field (recordLength)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->record_length);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->record_length);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_file_record_response_item.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_file_record_response_item.c
index f3ffe9a..aeff2ae 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_file_record_response_item.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_file_record_response_item.c
@@ -23,8 +23,8 @@
// Parse function.
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item_parse(plc4c_spi_read_buffer* buf, plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item_parse(plc4c_spi_read_buffer* io, plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -36,14 +36,14 @@
// Implicit Field (dataLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t dataLength = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &dataLength);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &dataLength);
if(_res != OK) {
return _res;
}
// Simple Field (referenceType)
uint8_t referenceType = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &referenceType);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &referenceType);
if(_res != OK) {
return _res;
}
@@ -58,10 +58,10 @@
{
// Length array
uint8_t _dataLength = (dataLength) - (1);
- uint8_t dataEndPos = plc4c_spi_read_get_pos(buf) + _dataLength;
- while(plc4c_spi_read_get_pos(buf) < dataEndPos) {
+ uint8_t dataEndPos = plc4c_spi_read_get_pos(io) + _dataLength;
+ while(plc4c_spi_read_get_pos(io) < dataEndPos) {
int8_t _value = 0;
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) &_value);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &_value);
if(_res != OK) {
return _res;
}
@@ -73,17 +73,17 @@
return OK;
}
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item_serialize(plc4c_spi_write_buffer* buf, plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item* _message) {
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item_serialize(plc4c_spi_write_buffer* io, plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item* _message) {
plc4c_return_code _res = OK;
// Implicit Field (dataLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, (plc4c_spi_evaluation_helper_count(_message->data)) + (1));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, (plc4c_spi_evaluation_helper_count(_message->data)) + (1));
if(_res != OK) {
return _res;
}
// Simple Field (referenceType)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, _message->reference_type);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->reference_type);
if(_res != OK) {
return _res;
}
@@ -94,7 +94,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = (int8_t*) plc4c_utils_list_get_value(_message->data, curItem);
- plc4c_spi_write_signed_byte(buf, 8, *_value);
+ plc4c_spi_write_signed_byte(io, 8, *_value);
}
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_request_item.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_request_item.c
index 1fc51b8..9855f70 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_request_item.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_request_item.c
@@ -23,8 +23,8 @@
// Parse function.
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item_parse(plc4c_spi_read_buffer* buf, plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item_parse(plc4c_spi_read_buffer* io, plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -36,7 +36,7 @@
// Simple Field (referenceType)
uint8_t referenceType = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &referenceType);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &referenceType);
if(_res != OK) {
return _res;
}
@@ -44,7 +44,7 @@
// Simple Field (fileNumber)
uint16_t fileNumber = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &fileNumber);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &fileNumber);
if(_res != OK) {
return _res;
}
@@ -52,7 +52,7 @@
// Simple Field (recordNumber)
uint16_t recordNumber = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &recordNumber);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &recordNumber);
if(_res != OK) {
return _res;
}
@@ -60,7 +60,7 @@
// Implicit Field (recordLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint16_t recordLength = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &recordLength);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &recordLength);
if(_res != OK) {
return _res;
}
@@ -74,10 +74,10 @@
{
// Length array
uint8_t _recordDataLength = (recordLength) * (2);
- uint8_t recordDataEndPos = plc4c_spi_read_get_pos(buf) + _recordDataLength;
- while(plc4c_spi_read_get_pos(buf) < recordDataEndPos) {
+ uint8_t recordDataEndPos = plc4c_spi_read_get_pos(io) + _recordDataLength;
+ while(plc4c_spi_read_get_pos(io) < recordDataEndPos) {
uint16_t _value = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &_value);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &_value);
if(_res != OK) {
return _res;
}
@@ -89,29 +89,29 @@
return OK;
}
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item_serialize(plc4c_spi_write_buffer* buf, plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item* _message) {
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item_serialize(plc4c_spi_write_buffer* io, plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item* _message) {
plc4c_return_code _res = OK;
// Simple Field (referenceType)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, _message->reference_type);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->reference_type);
if(_res != OK) {
return _res;
}
// Simple Field (fileNumber)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->file_number);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->file_number);
if(_res != OK) {
return _res;
}
// Simple Field (recordNumber)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->record_number);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->record_number);
if(_res != OK) {
return _res;
}
// Implicit Field (recordLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_short(buf, 16, (((plc4c_spi_evaluation_helper_count(_message->record_data)) * (2))) / (2));
+ _res = plc4c_spi_write_unsigned_short(io, 16, (((plc4c_spi_evaluation_helper_count(_message->record_data)) * (2))) / (2));
if(_res != OK) {
return _res;
}
@@ -122,7 +122,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
uint16_t* _value = (uint16_t*) plc4c_utils_list_get_value(_message->record_data, curItem);
- plc4c_spi_write_unsigned_short(buf, 16, *_value);
+ plc4c_spi_write_unsigned_short(io, 16, *_value);
}
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_response_item.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_response_item.c
index 3826640..906650e 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_response_item.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_response_item.c
@@ -23,8 +23,8 @@
// Parse function.
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item_parse(plc4c_spi_read_buffer* buf, plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item_parse(plc4c_spi_read_buffer* io, plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -36,7 +36,7 @@
// Simple Field (referenceType)
uint8_t referenceType = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &referenceType);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &referenceType);
if(_res != OK) {
return _res;
}
@@ -44,7 +44,7 @@
// Simple Field (fileNumber)
uint16_t fileNumber = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &fileNumber);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &fileNumber);
if(_res != OK) {
return _res;
}
@@ -52,7 +52,7 @@
// Simple Field (recordNumber)
uint16_t recordNumber = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &recordNumber);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &recordNumber);
if(_res != OK) {
return _res;
}
@@ -60,7 +60,7 @@
// Implicit Field (recordLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint16_t recordLength = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &recordLength);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &recordLength);
if(_res != OK) {
return _res;
}
@@ -74,10 +74,10 @@
{
// Length array
uint8_t _recordDataLength = (recordLength) * (2);
- uint8_t recordDataEndPos = plc4c_spi_read_get_pos(buf) + _recordDataLength;
- while(plc4c_spi_read_get_pos(buf) < recordDataEndPos) {
+ uint8_t recordDataEndPos = plc4c_spi_read_get_pos(io) + _recordDataLength;
+ while(plc4c_spi_read_get_pos(io) < recordDataEndPos) {
uint16_t _value = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &_value);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &_value);
if(_res != OK) {
return _res;
}
@@ -89,29 +89,29 @@
return OK;
}
-plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item_serialize(plc4c_spi_write_buffer* buf, plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item* _message) {
+plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item_serialize(plc4c_spi_write_buffer* io, plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item* _message) {
plc4c_return_code _res = OK;
// Simple Field (referenceType)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, _message->reference_type);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->reference_type);
if(_res != OK) {
return _res;
}
// Simple Field (fileNumber)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->file_number);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->file_number);
if(_res != OK) {
return _res;
}
// Simple Field (recordNumber)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->record_number);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->record_number);
if(_res != OK) {
return _res;
}
// Implicit Field (recordLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_short(buf, 16, (((plc4c_spi_evaluation_helper_count(_message->record_data)) * (2))) / (2));
+ _res = plc4c_spi_write_unsigned_short(io, 16, (((plc4c_spi_evaluation_helper_count(_message->record_data)) * (2))) / (2));
if(_res != OK) {
return _res;
}
@@ -122,7 +122,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
uint16_t* _value = (uint16_t*) plc4c_utils_list_get_value(_message->record_data, curItem);
- plc4c_spi_write_unsigned_short(buf, 16, *_value);
+ plc4c_spi_write_unsigned_short(io, 16, *_value);
}
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_serial_adu.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_serial_adu.c
index a24d383..5cc1a4e 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_serial_adu.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_serial_adu.c
@@ -23,8 +23,8 @@
// Parse function.
-plc4c_return_code plc4c_modbus_read_write_modbus_serial_adu_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_serial_adu** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_modbus_read_write_modbus_serial_adu_parse(plc4c_spi_read_buffer* io, bool response, plc4c_modbus_read_write_modbus_serial_adu** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -36,7 +36,7 @@
// Simple Field (transactionId)
uint16_t transactionId = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &transactionId);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &transactionId);
if(_res != OK) {
return _res;
}
@@ -45,7 +45,7 @@
// Reserved Field (Compartmentalized so the "reserved" variable can't leak)
{
uint16_t _reserved = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &_reserved);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &_reserved);
if(_res != OK) {
return _res;
}
@@ -56,7 +56,7 @@
// Simple Field (length)
uint16_t length = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &length);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &length);
if(_res != OK) {
return _res;
}
@@ -64,7 +64,7 @@
// Simple Field (address)
uint8_t address = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &address);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &address);
if(_res != OK) {
return _res;
}
@@ -72,7 +72,7 @@
// Simple Field (pdu)
plc4c_modbus_read_write_modbus_pdu* pdu;
- _res = plc4c_modbus_read_write_modbus_pdu_parse(buf, response, (void*) &pdu);
+ _res = plc4c_modbus_read_write_modbus_pdu_parse(io, response, (void*) &pdu);
if(_res != OK) {
return _res;
}
@@ -81,35 +81,35 @@
return OK;
}
-plc4c_return_code plc4c_modbus_read_write_modbus_serial_adu_serialize(plc4c_spi_write_buffer* buf, plc4c_modbus_read_write_modbus_serial_adu* _message) {
+plc4c_return_code plc4c_modbus_read_write_modbus_serial_adu_serialize(plc4c_spi_write_buffer* io, plc4c_modbus_read_write_modbus_serial_adu* _message) {
plc4c_return_code _res = OK;
// Simple Field (transactionId)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->transaction_id);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->transaction_id);
if(_res != OK) {
return _res;
}
// Reserved Field
- _res = plc4c_spi_write_unsigned_short(buf, 16, 0x0000);
+ _res = plc4c_spi_write_unsigned_short(io, 16, 0x0000);
if(_res != OK) {
return _res;
}
// Simple Field (length)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->length);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->length);
if(_res != OK) {
return _res;
}
// Simple Field (address)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, _message->address);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->address);
if(_res != OK) {
return _res;
}
// Simple Field (pdu)
- _res = plc4c_modbus_read_write_modbus_pdu_serialize(buf, _message->pdu);
+ _res = plc4c_modbus_read_write_modbus_pdu_serialize(io, _message->pdu);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_tcp_adu.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_tcp_adu.c
index 1060207..77dac92 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_tcp_adu.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_tcp_adu.c
@@ -29,8 +29,8 @@
}
// Parse function.
-plc4c_return_code plc4c_modbus_read_write_modbus_tcp_adu_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_tcp_adu** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_modbus_read_write_modbus_tcp_adu_parse(plc4c_spi_read_buffer* io, bool response, plc4c_modbus_read_write_modbus_tcp_adu** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -42,7 +42,7 @@
// Simple Field (transactionIdentifier)
uint16_t transactionIdentifier = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &transactionIdentifier);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &transactionIdentifier);
if(_res != OK) {
return _res;
}
@@ -50,7 +50,7 @@
// Const Field (protocolIdentifier)
uint16_t protocolIdentifier = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &protocolIdentifier);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &protocolIdentifier);
if(_res != OK) {
return _res;
}
@@ -61,14 +61,14 @@
// Implicit Field (length) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint16_t length = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &length);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &length);
if(_res != OK) {
return _res;
}
// Simple Field (unitIdentifier)
uint8_t unitIdentifier = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &unitIdentifier);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &unitIdentifier);
if(_res != OK) {
return _res;
}
@@ -76,7 +76,7 @@
// Simple Field (pdu)
plc4c_modbus_read_write_modbus_pdu* pdu;
- _res = plc4c_modbus_read_write_modbus_pdu_parse(buf, response, (void*) &pdu);
+ _res = plc4c_modbus_read_write_modbus_pdu_parse(io, response, (void*) &pdu);
if(_res != OK) {
return _res;
}
@@ -85,32 +85,32 @@
return OK;
}
-plc4c_return_code plc4c_modbus_read_write_modbus_tcp_adu_serialize(plc4c_spi_write_buffer* buf, plc4c_modbus_read_write_modbus_tcp_adu* _message) {
+plc4c_return_code plc4c_modbus_read_write_modbus_tcp_adu_serialize(plc4c_spi_write_buffer* io, plc4c_modbus_read_write_modbus_tcp_adu* _message) {
plc4c_return_code _res = OK;
// Simple Field (transactionIdentifier)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->transaction_identifier);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->transaction_identifier);
if(_res != OK) {
return _res;
}
// Const Field (protocolIdentifier)
- plc4c_spi_write_unsigned_short(buf, 16, PLC4C_MODBUS_READ_WRITE_MODBUS_TCP_ADU_PROTOCOL_IDENTIFIER());
+ plc4c_spi_write_unsigned_short(io, 16, PLC4C_MODBUS_READ_WRITE_MODBUS_TCP_ADU_PROTOCOL_IDENTIFIER());
// Implicit Field (length) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_short(buf, 16, (plc4c_modbus_read_write_modbus_pdu_length_in_bytes(_message->pdu)) + (1));
+ _res = plc4c_spi_write_unsigned_short(io, 16, (plc4c_modbus_read_write_modbus_pdu_length_in_bytes(_message->pdu)) + (1));
if(_res != OK) {
return _res;
}
// Simple Field (unitIdentifier)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, _message->unit_identifier);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->unit_identifier);
if(_res != OK) {
return _res;
}
// Simple Field (pdu)
- _res = plc4c_modbus_read_write_modbus_pdu_serialize(buf, _message->pdu);
+ _res = plc4c_modbus_read_write_modbus_pdu_serialize(io, _message->pdu);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/generated-sources/s7/includes/cotp_packet.h b/sandbox/plc4c/generated-sources/s7/include/cotp_packet.h
similarity index 96%
rename from sandbox/plc4c/generated-sources/s7/includes/cotp_packet.h
rename to sandbox/plc4c/generated-sources/s7/include/cotp_packet.h
index d66d287..3df58ae 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/cotp_packet.h
+++ b/sandbox/plc4c/generated-sources/s7/include/cotp_packet.h
@@ -94,9 +94,9 @@
// Create an empty NULL-struct
plc4c_s7_read_write_cotp_packet plc4c_s7_read_write_cotp_packet_null();
-plc4c_return_code plc4c_s7_read_write_cotp_packet_parse(plc4c_spi_read_buffer* buf, uint16_t cotpLen, plc4c_s7_read_write_cotp_packet** message);
+plc4c_return_code plc4c_s7_read_write_cotp_packet_parse(plc4c_spi_read_buffer* io, uint16_t cotpLen, plc4c_s7_read_write_cotp_packet** message);
-plc4c_return_code plc4c_s7_read_write_cotp_packet_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_cotp_packet* message);
+plc4c_return_code plc4c_s7_read_write_cotp_packet_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_cotp_packet* message);
uint16_t plc4c_s7_read_write_cotp_packet_length_in_bytes(plc4c_s7_read_write_cotp_packet* message);
diff --git a/sandbox/plc4c/generated-sources/s7/includes/cotp_parameter.h b/sandbox/plc4c/generated-sources/s7/include/cotp_parameter.h
similarity index 95%
rename from sandbox/plc4c/generated-sources/s7/includes/cotp_parameter.h
rename to sandbox/plc4c/generated-sources/s7/include/cotp_parameter.h
index 2759553..332edac 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/cotp_parameter.h
+++ b/sandbox/plc4c/generated-sources/s7/include/cotp_parameter.h
@@ -77,9 +77,9 @@
// Create an empty NULL-struct
plc4c_s7_read_write_cotp_parameter plc4c_s7_read_write_cotp_parameter_null();
-plc4c_return_code plc4c_s7_read_write_cotp_parameter_parse(plc4c_spi_read_buffer* buf, uint8_t rest, plc4c_s7_read_write_cotp_parameter** message);
+plc4c_return_code plc4c_s7_read_write_cotp_parameter_parse(plc4c_spi_read_buffer* io, uint8_t rest, plc4c_s7_read_write_cotp_parameter** message);
-plc4c_return_code plc4c_s7_read_write_cotp_parameter_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_cotp_parameter* message);
+plc4c_return_code plc4c_s7_read_write_cotp_parameter_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_cotp_parameter* message);
uint16_t plc4c_s7_read_write_cotp_parameter_length_in_bytes(plc4c_s7_read_write_cotp_parameter* message);
diff --git a/sandbox/plc4c/generated-sources/s7/includes/cotp_protocol_class.h b/sandbox/plc4c/generated-sources/s7/include/cotp_protocol_class.h
similarity index 100%
rename from sandbox/plc4c/generated-sources/s7/includes/cotp_protocol_class.h
rename to sandbox/plc4c/generated-sources/s7/include/cotp_protocol_class.h
diff --git a/sandbox/plc4c/generated-sources/s7/includes/cotp_tpdu_size.h b/sandbox/plc4c/generated-sources/s7/include/cotp_tpdu_size.h
similarity index 100%
rename from sandbox/plc4c/generated-sources/s7/includes/cotp_tpdu_size.h
rename to sandbox/plc4c/generated-sources/s7/include/cotp_tpdu_size.h
diff --git a/sandbox/plc4c/generated-sources/s7/include/data_item.h b/sandbox/plc4c/generated-sources/s7/include/data_item.h
new file mode 100644
index 0000000..a0a5fa6
--- /dev/null
+++ b/sandbox/plc4c/generated-sources/s7/include/data_item.h
@@ -0,0 +1,43 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+#ifndef PLC4C_S7_READ_WRITE_DATA_ITEM_H_
+#define PLC4C_S7_READ_WRITE_DATA_ITEM_H_
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <plc4c/spi/read_buffer.h>
+#include <plc4c/spi/write_buffer.h>
+#include <plc4c/utils/list.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+plc4c_return_code plc4c_s7_read_write_data_item_parse(plc4c_spi_read_buffer* buf, uint8_t dataProtocolId, int32_t stringLength, plc4c_data** data_item);
+
+plc4c_return_code plc4c_s7_read_write_data_item_serialize(plc4c_spi_write_buffer* buf, plc4c_data** data_item);
+
+uint16_t plc4c_s7_read_write_data_item_length_in_bytes(plc4c_data* data_item);
+
+uint16_t plc4c_s7_read_write_data_item_length_in_bits(plc4c_data* data_item);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // PLC4C_S7_READ_WRITE_DATA_ITEM_H_
diff --git a/sandbox/plc4c/generated-sources/s7/includes/data_transport_error_code.h b/sandbox/plc4c/generated-sources/s7/include/data_transport_error_code.h
similarity index 100%
rename from sandbox/plc4c/generated-sources/s7/includes/data_transport_error_code.h
rename to sandbox/plc4c/generated-sources/s7/include/data_transport_error_code.h
diff --git a/sandbox/plc4c/generated-sources/s7/includes/data_transport_size.h b/sandbox/plc4c/generated-sources/s7/include/data_transport_size.h
similarity index 100%
rename from sandbox/plc4c/generated-sources/s7/includes/data_transport_size.h
rename to sandbox/plc4c/generated-sources/s7/include/data_transport_size.h
diff --git a/sandbox/plc4c/generated-sources/s7/includes/device_group.h b/sandbox/plc4c/generated-sources/s7/include/device_group.h
similarity index 100%
rename from sandbox/plc4c/generated-sources/s7/includes/device_group.h
rename to sandbox/plc4c/generated-sources/s7/include/device_group.h
diff --git a/sandbox/plc4c/generated-sources/s7/includes/memory_area.h b/sandbox/plc4c/generated-sources/s7/include/memory_area.h
similarity index 100%
rename from sandbox/plc4c/generated-sources/s7/includes/memory_area.h
rename to sandbox/plc4c/generated-sources/s7/include/memory_area.h
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_address.h b/sandbox/plc4c/generated-sources/s7/include/s7_address.h
similarity index 95%
rename from sandbox/plc4c/generated-sources/s7/includes/s7_address.h
rename to sandbox/plc4c/generated-sources/s7/include/s7_address.h
index ff51ecf..6dcad26 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_address.h
+++ b/sandbox/plc4c/generated-sources/s7/include/s7_address.h
@@ -67,9 +67,9 @@
// Create an empty NULL-struct
plc4c_s7_read_write_s7_address plc4c_s7_read_write_s7_address_null();
-plc4c_return_code plc4c_s7_read_write_s7_address_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_s7_address** message);
+plc4c_return_code plc4c_s7_read_write_s7_address_parse(plc4c_spi_read_buffer* io, plc4c_s7_read_write_s7_address** message);
-plc4c_return_code plc4c_s7_read_write_s7_address_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_address* message);
+plc4c_return_code plc4c_s7_read_write_s7_address_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_s7_address* message);
uint16_t plc4c_s7_read_write_s7_address_length_in_bytes(plc4c_s7_read_write_s7_address* message);
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_message.h b/sandbox/plc4c/generated-sources/s7/include/s7_message.h
similarity index 96%
rename from sandbox/plc4c/generated-sources/s7/includes/s7_message.h
rename to sandbox/plc4c/generated-sources/s7/include/s7_message.h
index ce2d9c5..a27d8ff 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_message.h
+++ b/sandbox/plc4c/generated-sources/s7/include/s7_message.h
@@ -81,9 +81,9 @@
// Create an empty NULL-struct
plc4c_s7_read_write_s7_message plc4c_s7_read_write_s7_message_null();
-plc4c_return_code plc4c_s7_read_write_s7_message_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_s7_message** message);
+plc4c_return_code plc4c_s7_read_write_s7_message_parse(plc4c_spi_read_buffer* io, plc4c_s7_read_write_s7_message** message);
-plc4c_return_code plc4c_s7_read_write_s7_message_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_message* message);
+plc4c_return_code plc4c_s7_read_write_s7_message_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_s7_message* message);
uint16_t plc4c_s7_read_write_s7_message_length_in_bytes(plc4c_s7_read_write_s7_message* message);
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_parameter.h b/sandbox/plc4c/generated-sources/s7/include/s7_parameter.h
similarity index 96%
rename from sandbox/plc4c/generated-sources/s7/includes/s7_parameter.h
rename to sandbox/plc4c/generated-sources/s7/include/s7_parameter.h
index 6f42b4f..d601ba0 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_parameter.h
+++ b/sandbox/plc4c/generated-sources/s7/include/s7_parameter.h
@@ -85,9 +85,9 @@
// Create an empty NULL-struct
plc4c_s7_read_write_s7_parameter plc4c_s7_read_write_s7_parameter_null();
-plc4c_return_code plc4c_s7_read_write_s7_parameter_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter** message);
+plc4c_return_code plc4c_s7_read_write_s7_parameter_parse(plc4c_spi_read_buffer* io, uint8_t messageType, plc4c_s7_read_write_s7_parameter** message);
-plc4c_return_code plc4c_s7_read_write_s7_parameter_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_parameter* message);
+plc4c_return_code plc4c_s7_read_write_s7_parameter_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_s7_parameter* message);
uint16_t plc4c_s7_read_write_s7_parameter_length_in_bytes(plc4c_s7_read_write_s7_parameter* message);
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_parameter_user_data_item.h b/sandbox/plc4c/generated-sources/s7/include/s7_parameter_user_data_item.h
similarity index 94%
rename from sandbox/plc4c/generated-sources/s7/includes/s7_parameter_user_data_item.h
rename to sandbox/plc4c/generated-sources/s7/include/s7_parameter_user_data_item.h
index a3a5481..b0114c3 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_parameter_user_data_item.h
+++ b/sandbox/plc4c/generated-sources/s7/include/s7_parameter_user_data_item.h
@@ -67,9 +67,9 @@
// Create an empty NULL-struct
plc4c_s7_read_write_s7_parameter_user_data_item plc4c_s7_read_write_s7_parameter_user_data_item_null();
-plc4c_return_code plc4c_s7_read_write_s7_parameter_user_data_item_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_s7_parameter_user_data_item** message);
+plc4c_return_code plc4c_s7_read_write_s7_parameter_user_data_item_parse(plc4c_spi_read_buffer* io, plc4c_s7_read_write_s7_parameter_user_data_item** message);
-plc4c_return_code plc4c_s7_read_write_s7_parameter_user_data_item_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_parameter_user_data_item* message);
+plc4c_return_code plc4c_s7_read_write_s7_parameter_user_data_item_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_s7_parameter_user_data_item* message);
uint16_t plc4c_s7_read_write_s7_parameter_user_data_item_length_in_bytes(plc4c_s7_read_write_s7_parameter_user_data_item* message);
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_payload.h b/sandbox/plc4c/generated-sources/s7/include/s7_payload.h
similarity index 94%
rename from sandbox/plc4c/generated-sources/s7/includes/s7_payload.h
rename to sandbox/plc4c/generated-sources/s7/include/s7_payload.h
index 297e7ad..26291f4 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_payload.h
+++ b/sandbox/plc4c/generated-sources/s7/include/s7_payload.h
@@ -77,9 +77,9 @@
// Create an empty NULL-struct
plc4c_s7_read_write_s7_payload plc4c_s7_read_write_s7_payload_null();
-plc4c_return_code plc4c_s7_read_write_s7_payload_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter* parameter, plc4c_s7_read_write_s7_payload** message);
+plc4c_return_code plc4c_s7_read_write_s7_payload_parse(plc4c_spi_read_buffer* io, uint8_t messageType, plc4c_s7_read_write_s7_parameter* parameter, plc4c_s7_read_write_s7_payload** message);
-plc4c_return_code plc4c_s7_read_write_s7_payload_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_payload* message);
+plc4c_return_code plc4c_s7_read_write_s7_payload_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_s7_payload* message);
uint16_t plc4c_s7_read_write_s7_payload_length_in_bytes(plc4c_s7_read_write_s7_payload* message);
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_payload_user_data_item.h b/sandbox/plc4c/generated-sources/s7/include/s7_payload_user_data_item.h
similarity index 94%
rename from sandbox/plc4c/generated-sources/s7/includes/s7_payload_user_data_item.h
rename to sandbox/plc4c/generated-sources/s7/include/s7_payload_user_data_item.h
index 5900576..5bd980b 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_payload_user_data_item.h
+++ b/sandbox/plc4c/generated-sources/s7/include/s7_payload_user_data_item.h
@@ -74,9 +74,9 @@
// Create an empty NULL-struct
plc4c_s7_read_write_s7_payload_user_data_item plc4c_s7_read_write_s7_payload_user_data_item_null();
-plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_item_parse(plc4c_spi_read_buffer* buf, unsigned int cpuFunctionType, plc4c_s7_read_write_s7_payload_user_data_item** message);
+plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_item_parse(plc4c_spi_read_buffer* io, unsigned int cpuFunctionType, plc4c_s7_read_write_s7_payload_user_data_item** message);
-plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_item_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_payload_user_data_item* message);
+plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_item_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_s7_payload_user_data_item* message);
uint16_t plc4c_s7_read_write_s7_payload_user_data_item_length_in_bytes(plc4c_s7_read_write_s7_payload_user_data_item* message);
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_var_payload_data_item.h b/sandbox/plc4c/generated-sources/s7/include/s7_var_payload_data_item.h
similarity index 90%
rename from sandbox/plc4c/generated-sources/s7/includes/s7_var_payload_data_item.h
rename to sandbox/plc4c/generated-sources/s7/include/s7_var_payload_data_item.h
index 6181a4c..a7497f1 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_var_payload_data_item.h
+++ b/sandbox/plc4c/generated-sources/s7/include/s7_var_payload_data_item.h
@@ -43,9 +43,9 @@
// Create an empty NULL-struct
plc4c_s7_read_write_s7_var_payload_data_item plc4c_s7_read_write_s7_var_payload_data_item_null();
-plc4c_return_code plc4c_s7_read_write_s7_var_payload_data_item_parse(plc4c_spi_read_buffer* buf, bool lastItem, plc4c_s7_read_write_s7_var_payload_data_item** message);
+plc4c_return_code plc4c_s7_read_write_s7_var_payload_data_item_parse(plc4c_spi_read_buffer* io, bool lastItem, plc4c_s7_read_write_s7_var_payload_data_item** message);
-plc4c_return_code plc4c_s7_read_write_s7_var_payload_data_item_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_var_payload_data_item* message, bool lastItem);
+plc4c_return_code plc4c_s7_read_write_s7_var_payload_data_item_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_s7_var_payload_data_item* message, bool lastItem);
uint16_t plc4c_s7_read_write_s7_var_payload_data_item_length_in_bytes(plc4c_s7_read_write_s7_var_payload_data_item* message);
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_var_payload_status_item.h b/sandbox/plc4c/generated-sources/s7/include/s7_var_payload_status_item.h
similarity index 91%
rename from sandbox/plc4c/generated-sources/s7/includes/s7_var_payload_status_item.h
rename to sandbox/plc4c/generated-sources/s7/include/s7_var_payload_status_item.h
index a8b9dab..fd8573d 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_var_payload_status_item.h
+++ b/sandbox/plc4c/generated-sources/s7/include/s7_var_payload_status_item.h
@@ -40,9 +40,9 @@
// Create an empty NULL-struct
plc4c_s7_read_write_s7_var_payload_status_item plc4c_s7_read_write_s7_var_payload_status_item_null();
-plc4c_return_code plc4c_s7_read_write_s7_var_payload_status_item_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_s7_var_payload_status_item** message);
+plc4c_return_code plc4c_s7_read_write_s7_var_payload_status_item_parse(plc4c_spi_read_buffer* io, plc4c_s7_read_write_s7_var_payload_status_item** message);
-plc4c_return_code plc4c_s7_read_write_s7_var_payload_status_item_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_var_payload_status_item* message);
+plc4c_return_code plc4c_s7_read_write_s7_var_payload_status_item_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_s7_var_payload_status_item* message);
uint16_t plc4c_s7_read_write_s7_var_payload_status_item_length_in_bytes(plc4c_s7_read_write_s7_var_payload_status_item* message);
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_var_request_parameter_item.h b/sandbox/plc4c/generated-sources/s7/include/s7_var_request_parameter_item.h
similarity index 93%
rename from sandbox/plc4c/generated-sources/s7/includes/s7_var_request_parameter_item.h
rename to sandbox/plc4c/generated-sources/s7/include/s7_var_request_parameter_item.h
index 9e3a4e1..102c330 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_var_request_parameter_item.h
+++ b/sandbox/plc4c/generated-sources/s7/include/s7_var_request_parameter_item.h
@@ -61,9 +61,9 @@
// Create an empty NULL-struct
plc4c_s7_read_write_s7_var_request_parameter_item plc4c_s7_read_write_s7_var_request_parameter_item_null();
-plc4c_return_code plc4c_s7_read_write_s7_var_request_parameter_item_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_s7_var_request_parameter_item** message);
+plc4c_return_code plc4c_s7_read_write_s7_var_request_parameter_item_parse(plc4c_spi_read_buffer* io, plc4c_s7_read_write_s7_var_request_parameter_item** message);
-plc4c_return_code plc4c_s7_read_write_s7_var_request_parameter_item_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_var_request_parameter_item* message);
+plc4c_return_code plc4c_s7_read_write_s7_var_request_parameter_item_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_s7_var_request_parameter_item* message);
uint16_t plc4c_s7_read_write_s7_var_request_parameter_item_length_in_bytes(plc4c_s7_read_write_s7_var_request_parameter_item* message);
diff --git a/sandbox/plc4c/generated-sources/s7/includes/szl_data_tree_item.h b/sandbox/plc4c/generated-sources/s7/include/szl_data_tree_item.h
similarity index 92%
rename from sandbox/plc4c/generated-sources/s7/includes/szl_data_tree_item.h
rename to sandbox/plc4c/generated-sources/s7/include/szl_data_tree_item.h
index eff888d..9213328 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/szl_data_tree_item.h
+++ b/sandbox/plc4c/generated-sources/s7/include/szl_data_tree_item.h
@@ -43,9 +43,9 @@
// Create an empty NULL-struct
plc4c_s7_read_write_szl_data_tree_item plc4c_s7_read_write_szl_data_tree_item_null();
-plc4c_return_code plc4c_s7_read_write_szl_data_tree_item_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_szl_data_tree_item** message);
+plc4c_return_code plc4c_s7_read_write_szl_data_tree_item_parse(plc4c_spi_read_buffer* io, plc4c_s7_read_write_szl_data_tree_item** message);
-plc4c_return_code plc4c_s7_read_write_szl_data_tree_item_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_szl_data_tree_item* message);
+plc4c_return_code plc4c_s7_read_write_szl_data_tree_item_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_szl_data_tree_item* message);
uint16_t plc4c_s7_read_write_szl_data_tree_item_length_in_bytes(plc4c_s7_read_write_szl_data_tree_item* message);
diff --git a/sandbox/plc4c/generated-sources/s7/includes/szl_id.h b/sandbox/plc4c/generated-sources/s7/include/szl_id.h
similarity index 94%
rename from sandbox/plc4c/generated-sources/s7/includes/szl_id.h
rename to sandbox/plc4c/generated-sources/s7/include/szl_id.h
index d885067..db0486b 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/szl_id.h
+++ b/sandbox/plc4c/generated-sources/s7/include/szl_id.h
@@ -43,9 +43,9 @@
// Create an empty NULL-struct
plc4c_s7_read_write_szl_id plc4c_s7_read_write_szl_id_null();
-plc4c_return_code plc4c_s7_read_write_szl_id_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_szl_id** message);
+plc4c_return_code plc4c_s7_read_write_szl_id_parse(plc4c_spi_read_buffer* io, plc4c_s7_read_write_szl_id** message);
-plc4c_return_code plc4c_s7_read_write_szl_id_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_szl_id* message);
+plc4c_return_code plc4c_s7_read_write_szl_id_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_szl_id* message);
uint16_t plc4c_s7_read_write_szl_id_length_in_bytes(plc4c_s7_read_write_szl_id* message);
diff --git a/sandbox/plc4c/generated-sources/s7/includes/szl_module_type_class.h b/sandbox/plc4c/generated-sources/s7/include/szl_module_type_class.h
similarity index 100%
rename from sandbox/plc4c/generated-sources/s7/includes/szl_module_type_class.h
rename to sandbox/plc4c/generated-sources/s7/include/szl_module_type_class.h
diff --git a/sandbox/plc4c/generated-sources/s7/includes/szl_sublist.h b/sandbox/plc4c/generated-sources/s7/include/szl_sublist.h
similarity index 100%
rename from sandbox/plc4c/generated-sources/s7/includes/szl_sublist.h
rename to sandbox/plc4c/generated-sources/s7/include/szl_sublist.h
diff --git a/sandbox/plc4c/generated-sources/s7/includes/tpkt_packet.h b/sandbox/plc4c/generated-sources/s7/include/tpkt_packet.h
similarity index 93%
rename from sandbox/plc4c/generated-sources/s7/includes/tpkt_packet.h
rename to sandbox/plc4c/generated-sources/s7/include/tpkt_packet.h
index 34677c9..b11f507 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/tpkt_packet.h
+++ b/sandbox/plc4c/generated-sources/s7/include/tpkt_packet.h
@@ -44,9 +44,9 @@
// Create an empty NULL-struct
plc4c_s7_read_write_tpkt_packet plc4c_s7_read_write_tpkt_packet_null();
-plc4c_return_code plc4c_s7_read_write_tpkt_packet_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_tpkt_packet** message);
+plc4c_return_code plc4c_s7_read_write_tpkt_packet_parse(plc4c_spi_read_buffer* io, plc4c_s7_read_write_tpkt_packet** message);
-plc4c_return_code plc4c_s7_read_write_tpkt_packet_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_tpkt_packet* message);
+plc4c_return_code plc4c_s7_read_write_tpkt_packet_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_tpkt_packet* message);
uint16_t plc4c_s7_read_write_tpkt_packet_length_in_bytes(plc4c_s7_read_write_tpkt_packet* message);
diff --git a/sandbox/plc4c/generated-sources/s7/includes/transport_size.h b/sandbox/plc4c/generated-sources/s7/include/transport_size.h
similarity index 100%
rename from sandbox/plc4c/generated-sources/s7/includes/transport_size.h
rename to sandbox/plc4c/generated-sources/s7/include/transport_size.h
diff --git a/sandbox/plc4c/generated-sources/s7/src/cotp_packet.c b/sandbox/plc4c/generated-sources/s7/src/cotp_packet.c
index a57dbf2..54684b0 100644
--- a/sandbox/plc4c/generated-sources/s7/src/cotp_packet.c
+++ b/sandbox/plc4c/generated-sources/s7/src/cotp_packet.c
@@ -53,8 +53,8 @@
// Parse function.
-plc4c_return_code plc4c_s7_read_write_cotp_packet_parse(plc4c_spi_read_buffer* buf, uint16_t cotpLen, plc4c_s7_read_write_cotp_packet** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_s7_read_write_cotp_packet_parse(plc4c_spi_read_buffer* io, uint16_t cotpLen, plc4c_s7_read_write_cotp_packet** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -66,14 +66,14 @@
// Implicit Field (headerLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t headerLength = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &headerLength);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &headerLength);
if(_res != OK) {
return _res;
}
// Discriminator Field (tpduCode) (Used as input to a switch field)
uint8_t tpduCode = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &tpduCode);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &tpduCode);
if(_res != OK) {
return _res;
}
@@ -84,7 +84,7 @@
// Simple Field (eot)
bool eot = false;
- _res = plc4c_spi_read_bit(buf, (bool*) &eot);
+ _res = plc4c_spi_read_bit(io, (bool*) &eot);
if(_res != OK) {
return _res;
}
@@ -94,7 +94,7 @@
// Simple Field (tpduRef)
unsigned int tpduRef = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 7, (uint8_t*) &tpduRef);
+ _res = plc4c_spi_read_unsigned_byte(io, 7, (uint8_t*) &tpduRef);
if(_res != OK) {
return _res;
}
@@ -106,7 +106,7 @@
// Simple Field (destinationReference)
uint16_t destinationReference = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &destinationReference);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &destinationReference);
if(_res != OK) {
return _res;
}
@@ -116,7 +116,7 @@
// Simple Field (sourceReference)
uint16_t sourceReference = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &sourceReference);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &sourceReference);
if(_res != OK) {
return _res;
}
@@ -126,7 +126,7 @@
// Enum field (protocolClass)
plc4c_s7_read_write_cotp_protocol_class protocolClass = plc4c_s7_read_write_cotp_protocol_class_null();
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) &protocolClass);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &protocolClass);
if(_res != OK) {
return _res;
}
@@ -138,7 +138,7 @@
// Simple Field (destinationReference)
uint16_t destinationReference = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &destinationReference);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &destinationReference);
if(_res != OK) {
return _res;
}
@@ -148,7 +148,7 @@
// Simple Field (sourceReference)
uint16_t sourceReference = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &sourceReference);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &sourceReference);
if(_res != OK) {
return _res;
}
@@ -158,7 +158,7 @@
// Enum field (protocolClass)
plc4c_s7_read_write_cotp_protocol_class protocolClass = plc4c_s7_read_write_cotp_protocol_class_null();
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) &protocolClass);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &protocolClass);
if(_res != OK) {
return _res;
}
@@ -170,7 +170,7 @@
// Simple Field (destinationReference)
uint16_t destinationReference = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &destinationReference);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &destinationReference);
if(_res != OK) {
return _res;
}
@@ -180,7 +180,7 @@
// Simple Field (sourceReference)
uint16_t sourceReference = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &sourceReference);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &sourceReference);
if(_res != OK) {
return _res;
}
@@ -190,7 +190,7 @@
// Enum field (protocolClass)
plc4c_s7_read_write_cotp_protocol_class protocolClass = plc4c_s7_read_write_cotp_protocol_class_null();
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) &protocolClass);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &protocolClass);
if(_res != OK) {
return _res;
}
@@ -202,7 +202,7 @@
// Simple Field (destinationReference)
uint16_t destinationReference = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &destinationReference);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &destinationReference);
if(_res != OK) {
return _res;
}
@@ -212,7 +212,7 @@
// Simple Field (sourceReference)
uint16_t sourceReference = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &sourceReference);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &sourceReference);
if(_res != OK) {
return _res;
}
@@ -224,7 +224,7 @@
// Simple Field (destinationReference)
uint16_t destinationReference = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &destinationReference);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &destinationReference);
if(_res != OK) {
return _res;
}
@@ -234,7 +234,7 @@
// Simple Field (rejectCause)
uint8_t rejectCause = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &rejectCause);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &rejectCause);
if(_res != OK) {
return _res;
}
@@ -243,7 +243,7 @@
}
// Array field (parameters)
- curPos = plc4c_spi_read_get_pos(buf) - startPos;
+ curPos = plc4c_spi_read_get_pos(io) - startPos;
plc4c_list* parameters = NULL;
plc4c_utils_list_create(¶meters);
if(parameters == NULL) {
@@ -252,28 +252,28 @@
{
// Length array
uint8_t _parametersLength = (((headerLength) + (1))) - (curPos);
- uint8_t parametersEndPos = plc4c_spi_read_get_pos(buf) + _parametersLength;
- while(plc4c_spi_read_get_pos(buf) < parametersEndPos) {
+ uint8_t parametersEndPos = plc4c_spi_read_get_pos(io) + _parametersLength;
+ while(plc4c_spi_read_get_pos(io) < parametersEndPos) {
plc4c_s7_read_write_cotp_parameter* _value = NULL;
- _res = plc4c_s7_read_write_cotp_parameter_parse(buf, (((headerLength) + (1))) - (curPos), (void*) &_value);
+ _res = plc4c_s7_read_write_cotp_parameter_parse(io, (((headerLength) + (1))) - (curPos), (void*) &_value);
if(_res != OK) {
return _res;
}
plc4c_utils_list_insert_head_value(parameters, _value);
- curPos = plc4c_spi_read_get_pos(buf) - startPos;
+ curPos = plc4c_spi_read_get_pos(io) - startPos;
}
}
(*_message)->parameters = parameters;
// Optional Field (payload) (Can be skipped, if a given expression evaluates to false)
- curPos = plc4c_spi_read_get_pos(buf) - startPos;
+ curPos = plc4c_spi_read_get_pos(io) - startPos;
plc4c_s7_read_write_s7_message* payload = NULL;
if((curPos) < (cotpLen)) {
payload = malloc(sizeof(plc4c_s7_read_write_s7_message));
if(payload == NULL) {
return NO_MEMORY;
}
- _res = plc4c_s7_read_write_s7_message_parse(buf, &payload);
+ _res = plc4c_s7_read_write_s7_message_parse(io, &payload);
if(_res != OK) {
return _res;
}
@@ -285,30 +285,30 @@
return OK;
}
-plc4c_return_code plc4c_s7_read_write_cotp_packet_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_cotp_packet* _message) {
+plc4c_return_code plc4c_s7_read_write_cotp_packet_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_cotp_packet* _message) {
plc4c_return_code _res = OK;
// Implicit Field (headerLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, (plc4c_s7_read_write_cotp_packet_length_in_bytes(_message)) - ((((((((_message->payload) != (NULL))) ? plc4c_s7_read_write_s7_message_length_in_bytes(_message->payload) : 0))) + (1))));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, (plc4c_s7_read_write_cotp_packet_length_in_bytes(_message)) - ((((((((_message->payload) != (NULL))) ? plc4c_s7_read_write_s7_message_length_in_bytes(_message->payload) : 0))) + (1))));
if(_res != OK) {
return _res;
}
// Discriminator Field (tpduCode)
- plc4c_spi_write_unsigned_byte(buf, 8, plc4c_s7_read_write_cotp_packet_get_discriminator(_message->_type).tpduCode);
+ plc4c_spi_write_unsigned_byte(io, 8, plc4c_s7_read_write_cotp_packet_get_discriminator(_message->_type).tpduCode);
// Switch Field (Depending of the current type, serialize the sub-type elements)
switch(_message->_type) {
case plc4c_s7_read_write_cotp_packet_type_plc4c_s7_read_write_cotp_packet_data: {
// Simple Field (eot)
- _res = plc4c_spi_write_bit(buf, _message->cotp_packet_data_eot);
+ _res = plc4c_spi_write_bit(io, _message->cotp_packet_data_eot);
if(_res != OK) {
return _res;
}
// Simple Field (tpduRef)
- _res = plc4c_spi_write_unsigned_byte(buf, 7, _message->cotp_packet_data_tpdu_ref);
+ _res = plc4c_spi_write_unsigned_byte(io, 7, _message->cotp_packet_data_tpdu_ref);
if(_res != OK) {
return _res;
}
@@ -318,19 +318,19 @@
case plc4c_s7_read_write_cotp_packet_type_plc4c_s7_read_write_cotp_packet_connection_request: {
// Simple Field (destinationReference)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->cotp_packet_connection_request_destination_reference);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->cotp_packet_connection_request_destination_reference);
if(_res != OK) {
return _res;
}
// Simple Field (sourceReference)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->cotp_packet_connection_request_source_reference);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->cotp_packet_connection_request_source_reference);
if(_res != OK) {
return _res;
}
// Enum field (protocolClass)
- _res = plc4c_spi_write_signed_byte(buf, 8, _message->cotp_packet_connection_request_protocol_class);
+ _res = plc4c_spi_write_signed_byte(io, 8, _message->cotp_packet_connection_request_protocol_class);
if(_res != OK) {
return _res;
}
@@ -340,19 +340,19 @@
case plc4c_s7_read_write_cotp_packet_type_plc4c_s7_read_write_cotp_packet_connection_response: {
// Simple Field (destinationReference)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->cotp_packet_connection_response_destination_reference);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->cotp_packet_connection_response_destination_reference);
if(_res != OK) {
return _res;
}
// Simple Field (sourceReference)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->cotp_packet_connection_response_source_reference);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->cotp_packet_connection_response_source_reference);
if(_res != OK) {
return _res;
}
// Enum field (protocolClass)
- _res = plc4c_spi_write_signed_byte(buf, 8, _message->cotp_packet_connection_response_protocol_class);
+ _res = plc4c_spi_write_signed_byte(io, 8, _message->cotp_packet_connection_response_protocol_class);
if(_res != OK) {
return _res;
}
@@ -362,19 +362,19 @@
case plc4c_s7_read_write_cotp_packet_type_plc4c_s7_read_write_cotp_packet_disconnect_request: {
// Simple Field (destinationReference)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->cotp_packet_disconnect_request_destination_reference);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->cotp_packet_disconnect_request_destination_reference);
if(_res != OK) {
return _res;
}
// Simple Field (sourceReference)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->cotp_packet_disconnect_request_source_reference);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->cotp_packet_disconnect_request_source_reference);
if(_res != OK) {
return _res;
}
// Enum field (protocolClass)
- _res = plc4c_spi_write_signed_byte(buf, 8, _message->cotp_packet_disconnect_request_protocol_class);
+ _res = plc4c_spi_write_signed_byte(io, 8, _message->cotp_packet_disconnect_request_protocol_class);
if(_res != OK) {
return _res;
}
@@ -384,13 +384,13 @@
case plc4c_s7_read_write_cotp_packet_type_plc4c_s7_read_write_cotp_packet_disconnect_response: {
// Simple Field (destinationReference)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->cotp_packet_disconnect_response_destination_reference);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->cotp_packet_disconnect_response_destination_reference);
if(_res != OK) {
return _res;
}
// Simple Field (sourceReference)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->cotp_packet_disconnect_response_source_reference);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->cotp_packet_disconnect_response_source_reference);
if(_res != OK) {
return _res;
}
@@ -400,13 +400,13 @@
case plc4c_s7_read_write_cotp_packet_type_plc4c_s7_read_write_cotp_packet_tpdu_error: {
// Simple Field (destinationReference)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->cotp_packet_tpdu_error_destination_reference);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->cotp_packet_tpdu_error_destination_reference);
if(_res != OK) {
return _res;
}
// Simple Field (rejectCause)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, _message->cotp_packet_tpdu_error_reject_cause);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->cotp_packet_tpdu_error_reject_cause);
if(_res != OK) {
return _res;
}
@@ -421,7 +421,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_s7_read_write_cotp_parameter* _value = (plc4c_s7_read_write_cotp_parameter*) plc4c_utils_list_get_value(_message->parameters, curItem);
- _res = plc4c_s7_read_write_cotp_parameter_serialize(buf, (void*) _value);
+ _res = plc4c_s7_read_write_cotp_parameter_serialize(io, (void*) _value);
if(_res != OK) {
return _res;
}
@@ -430,7 +430,7 @@
// Optional Field (payload)
if(_message->payload != NULL) {
- _res = plc4c_s7_read_write_s7_message_serialize(buf, _message->payload);
+ _res = plc4c_s7_read_write_s7_message_serialize(io, _message->payload);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/cotp_parameter.c b/sandbox/plc4c/generated-sources/s7/src/cotp_parameter.c
index cad3703..88057b2 100644
--- a/sandbox/plc4c/generated-sources/s7/src/cotp_parameter.c
+++ b/sandbox/plc4c/generated-sources/s7/src/cotp_parameter.c
@@ -51,8 +51,8 @@
// Parse function.
-plc4c_return_code plc4c_s7_read_write_cotp_parameter_parse(plc4c_spi_read_buffer* buf, uint8_t rest, plc4c_s7_read_write_cotp_parameter** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_s7_read_write_cotp_parameter_parse(plc4c_spi_read_buffer* io, uint8_t rest, plc4c_s7_read_write_cotp_parameter** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -64,14 +64,14 @@
// Discriminator Field (parameterType) (Used as input to a switch field)
uint8_t parameterType = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) ¶meterType);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) ¶meterType);
if(_res != OK) {
return _res;
}
// Implicit Field (parameterLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t parameterLength = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) ¶meterLength);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) ¶meterLength);
if(_res != OK) {
return _res;
}
@@ -82,7 +82,7 @@
// Enum field (tpduSize)
plc4c_s7_read_write_cotp_tpdu_size tpduSize = plc4c_s7_read_write_cotp_tpdu_size_null();
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) &tpduSize);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &tpduSize);
if(_res != OK) {
return _res;
}
@@ -94,7 +94,7 @@
// Simple Field (tsapId)
uint16_t tsapId = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &tsapId);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &tsapId);
if(_res != OK) {
return _res;
}
@@ -106,7 +106,7 @@
// Simple Field (tsapId)
uint16_t tsapId = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &tsapId);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &tsapId);
if(_res != OK) {
return _res;
}
@@ -118,7 +118,7 @@
// Simple Field (crc)
uint8_t crc = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &crc);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &crc);
if(_res != OK) {
return _res;
}
@@ -140,7 +140,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
uint8_t* _value = malloc(sizeof(uint8_t));
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) _value);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) _value);
if(_res != OK) {
return _res;
}
@@ -154,14 +154,14 @@
return OK;
}
-plc4c_return_code plc4c_s7_read_write_cotp_parameter_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_cotp_parameter* _message) {
+plc4c_return_code plc4c_s7_read_write_cotp_parameter_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_cotp_parameter* _message) {
plc4c_return_code _res = OK;
// Discriminator Field (parameterType)
- plc4c_spi_write_unsigned_byte(buf, 8, plc4c_s7_read_write_cotp_parameter_get_discriminator(_message->_type).parameterType);
+ plc4c_spi_write_unsigned_byte(io, 8, plc4c_s7_read_write_cotp_parameter_get_discriminator(_message->_type).parameterType);
// Implicit Field (parameterLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, (plc4c_s7_read_write_cotp_parameter_length_in_bytes(_message)) - (2));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, (plc4c_s7_read_write_cotp_parameter_length_in_bytes(_message)) - (2));
if(_res != OK) {
return _res;
}
@@ -171,7 +171,7 @@
case plc4c_s7_read_write_cotp_parameter_type_plc4c_s7_read_write_cotp_parameter_tpdu_size: {
// Enum field (tpduSize)
- _res = plc4c_spi_write_signed_byte(buf, 8, _message->cotp_parameter_tpdu_size_tpdu_size);
+ _res = plc4c_spi_write_signed_byte(io, 8, _message->cotp_parameter_tpdu_size_tpdu_size);
if(_res != OK) {
return _res;
}
@@ -181,7 +181,7 @@
case plc4c_s7_read_write_cotp_parameter_type_plc4c_s7_read_write_cotp_parameter_calling_tsap: {
// Simple Field (tsapId)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->cotp_parameter_calling_tsap_tsap_id);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->cotp_parameter_calling_tsap_tsap_id);
if(_res != OK) {
return _res;
}
@@ -191,7 +191,7 @@
case plc4c_s7_read_write_cotp_parameter_type_plc4c_s7_read_write_cotp_parameter_called_tsap: {
// Simple Field (tsapId)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->cotp_parameter_called_tsap_tsap_id);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->cotp_parameter_called_tsap_tsap_id);
if(_res != OK) {
return _res;
}
@@ -201,7 +201,7 @@
case plc4c_s7_read_write_cotp_parameter_type_plc4c_s7_read_write_cotp_parameter_checksum: {
// Simple Field (crc)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, _message->cotp_parameter_checksum_crc);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->cotp_parameter_checksum_crc);
if(_res != OK) {
return _res;
}
@@ -216,7 +216,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
uint8_t* _value = (uint8_t*) plc4c_utils_list_get_value(_message->cotp_parameter_disconnect_additional_information_data, curItem);
- plc4c_spi_write_unsigned_byte(buf, 8, *_value);
+ plc4c_spi_write_unsigned_byte(io, 8, *_value);
}
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/data_item.c b/sandbox/plc4c/generated-sources/s7/src/data_item.c
new file mode 100644
index 0000000..1d0f20d
--- /dev/null
+++ b/sandbox/plc4c/generated-sources/s7/src/data_item.c
@@ -0,0 +1,256 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+#include <stdio.h>
+#include <time.h>
+#include <plc4c/data.h>
+#include <plc4c/spi/evaluation_helper.h>
+#include <plc4c/driver_s7.h>
+#include "data_item.h"
+
+// Parse function.
+plc4c_return_code plc4c_s7_read_write_data_item_parse(plc4c_spi_read_buffer* io, uint8_t dataProtocolId, int32_t stringLength, plc4c_data** data_item) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
+ uint16_t curPos;
+ plc4c_return_code _res = OK;
+
+ if(dataProtocolId == 01) { /* Boolean */
+
+ // Reserved Field (Compartmentalized so the "reserved" variable can't leak)
+ {
+ unsigned int _reserved = 0;
+ _res = plc4c_spi_read_unsigned_byte(io, 7, (uint8_t*) &_reserved);
+ if(_res != OK) {
+ return _res;
+ }
+ if(_reserved != 0x00) {
+ printf("Expected constant value '%d' but got '%d' for reserved field.", 0x00, _reserved);
+ }
+ }
+
+ // Simple Field (value)
+ bool value = false;
+ _res = plc4c_spi_read_bit(io, (bool*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_bool_data(value);
+
+ } else
+ if(dataProtocolId == 11) { /* List */
+
+ // Array field (value)
+ } else
+ if(dataProtocolId == 12) { /* List */
+
+ // Array field (value)
+ } else
+ if(dataProtocolId == 13) { /* List */
+
+ // Array field (value)
+ } else
+ if(dataProtocolId == 14) { /* List */
+
+ // Array field (value)
+ } else
+ if(dataProtocolId == 21) { /* Integer */
+
+ // Simple Field (value)
+ int8_t value = 0;
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_int8_t_data(value);
+
+ } else
+ if(dataProtocolId == 22) { /* Integer */
+
+ // Simple Field (value)
+ uint8_t value = 0;
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_uint8_t_data(value);
+
+ } else
+ if(dataProtocolId == 23) { /* Integer */
+
+ // Simple Field (value)
+ int16_t value = 0;
+ _res = plc4c_spi_read_signed_short(io, 16, (int16_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_int16_t_data(value);
+
+ } else
+ if(dataProtocolId == 24) { /* Integer */
+
+ // Simple Field (value)
+ uint16_t value = 0;
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_uint16_t_data(value);
+
+ } else
+ if(dataProtocolId == 25) { /* Integer */
+
+ // Simple Field (value)
+ int32_t value = 0;
+ _res = plc4c_spi_read_signed_int(io, 32, (int32_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_int32_t_data(value);
+
+ } else
+ if(dataProtocolId == 26) { /* Long */
+
+ // Simple Field (value)
+ uint32_t value = 0;
+ _res = plc4c_spi_read_unsigned_int(io, 32, (uint32_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_uint32_t_data(value);
+
+ } else
+ if(dataProtocolId == 27) { /* Long */
+
+ // Simple Field (value)
+ int64_t value = 0;
+ _res = plc4c_spi_read_signed_long(io, 64, (int64_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_int64_t_data(value);
+
+ } else
+ if(dataProtocolId == 28) { /* BigInteger */
+
+ // Simple Field (value)
+ uint64_t value = 0;
+ _res = plc4c_spi_read_unsigned_long(io, 64, (uint64_t*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_uint64_t_data(value);
+
+ } else
+ if(dataProtocolId == 31) { /* Float */
+
+ // Simple Field (value)
+ float value = 0.0;
+ _res = plc4c_spi_read_float(io, 32, (float*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_float_data(value);
+
+ } else
+ if(dataProtocolId == 32) { /* Double */
+
+ // Simple Field (value)
+ double value = 0.0;
+ _res = plc4c_spi_read_double(io, 64, (double*) &value);
+ if(_res != OK) {
+ return _res;
+ }
+
+ *data_item = plc4c_data_create_double_data(value);
+
+ } else
+ if(dataProtocolId == 41) { /* String */
+ } else
+ if(dataProtocolId == 42) { /* String */
+ } else
+ if(dataProtocolId == 43) { /* String */
+
+ // Manual Field (value)
+ char* value = (char*) (plc4c_s7_read_write_parse_s7_string(io, stringLength, "UTF-8"));
+ } else
+ if(dataProtocolId == 44) { /* String */
+
+ // Manual Field (value)
+ char* value = (char*) (plc4c_s7_read_write_parse_s7_string(io, stringLength, "UTF-16"));
+ } else
+ if(dataProtocolId == 51) { /* Time */
+
+ // Manual Field (value)
+ time_t value = (time_t) (plc4c_s7_read_write_parse_tia_time(io));
+ } else
+ if(dataProtocolId == 52) { /* Time */
+
+ // Manual Field (value)
+ time_t value = (time_t) (plc4c_s7_read_write_parse_s5_time(io));
+ } else
+ if(dataProtocolId == 53) { /* Time */
+
+ // Manual Field (value)
+ time_t value = (time_t) (plc4c_s7_read_write_parse_tia_l_time(io));
+ } else
+ if(dataProtocolId == 54) { /* Date */
+
+ // Manual Field (value)
+ time_t value = (time_t) (plc4c_s7_read_write_parse_tia_date(io));
+ } else
+ if(dataProtocolId == 55) { /* Time */
+
+ // Manual Field (value)
+ time_t value = (time_t) (plc4c_s7_read_write_parse_tia_time_of_day(io));
+ } else
+ if(dataProtocolId == 56) { /* DateTime */
+
+ // Manual Field (value)
+ time_t value = (time_t) (plc4c_s7_read_write_parse_tia_date_time(io));
+ }
+
+ return OK;
+}
+
+plc4c_return_code plc4c_s7_read_write_data_item_serialize(plc4c_spi_write_buffer* io, plc4c_data** data_item) {
+ plc4c_return_code _res = OK;
+
+ return OK;
+}
+
+uint16_t plc4c_s7_read_write_data_item_length_in_bytes(plc4c_data* data_item) {
+ return plc4c_s7_read_write_data_item_length_in_bits(data_item) / 8;
+}
+
+uint16_t plc4c_s7_read_write_data_item_length_in_bits(plc4c_data* data_item) {
+ uint16_t lengthInBits = 0;
+
+ return lengthInBits;
+}
+
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_address.c b/sandbox/plc4c/generated-sources/s7/src/s7_address.c
index 4f4e5b0..99b5fef 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_address.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_address.c
@@ -43,8 +43,8 @@
// Parse function.
-plc4c_return_code plc4c_s7_read_write_s7_address_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_s7_address** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_s7_read_write_s7_address_parse(plc4c_spi_read_buffer* io, plc4c_s7_read_write_s7_address** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -56,7 +56,7 @@
// Discriminator Field (addressType) (Used as input to a switch field)
uint8_t addressType = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &addressType);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &addressType);
if(_res != OK) {
return _res;
}
@@ -67,7 +67,7 @@
// Enum field (transportSize)
plc4c_s7_read_write_transport_size transportSize = plc4c_s7_read_write_transport_size_null();
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) &transportSize);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &transportSize);
if(_res != OK) {
return _res;
}
@@ -77,7 +77,7 @@
// Simple Field (numberOfElements)
uint16_t numberOfElements = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &numberOfElements);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &numberOfElements);
if(_res != OK) {
return _res;
}
@@ -87,7 +87,7 @@
// Simple Field (dbNumber)
uint16_t dbNumber = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &dbNumber);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &dbNumber);
if(_res != OK) {
return _res;
}
@@ -97,7 +97,7 @@
// Enum field (area)
plc4c_s7_read_write_memory_area area = plc4c_s7_read_write_memory_area_null();
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) &area);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &area);
if(_res != OK) {
return _res;
}
@@ -108,7 +108,7 @@
// Reserved Field (Compartmentalized so the "reserved" variable can't leak)
{
unsigned int _reserved = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 5, (uint8_t*) &_reserved);
+ _res = plc4c_spi_read_unsigned_byte(io, 5, (uint8_t*) &_reserved);
if(_res != OK) {
return _res;
}
@@ -121,7 +121,7 @@
// Simple Field (byteAddress)
uint16_t byteAddress = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &byteAddress);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &byteAddress);
if(_res != OK) {
return _res;
}
@@ -131,7 +131,7 @@
// Simple Field (bitAddress)
unsigned int bitAddress = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 3, (uint8_t*) &bitAddress);
+ _res = plc4c_spi_read_unsigned_byte(io, 3, (uint8_t*) &bitAddress);
if(_res != OK) {
return _res;
}
@@ -142,54 +142,54 @@
return OK;
}
-plc4c_return_code plc4c_s7_read_write_s7_address_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_address* _message) {
+plc4c_return_code plc4c_s7_read_write_s7_address_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_s7_address* _message) {
plc4c_return_code _res = OK;
// Discriminator Field (addressType)
- plc4c_spi_write_unsigned_byte(buf, 8, plc4c_s7_read_write_s7_address_get_discriminator(_message->_type).addressType);
+ plc4c_spi_write_unsigned_byte(io, 8, plc4c_s7_read_write_s7_address_get_discriminator(_message->_type).addressType);
// Switch Field (Depending of the current type, serialize the sub-type elements)
switch(_message->_type) {
case plc4c_s7_read_write_s7_address_type_plc4c_s7_read_write_s7_address_any: {
// Enum field (transportSize)
- _res = plc4c_spi_write_signed_byte(buf, 8, _message->s7_address_any_transport_size);
+ _res = plc4c_spi_write_signed_byte(io, 8, _message->s7_address_any_transport_size);
if(_res != OK) {
return _res;
}
// Simple Field (numberOfElements)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->s7_address_any_number_of_elements);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->s7_address_any_number_of_elements);
if(_res != OK) {
return _res;
}
// Simple Field (dbNumber)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->s7_address_any_db_number);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->s7_address_any_db_number);
if(_res != OK) {
return _res;
}
// Enum field (area)
- _res = plc4c_spi_write_signed_byte(buf, 8, _message->s7_address_any_area);
+ _res = plc4c_spi_write_signed_byte(io, 8, _message->s7_address_any_area);
if(_res != OK) {
return _res;
}
// Reserved Field
- _res = plc4c_spi_write_unsigned_byte(buf, 5, 0x00);
+ _res = plc4c_spi_write_unsigned_byte(io, 5, 0x00);
if(_res != OK) {
return _res;
}
// Simple Field (byteAddress)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->s7_address_any_byte_address);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->s7_address_any_byte_address);
if(_res != OK) {
return _res;
}
// Simple Field (bitAddress)
- _res = plc4c_spi_write_unsigned_byte(buf, 3, _message->s7_address_any_bit_address);
+ _res = plc4c_spi_write_unsigned_byte(io, 3, _message->s7_address_any_bit_address);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_message.c b/sandbox/plc4c/generated-sources/s7/src/s7_message.c
index 69f20b8..15e0509 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_message.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_message.c
@@ -55,8 +55,8 @@
}
// Parse function.
-plc4c_return_code plc4c_s7_read_write_s7_message_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_s7_message** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_s7_read_write_s7_message_parse(plc4c_spi_read_buffer* io, plc4c_s7_read_write_s7_message** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -68,7 +68,7 @@
// Const Field (protocolId)
uint8_t protocolId = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &protocolId);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &protocolId);
if(_res != OK) {
return _res;
}
@@ -79,7 +79,7 @@
// Discriminator Field (messageType) (Used as input to a switch field)
uint8_t messageType = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &messageType);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &messageType);
if(_res != OK) {
return _res;
}
@@ -87,7 +87,7 @@
// Reserved Field (Compartmentalized so the "reserved" variable can't leak)
{
uint16_t _reserved = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &_reserved);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &_reserved);
if(_res != OK) {
return _res;
}
@@ -98,7 +98,7 @@
// Simple Field (tpduReference)
uint16_t tpduReference = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &tpduReference);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &tpduReference);
if(_res != OK) {
return _res;
}
@@ -106,14 +106,14 @@
// Implicit Field (parameterLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint16_t parameterLength = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) ¶meterLength);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) ¶meterLength);
if(_res != OK) {
return _res;
}
// Implicit Field (payloadLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint16_t payloadLength = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &payloadLength);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &payloadLength);
if(_res != OK) {
return _res;
}
@@ -127,7 +127,7 @@
// Simple Field (errorClass)
uint8_t errorClass = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &errorClass);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &errorClass);
if(_res != OK) {
return _res;
}
@@ -137,7 +137,7 @@
// Simple Field (errorCode)
uint8_t errorCode = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &errorCode);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &errorCode);
if(_res != OK) {
return _res;
}
@@ -149,7 +149,7 @@
// Simple Field (errorClass)
uint8_t errorClass = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &errorClass);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &errorClass);
if(_res != OK) {
return _res;
}
@@ -159,7 +159,7 @@
// Simple Field (errorCode)
uint8_t errorCode = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &errorCode);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &errorCode);
if(_res != OK) {
return _res;
}
@@ -177,7 +177,7 @@
if(parameter == NULL) {
return NO_MEMORY;
}
- _res = plc4c_s7_read_write_s7_parameter_parse(buf, messageType, ¶meter);
+ _res = plc4c_s7_read_write_s7_parameter_parse(io, messageType, ¶meter);
if(_res != OK) {
return _res;
}
@@ -193,7 +193,7 @@
if(payload == NULL) {
return NO_MEMORY;
}
- _res = plc4c_s7_read_write_s7_payload_parse(buf, messageType, parameter, &payload);
+ _res = plc4c_s7_read_write_s7_payload_parse(io, messageType, parameter, &payload);
if(_res != OK) {
return _res;
}
@@ -205,35 +205,35 @@
return OK;
}
-plc4c_return_code plc4c_s7_read_write_s7_message_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_message* _message) {
+plc4c_return_code plc4c_s7_read_write_s7_message_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_s7_message* _message) {
plc4c_return_code _res = OK;
// Const Field (protocolId)
- plc4c_spi_write_unsigned_byte(buf, 8, PLC4C_S7_READ_WRITE_S7_MESSAGE_PROTOCOL_ID());
+ plc4c_spi_write_unsigned_byte(io, 8, PLC4C_S7_READ_WRITE_S7_MESSAGE_PROTOCOL_ID());
// Discriminator Field (messageType)
- plc4c_spi_write_unsigned_byte(buf, 8, plc4c_s7_read_write_s7_message_get_discriminator(_message->_type).messageType);
+ plc4c_spi_write_unsigned_byte(io, 8, plc4c_s7_read_write_s7_message_get_discriminator(_message->_type).messageType);
// Reserved Field
- _res = plc4c_spi_write_unsigned_short(buf, 16, 0x0000);
+ _res = plc4c_spi_write_unsigned_short(io, 16, 0x0000);
if(_res != OK) {
return _res;
}
// Simple Field (tpduReference)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->tpdu_reference);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->tpdu_reference);
if(_res != OK) {
return _res;
}
// Implicit Field (parameterLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_short(buf, 16, (((_message->parameter) != (NULL)) ? plc4c_s7_read_write_s7_parameter_length_in_bytes(_message->parameter) : 0));
+ _res = plc4c_spi_write_unsigned_short(io, 16, (((_message->parameter) != (NULL)) ? plc4c_s7_read_write_s7_parameter_length_in_bytes(_message->parameter) : 0));
if(_res != OK) {
return _res;
}
// Implicit Field (payloadLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_short(buf, 16, (((_message->payload) != (NULL)) ? plc4c_s7_read_write_s7_payload_length_in_bytes(_message->payload) : 0));
+ _res = plc4c_spi_write_unsigned_short(io, 16, (((_message->payload) != (NULL)) ? plc4c_s7_read_write_s7_payload_length_in_bytes(_message->payload) : 0));
if(_res != OK) {
return _res;
}
@@ -247,13 +247,13 @@
case plc4c_s7_read_write_s7_message_type_plc4c_s7_read_write_s7_message_response: {
// Simple Field (errorClass)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, _message->s7_message_response_error_class);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->s7_message_response_error_class);
if(_res != OK) {
return _res;
}
// Simple Field (errorCode)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, _message->s7_message_response_error_code);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->s7_message_response_error_code);
if(_res != OK) {
return _res;
}
@@ -263,13 +263,13 @@
case plc4c_s7_read_write_s7_message_type_plc4c_s7_read_write_s7_message_response_data: {
// Simple Field (errorClass)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, _message->s7_message_response_data_error_class);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->s7_message_response_data_error_class);
if(_res != OK) {
return _res;
}
// Simple Field (errorCode)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, _message->s7_message_response_data_error_code);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->s7_message_response_data_error_code);
if(_res != OK) {
return _res;
}
@@ -284,7 +284,7 @@
// Optional Field (parameter)
if(_message->parameter != NULL) {
- _res = plc4c_s7_read_write_s7_parameter_serialize(buf, _message->parameter);
+ _res = plc4c_s7_read_write_s7_parameter_serialize(io, _message->parameter);
if(_res != OK) {
return _res;
}
@@ -292,7 +292,7 @@
// Optional Field (payload)
if(_message->payload != NULL) {
- _res = plc4c_s7_read_write_s7_payload_serialize(buf, _message->payload);
+ _res = plc4c_s7_read_write_s7_payload_serialize(io, _message->payload);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_parameter.c b/sandbox/plc4c/generated-sources/s7/src/s7_parameter.c
index cdd0bd1..696d0aa 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_parameter.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_parameter.c
@@ -53,8 +53,8 @@
// Parse function.
-plc4c_return_code plc4c_s7_read_write_s7_parameter_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_s7_read_write_s7_parameter_parse(plc4c_spi_read_buffer* io, uint8_t messageType, plc4c_s7_read_write_s7_parameter** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -66,7 +66,7 @@
// Discriminator Field (parameterType) (Used as input to a switch field)
uint8_t parameterType = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) ¶meterType);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) ¶meterType);
if(_res != OK) {
return _res;
}
@@ -78,7 +78,7 @@
// Reserved Field (Compartmentalized so the "reserved" variable can't leak)
{
uint8_t _reserved = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &_reserved);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &_reserved);
if(_res != OK) {
return _res;
}
@@ -91,7 +91,7 @@
// Simple Field (maxAmqCaller)
uint16_t maxAmqCaller = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &maxAmqCaller);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &maxAmqCaller);
if(_res != OK) {
return _res;
}
@@ -101,7 +101,7 @@
// Simple Field (maxAmqCallee)
uint16_t maxAmqCallee = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &maxAmqCallee);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &maxAmqCallee);
if(_res != OK) {
return _res;
}
@@ -111,7 +111,7 @@
// Simple Field (pduLength)
uint16_t pduLength = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &pduLength);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &pduLength);
if(_res != OK) {
return _res;
}
@@ -123,7 +123,7 @@
// Implicit Field (numItems) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t numItems = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &numItems);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &numItems);
if(_res != OK) {
return _res;
}
@@ -142,7 +142,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_s7_read_write_s7_var_request_parameter_item* _value = NULL;
- _res = plc4c_s7_read_write_s7_var_request_parameter_item_parse(buf, (void*) &_value);
+ _res = plc4c_s7_read_write_s7_var_request_parameter_item_parse(io, (void*) &_value);
if(_res != OK) {
return _res;
}
@@ -157,7 +157,7 @@
// Simple Field (numItems)
uint8_t numItems = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &numItems);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &numItems);
if(_res != OK) {
return _res;
}
@@ -169,7 +169,7 @@
// Implicit Field (numItems) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t numItems = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &numItems);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &numItems);
if(_res != OK) {
return _res;
}
@@ -188,7 +188,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_s7_read_write_s7_var_request_parameter_item* _value = NULL;
- _res = plc4c_s7_read_write_s7_var_request_parameter_item_parse(buf, (void*) &_value);
+ _res = plc4c_s7_read_write_s7_var_request_parameter_item_parse(io, (void*) &_value);
if(_res != OK) {
return _res;
}
@@ -203,7 +203,7 @@
// Simple Field (numItems)
uint8_t numItems = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &numItems);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &numItems);
if(_res != OK) {
return _res;
}
@@ -215,7 +215,7 @@
// Implicit Field (numItems) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t numItems = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &numItems);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &numItems);
if(_res != OK) {
return _res;
}
@@ -234,7 +234,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_s7_read_write_s7_parameter_user_data_item* _value = NULL;
- _res = plc4c_s7_read_write_s7_parameter_user_data_item_parse(buf, (void*) &_value);
+ _res = plc4c_s7_read_write_s7_parameter_user_data_item_parse(io, (void*) &_value);
if(_res != OK) {
return _res;
}
@@ -248,36 +248,36 @@
return OK;
}
-plc4c_return_code plc4c_s7_read_write_s7_parameter_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_parameter* _message) {
+plc4c_return_code plc4c_s7_read_write_s7_parameter_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_s7_parameter* _message) {
plc4c_return_code _res = OK;
// Discriminator Field (parameterType)
- plc4c_spi_write_unsigned_byte(buf, 8, plc4c_s7_read_write_s7_parameter_get_discriminator(_message->_type).parameterType);
+ plc4c_spi_write_unsigned_byte(io, 8, plc4c_s7_read_write_s7_parameter_get_discriminator(_message->_type).parameterType);
// Switch Field (Depending of the current type, serialize the sub-type elements)
switch(_message->_type) {
case plc4c_s7_read_write_s7_parameter_type_plc4c_s7_read_write_s7_parameter_setup_communication: {
// Reserved Field
- _res = plc4c_spi_write_unsigned_byte(buf, 8, 0x00);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, 0x00);
if(_res != OK) {
return _res;
}
// Simple Field (maxAmqCaller)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->s7_parameter_setup_communication_max_amq_caller);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->s7_parameter_setup_communication_max_amq_caller);
if(_res != OK) {
return _res;
}
// Simple Field (maxAmqCallee)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->s7_parameter_setup_communication_max_amq_callee);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->s7_parameter_setup_communication_max_amq_callee);
if(_res != OK) {
return _res;
}
// Simple Field (pduLength)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->s7_parameter_setup_communication_pdu_length);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->s7_parameter_setup_communication_pdu_length);
if(_res != OK) {
return _res;
}
@@ -287,7 +287,7 @@
case plc4c_s7_read_write_s7_parameter_type_plc4c_s7_read_write_s7_parameter_read_var_request: {
// Implicit Field (numItems) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, plc4c_spi_evaluation_helper_count(_message->s7_parameter_read_var_request_items));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, plc4c_spi_evaluation_helper_count(_message->s7_parameter_read_var_request_items));
if(_res != OK) {
return _res;
}
@@ -298,7 +298,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_s7_read_write_s7_var_request_parameter_item* _value = (plc4c_s7_read_write_s7_var_request_parameter_item*) plc4c_utils_list_get_value(_message->s7_parameter_read_var_request_items, curItem);
- _res = plc4c_s7_read_write_s7_var_request_parameter_item_serialize(buf, (void*) _value);
+ _res = plc4c_s7_read_write_s7_var_request_parameter_item_serialize(io, (void*) _value);
if(_res != OK) {
return _res;
}
@@ -310,7 +310,7 @@
case plc4c_s7_read_write_s7_parameter_type_plc4c_s7_read_write_s7_parameter_read_var_response: {
// Simple Field (numItems)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, _message->s7_parameter_read_var_response_num_items);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->s7_parameter_read_var_response_num_items);
if(_res != OK) {
return _res;
}
@@ -320,7 +320,7 @@
case plc4c_s7_read_write_s7_parameter_type_plc4c_s7_read_write_s7_parameter_write_var_request: {
// Implicit Field (numItems) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, plc4c_spi_evaluation_helper_count(_message->s7_parameter_write_var_request_items));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, plc4c_spi_evaluation_helper_count(_message->s7_parameter_write_var_request_items));
if(_res != OK) {
return _res;
}
@@ -331,7 +331,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_s7_read_write_s7_var_request_parameter_item* _value = (plc4c_s7_read_write_s7_var_request_parameter_item*) plc4c_utils_list_get_value(_message->s7_parameter_write_var_request_items, curItem);
- _res = plc4c_s7_read_write_s7_var_request_parameter_item_serialize(buf, (void*) _value);
+ _res = plc4c_s7_read_write_s7_var_request_parameter_item_serialize(io, (void*) _value);
if(_res != OK) {
return _res;
}
@@ -343,7 +343,7 @@
case plc4c_s7_read_write_s7_parameter_type_plc4c_s7_read_write_s7_parameter_write_var_response: {
// Simple Field (numItems)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, _message->s7_parameter_write_var_response_num_items);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->s7_parameter_write_var_response_num_items);
if(_res != OK) {
return _res;
}
@@ -353,7 +353,7 @@
case plc4c_s7_read_write_s7_parameter_type_plc4c_s7_read_write_s7_parameter_user_data: {
// Implicit Field (numItems) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, plc4c_spi_evaluation_helper_count(_message->s7_parameter_user_data_items));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, plc4c_spi_evaluation_helper_count(_message->s7_parameter_user_data_items));
if(_res != OK) {
return _res;
}
@@ -364,7 +364,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_s7_read_write_s7_parameter_user_data_item* _value = (plc4c_s7_read_write_s7_parameter_user_data_item*) plc4c_utils_list_get_value(_message->s7_parameter_user_data_items, curItem);
- _res = plc4c_s7_read_write_s7_parameter_user_data_item_serialize(buf, (void*) _value);
+ _res = plc4c_s7_read_write_s7_parameter_user_data_item_serialize(io, (void*) _value);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_parameter_user_data_item.c b/sandbox/plc4c/generated-sources/s7/src/s7_parameter_user_data_item.c
index 5b683aa..60d49f1 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_parameter_user_data_item.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_parameter_user_data_item.c
@@ -43,8 +43,8 @@
// Parse function.
-plc4c_return_code plc4c_s7_read_write_s7_parameter_user_data_item_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_s7_parameter_user_data_item** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_s7_read_write_s7_parameter_user_data_item_parse(plc4c_spi_read_buffer* io, plc4c_s7_read_write_s7_parameter_user_data_item** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -56,7 +56,7 @@
// Discriminator Field (itemType) (Used as input to a switch field)
uint8_t itemType = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &itemType);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &itemType);
if(_res != OK) {
return _res;
}
@@ -67,7 +67,7 @@
// Implicit Field (itemLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t itemLength = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &itemLength);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &itemLength);
if(_res != OK) {
return _res;
}
@@ -76,7 +76,7 @@
// Simple Field (method)
uint8_t method = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &method);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &method);
if(_res != OK) {
return _res;
}
@@ -86,7 +86,7 @@
// Simple Field (cpuFunctionType)
unsigned int cpuFunctionType = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 4, (uint8_t*) &cpuFunctionType);
+ _res = plc4c_spi_read_unsigned_byte(io, 4, (uint8_t*) &cpuFunctionType);
if(_res != OK) {
return _res;
}
@@ -96,7 +96,7 @@
// Simple Field (cpuFunctionGroup)
unsigned int cpuFunctionGroup = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 4, (uint8_t*) &cpuFunctionGroup);
+ _res = plc4c_spi_read_unsigned_byte(io, 4, (uint8_t*) &cpuFunctionGroup);
if(_res != OK) {
return _res;
}
@@ -106,7 +106,7 @@
// Simple Field (cpuSubfunction)
uint8_t cpuSubfunction = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &cpuSubfunction);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &cpuSubfunction);
if(_res != OK) {
return _res;
}
@@ -116,7 +116,7 @@
// Simple Field (sequenceNumber)
uint8_t sequenceNumber = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &sequenceNumber);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &sequenceNumber);
if(_res != OK) {
return _res;
}
@@ -132,7 +132,7 @@
return NO_MEMORY;
}
*dataUnitReferenceNumber = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) dataUnitReferenceNumber);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) dataUnitReferenceNumber);
if(_res != OK) {
return _res;
}
@@ -151,7 +151,7 @@
return NO_MEMORY;
}
*lastDataUnit = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) lastDataUnit);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) lastDataUnit);
if(_res != OK) {
return _res;
}
@@ -170,7 +170,7 @@
return NO_MEMORY;
}
*errorCode = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) errorCode);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) errorCode);
if(_res != OK) {
return _res;
}
@@ -184,55 +184,55 @@
return OK;
}
-plc4c_return_code plc4c_s7_read_write_s7_parameter_user_data_item_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_parameter_user_data_item* _message) {
+plc4c_return_code plc4c_s7_read_write_s7_parameter_user_data_item_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_s7_parameter_user_data_item* _message) {
plc4c_return_code _res = OK;
// Discriminator Field (itemType)
- plc4c_spi_write_unsigned_byte(buf, 8, plc4c_s7_read_write_s7_parameter_user_data_item_get_discriminator(_message->_type).itemType);
+ plc4c_spi_write_unsigned_byte(io, 8, plc4c_s7_read_write_s7_parameter_user_data_item_get_discriminator(_message->_type).itemType);
// Switch Field (Depending of the current type, serialize the sub-type elements)
switch(_message->_type) {
case plc4c_s7_read_write_s7_parameter_user_data_item_type_plc4c_s7_read_write_s7_parameter_user_data_item_cpu_functions: {
// Implicit Field (itemLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, (plc4c_s7_read_write_s7_parameter_user_data_item_length_in_bytes(_message)) - (2));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, (plc4c_s7_read_write_s7_parameter_user_data_item_length_in_bytes(_message)) - (2));
if(_res != OK) {
return _res;
}
// Simple Field (method)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, _message->s7_parameter_user_data_item_cpu_functions_method);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->s7_parameter_user_data_item_cpu_functions_method);
if(_res != OK) {
return _res;
}
// Simple Field (cpuFunctionType)
- _res = plc4c_spi_write_unsigned_byte(buf, 4, _message->s7_parameter_user_data_item_cpu_functions_cpu_function_type);
+ _res = plc4c_spi_write_unsigned_byte(io, 4, _message->s7_parameter_user_data_item_cpu_functions_cpu_function_type);
if(_res != OK) {
return _res;
}
// Simple Field (cpuFunctionGroup)
- _res = plc4c_spi_write_unsigned_byte(buf, 4, _message->s7_parameter_user_data_item_cpu_functions_cpu_function_group);
+ _res = plc4c_spi_write_unsigned_byte(io, 4, _message->s7_parameter_user_data_item_cpu_functions_cpu_function_group);
if(_res != OK) {
return _res;
}
// Simple Field (cpuSubfunction)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, _message->s7_parameter_user_data_item_cpu_functions_cpu_subfunction);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->s7_parameter_user_data_item_cpu_functions_cpu_subfunction);
if(_res != OK) {
return _res;
}
// Simple Field (sequenceNumber)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, _message->s7_parameter_user_data_item_cpu_functions_sequence_number);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->s7_parameter_user_data_item_cpu_functions_sequence_number);
if(_res != OK) {
return _res;
}
// Optional Field (dataUnitReferenceNumber)
if(_message->s7_parameter_user_data_item_cpu_functions_data_unit_reference_number != NULL) {
- _res = plc4c_spi_write_unsigned_byte(buf, 8, *_message->s7_parameter_user_data_item_cpu_functions_data_unit_reference_number);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, *_message->s7_parameter_user_data_item_cpu_functions_data_unit_reference_number);
if(_res != OK) {
return _res;
}
@@ -240,7 +240,7 @@
// Optional Field (lastDataUnit)
if(_message->s7_parameter_user_data_item_cpu_functions_last_data_unit != NULL) {
- _res = plc4c_spi_write_unsigned_byte(buf, 8, *_message->s7_parameter_user_data_item_cpu_functions_last_data_unit);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, *_message->s7_parameter_user_data_item_cpu_functions_last_data_unit);
if(_res != OK) {
return _res;
}
@@ -248,7 +248,7 @@
// Optional Field (errorCode)
if(_message->s7_parameter_user_data_item_cpu_functions_error_code != NULL) {
- _res = plc4c_spi_write_unsigned_short(buf, 16, *_message->s7_parameter_user_data_item_cpu_functions_error_code);
+ _res = plc4c_spi_write_unsigned_short(io, 16, *_message->s7_parameter_user_data_item_cpu_functions_error_code);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_payload.c b/sandbox/plc4c/generated-sources/s7/src/s7_payload.c
index 62cf046..a273679 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_payload.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_payload.c
@@ -49,8 +49,8 @@
// Parse function.
-plc4c_return_code plc4c_s7_read_write_s7_payload_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter* parameter, plc4c_s7_read_write_s7_payload** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_s7_read_write_s7_payload_parse(plc4c_spi_read_buffer* io, uint8_t messageType, plc4c_s7_read_write_s7_parameter* parameter, plc4c_s7_read_write_s7_payload** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -76,7 +76,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_s7_read_write_s7_var_payload_data_item* _value = NULL;
- _res = plc4c_s7_read_write_s7_var_payload_data_item_parse(buf, lastItem, (void*) &_value);
+ _res = plc4c_s7_read_write_s7_var_payload_data_item_parse(io, lastItem, (void*) &_value);
if(_res != OK) {
return _res;
}
@@ -101,7 +101,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_s7_read_write_s7_var_payload_data_item* _value = NULL;
- _res = plc4c_s7_read_write_s7_var_payload_data_item_parse(buf, lastItem, (void*) &_value);
+ _res = plc4c_s7_read_write_s7_var_payload_data_item_parse(io, lastItem, (void*) &_value);
if(_res != OK) {
return _res;
}
@@ -126,7 +126,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_s7_read_write_s7_var_payload_status_item* _value = NULL;
- _res = plc4c_s7_read_write_s7_var_payload_status_item_parse(buf, (void*) &_value);
+ _res = plc4c_s7_read_write_s7_var_payload_status_item_parse(io, (void*) &_value);
if(_res != OK) {
return _res;
}
@@ -151,7 +151,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_s7_read_write_s7_payload_user_data_item* _value = NULL;
- _res = plc4c_s7_read_write_s7_payload_user_data_item_parse(buf, ((plc4c_s7_read_write_s7_parameter_user_data_item*) (plc4c_utils_list_get_value(((plc4c_s7_read_write_s7_parameter*) (parameter))->s7_parameter_user_data_items, 0)))->s7_parameter_user_data_item_cpu_functions_cpu_function_type, (void*) &_value);
+ _res = plc4c_s7_read_write_s7_payload_user_data_item_parse(io, ((plc4c_s7_read_write_s7_parameter_user_data_item*) (plc4c_utils_list_get_value(((plc4c_s7_read_write_s7_parameter*) (parameter))->s7_parameter_user_data_items, 0)))->s7_parameter_user_data_item_cpu_functions_cpu_function_type, (void*) &_value);
if(_res != OK) {
return _res;
}
@@ -165,7 +165,7 @@
return OK;
}
-plc4c_return_code plc4c_s7_read_write_s7_payload_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_payload* _message) {
+plc4c_return_code plc4c_s7_read_write_s7_payload_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_s7_payload* _message) {
plc4c_return_code _res = OK;
// Switch Field (Depending of the current type, serialize the sub-type elements)
@@ -178,7 +178,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_s7_read_write_s7_var_payload_data_item* _value = (plc4c_s7_read_write_s7_var_payload_data_item*) plc4c_utils_list_get_value(_message->s7_payload_read_var_response_items, curItem);
- _res = plc4c_s7_read_write_s7_var_payload_data_item_serialize(buf, (void*) _value, lastItem);
+ _res = plc4c_s7_read_write_s7_var_payload_data_item_serialize(io, (void*) _value, lastItem);
if(_res != OK) {
return _res;
}
@@ -195,7 +195,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_s7_read_write_s7_var_payload_data_item* _value = (plc4c_s7_read_write_s7_var_payload_data_item*) plc4c_utils_list_get_value(_message->s7_payload_write_var_request_items, curItem);
- _res = plc4c_s7_read_write_s7_var_payload_data_item_serialize(buf, (void*) _value, lastItem);
+ _res = plc4c_s7_read_write_s7_var_payload_data_item_serialize(io, (void*) _value, lastItem);
if(_res != OK) {
return _res;
}
@@ -212,7 +212,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_s7_read_write_s7_var_payload_status_item* _value = (plc4c_s7_read_write_s7_var_payload_status_item*) plc4c_utils_list_get_value(_message->s7_payload_write_var_response_items, curItem);
- _res = plc4c_s7_read_write_s7_var_payload_status_item_serialize(buf, (void*) _value);
+ _res = plc4c_s7_read_write_s7_var_payload_status_item_serialize(io, (void*) _value);
if(_res != OK) {
return _res;
}
@@ -229,7 +229,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_s7_read_write_s7_payload_user_data_item* _value = (plc4c_s7_read_write_s7_payload_user_data_item*) plc4c_utils_list_get_value(_message->s7_payload_user_data_items, curItem);
- _res = plc4c_s7_read_write_s7_payload_user_data_item_serialize(buf, (void*) _value);
+ _res = plc4c_s7_read_write_s7_payload_user_data_item_serialize(io, (void*) _value);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data_item.c b/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data_item.c
index 04f9925..830f547 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data_item.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data_item.c
@@ -51,8 +51,8 @@
}
// Parse function.
-plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_item_parse(plc4c_spi_read_buffer* buf, unsigned int cpuFunctionType, plc4c_s7_read_write_s7_payload_user_data_item** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_item_parse(plc4c_spi_read_buffer* io, unsigned int cpuFunctionType, plc4c_s7_read_write_s7_payload_user_data_item** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -64,7 +64,7 @@
// Enum field (returnCode)
plc4c_s7_read_write_data_transport_error_code returnCode = plc4c_s7_read_write_data_transport_error_code_null();
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) &returnCode);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &returnCode);
if(_res != OK) {
return _res;
}
@@ -72,7 +72,7 @@
// Enum field (transportSize)
plc4c_s7_read_write_data_transport_size transportSize = plc4c_s7_read_write_data_transport_size_null();
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) &transportSize);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &transportSize);
if(_res != OK) {
return _res;
}
@@ -80,14 +80,14 @@
// Implicit Field (dataLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint16_t dataLength = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &dataLength);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &dataLength);
if(_res != OK) {
return _res;
}
// Simple Field (szlId)
plc4c_s7_read_write_szl_id* szlId;
- _res = plc4c_s7_read_write_szl_id_parse(buf, (void*) &szlId);
+ _res = plc4c_s7_read_write_szl_id_parse(io, (void*) &szlId);
if(_res != OK) {
return _res;
}
@@ -95,7 +95,7 @@
// Simple Field (szlIndex)
uint16_t szlIndex = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &szlIndex);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &szlIndex);
if(_res != OK) {
return _res;
}
@@ -110,7 +110,7 @@
// Const Field (szlItemLength)
uint16_t szlItemLength = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &szlItemLength);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &szlItemLength);
if(_res != OK) {
return _res;
}
@@ -123,7 +123,7 @@
// Implicit Field (szlItemCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint16_t szlItemCount = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &szlItemCount);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &szlItemCount);
if(_res != OK) {
return _res;
}
@@ -142,7 +142,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_s7_read_write_szl_data_tree_item* _value = NULL;
- _res = plc4c_s7_read_write_szl_data_tree_item_parse(buf, (void*) &_value);
+ _res = plc4c_s7_read_write_szl_data_tree_item_parse(io, (void*) &_value);
if(_res != OK) {
return _res;
}
@@ -156,35 +156,35 @@
return OK;
}
-plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_item_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_payload_user_data_item* _message) {
+plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_item_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_s7_payload_user_data_item* _message) {
plc4c_return_code _res = OK;
// Enum field (returnCode)
- _res = plc4c_spi_write_signed_byte(buf, 8, _message->return_code);
+ _res = plc4c_spi_write_signed_byte(io, 8, _message->return_code);
if(_res != OK) {
return _res;
}
// Enum field (transportSize)
- _res = plc4c_spi_write_signed_byte(buf, 8, _message->transport_size);
+ _res = plc4c_spi_write_signed_byte(io, 8, _message->transport_size);
if(_res != OK) {
return _res;
}
// Implicit Field (dataLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_short(buf, 16, (plc4c_s7_read_write_s7_payload_user_data_item_length_in_bytes(_message)) - (4));
+ _res = plc4c_spi_write_unsigned_short(io, 16, (plc4c_s7_read_write_s7_payload_user_data_item_length_in_bytes(_message)) - (4));
if(_res != OK) {
return _res;
}
// Simple Field (szlId)
- _res = plc4c_s7_read_write_szl_id_serialize(buf, _message->szl_id);
+ _res = plc4c_s7_read_write_szl_id_serialize(io, _message->szl_id);
if(_res != OK) {
return _res;
}
// Simple Field (szlIndex)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->szl_index);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->szl_index);
if(_res != OK) {
return _res;
}
@@ -198,10 +198,10 @@
case plc4c_s7_read_write_s7_payload_user_data_item_type_plc4c_s7_read_write_s7_payload_user_data_item_cpu_function_read_szl_response: {
// Const Field (szlItemLength)
- plc4c_spi_write_unsigned_short(buf, 16, PLC4C_S7_READ_WRITE_S7_PAYLOAD_USER_DATA_ITEM_CPU_FUNCTION_READ_SZL_RESPONSE_SZL_ITEM_LENGTH());
+ plc4c_spi_write_unsigned_short(io, 16, PLC4C_S7_READ_WRITE_S7_PAYLOAD_USER_DATA_ITEM_CPU_FUNCTION_READ_SZL_RESPONSE_SZL_ITEM_LENGTH());
// Implicit Field (szlItemCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_short(buf, 16, plc4c_spi_evaluation_helper_count(_message->s7_payload_user_data_item_cpu_function_read_szl_response_items));
+ _res = plc4c_spi_write_unsigned_short(io, 16, plc4c_spi_evaluation_helper_count(_message->s7_payload_user_data_item_cpu_function_read_szl_response_items));
if(_res != OK) {
return _res;
}
@@ -212,7 +212,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
bool lastItem = curItem == (itemCount - 1);
plc4c_s7_read_write_szl_data_tree_item* _value = (plc4c_s7_read_write_szl_data_tree_item*) plc4c_utils_list_get_value(_message->s7_payload_user_data_item_cpu_function_read_szl_response_items, curItem);
- _res = plc4c_s7_read_write_szl_data_tree_item_serialize(buf, (void*) _value);
+ _res = plc4c_s7_read_write_szl_data_tree_item_serialize(io, (void*) _value);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_var_payload_data_item.c b/sandbox/plc4c/generated-sources/s7/src/s7_var_payload_data_item.c
index 8cb2346..aa06042 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_var_payload_data_item.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_var_payload_data_item.c
@@ -23,8 +23,8 @@
// Parse function.
-plc4c_return_code plc4c_s7_read_write_s7_var_payload_data_item_parse(plc4c_spi_read_buffer* buf, bool lastItem, plc4c_s7_read_write_s7_var_payload_data_item** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_s7_read_write_s7_var_payload_data_item_parse(plc4c_spi_read_buffer* io, bool lastItem, plc4c_s7_read_write_s7_var_payload_data_item** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -36,7 +36,7 @@
// Enum field (returnCode)
plc4c_s7_read_write_data_transport_error_code returnCode = plc4c_s7_read_write_data_transport_error_code_null();
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) &returnCode);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &returnCode);
if(_res != OK) {
return _res;
}
@@ -44,7 +44,7 @@
// Enum field (transportSize)
plc4c_s7_read_write_data_transport_size transportSize = plc4c_s7_read_write_data_transport_size_null();
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) &transportSize);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &transportSize);
if(_res != OK) {
return _res;
}
@@ -52,7 +52,7 @@
// Implicit Field (dataLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint16_t dataLength = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &dataLength);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &dataLength);
if(_res != OK) {
return _res;
}
@@ -69,7 +69,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = malloc(sizeof(int8_t));
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) _value);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) _value);
if(_res != OK) {
return _res;
}
@@ -80,11 +80,11 @@
// Padding Field (padding)
{
- int _timesPadding = (int) ((plc4c_spi_read_has_more(buf, 8)) && (((lastItem) ? 0 : (plc4c_spi_evaluation_helper_count(data)) % (2))));
+ int _timesPadding = (int) ((plc4c_spi_read_has_more(io, 8)) && (((lastItem) ? 0 : (plc4c_spi_evaluation_helper_count(data)) % (2))));
while (_timesPadding-- > 0) {
// Just read the padding data and ignore it
uint8_t _paddingValue = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &_paddingValue);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &_paddingValue);
if(_res != OK) {
return _res;
}
@@ -94,23 +94,23 @@
return OK;
}
-plc4c_return_code plc4c_s7_read_write_s7_var_payload_data_item_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_var_payload_data_item* _message, bool lastItem) {
+plc4c_return_code plc4c_s7_read_write_s7_var_payload_data_item_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_s7_var_payload_data_item* _message, bool lastItem) {
plc4c_return_code _res = OK;
// Enum field (returnCode)
- _res = plc4c_spi_write_signed_byte(buf, 8, _message->return_code);
+ _res = plc4c_spi_write_signed_byte(io, 8, _message->return_code);
if(_res != OK) {
return _res;
}
// Enum field (transportSize)
- _res = plc4c_spi_write_signed_byte(buf, 8, _message->transport_size);
+ _res = plc4c_spi_write_signed_byte(io, 8, _message->transport_size);
if(_res != OK) {
return _res;
}
// Implicit Field (dataLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_short(buf, 16, (plc4c_spi_evaluation_helper_count(_message->data)) * ((((((_message->transport_size) == (plc4c_s7_read_write_data_transport_size_BIT))) ? 1 : (((plc4c_s7_read_write_data_transport_size_get_size_in_bits(_message->transport_size)) ? 8 : 1))))));
+ _res = plc4c_spi_write_unsigned_short(io, 16, (plc4c_spi_evaluation_helper_count(_message->data)) * ((((((_message->transport_size) == (plc4c_s7_read_write_data_transport_size_BIT))) ? 1 : (((plc4c_s7_read_write_data_transport_size_get_size_in_bits(_message->transport_size)) ? 8 : 1))))));
if(_res != OK) {
return _res;
}
@@ -121,7 +121,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = (int8_t*) plc4c_utils_list_get_value(_message->data, curItem);
- plc4c_spi_write_signed_byte(buf, 8, *_value);
+ plc4c_spi_write_signed_byte(io, 8, *_value);
}
}
@@ -130,7 +130,7 @@
int _timesPadding = (int) (((lastItem) ? 0 : (plc4c_spi_evaluation_helper_count(_message->data)) % (2)));
while (_timesPadding-- > 0) {
// Just output the default padding data
- _res = plc4c_spi_write_unsigned_byte(buf, 8, 0);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, 0);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_var_payload_status_item.c b/sandbox/plc4c/generated-sources/s7/src/s7_var_payload_status_item.c
index 7d4b955..94e9b04 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_var_payload_status_item.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_var_payload_status_item.c
@@ -23,8 +23,8 @@
// Parse function.
-plc4c_return_code plc4c_s7_read_write_s7_var_payload_status_item_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_s7_var_payload_status_item** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_s7_read_write_s7_var_payload_status_item_parse(plc4c_spi_read_buffer* io, plc4c_s7_read_write_s7_var_payload_status_item** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -36,7 +36,7 @@
// Enum field (returnCode)
plc4c_s7_read_write_data_transport_error_code returnCode = plc4c_s7_read_write_data_transport_error_code_null();
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) &returnCode);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &returnCode);
if(_res != OK) {
return _res;
}
@@ -45,11 +45,11 @@
return OK;
}
-plc4c_return_code plc4c_s7_read_write_s7_var_payload_status_item_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_var_payload_status_item* _message) {
+plc4c_return_code plc4c_s7_read_write_s7_var_payload_status_item_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_s7_var_payload_status_item* _message) {
plc4c_return_code _res = OK;
// Enum field (returnCode)
- _res = plc4c_spi_write_signed_byte(buf, 8, _message->return_code);
+ _res = plc4c_spi_write_signed_byte(io, 8, _message->return_code);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_var_request_parameter_item.c b/sandbox/plc4c/generated-sources/s7/src/s7_var_request_parameter_item.c
index a6726bb..f4f48f2 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_var_request_parameter_item.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_var_request_parameter_item.c
@@ -43,8 +43,8 @@
// Parse function.
-plc4c_return_code plc4c_s7_read_write_s7_var_request_parameter_item_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_s7_var_request_parameter_item** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_s7_read_write_s7_var_request_parameter_item_parse(plc4c_spi_read_buffer* io, plc4c_s7_read_write_s7_var_request_parameter_item** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -56,7 +56,7 @@
// Discriminator Field (itemType) (Used as input to a switch field)
uint8_t itemType = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &itemType);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &itemType);
if(_res != OK) {
return _res;
}
@@ -67,7 +67,7 @@
// Implicit Field (itemLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint8_t itemLength = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &itemLength);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &itemLength);
if(_res != OK) {
return _res;
}
@@ -76,7 +76,7 @@
// Simple Field (address)
plc4c_s7_read_write_s7_address* address;
- _res = plc4c_s7_read_write_s7_address_parse(buf, (void*) &address);
+ _res = plc4c_s7_read_write_s7_address_parse(io, (void*) &address);
if(_res != OK) {
return _res;
}
@@ -87,24 +87,24 @@
return OK;
}
-plc4c_return_code plc4c_s7_read_write_s7_var_request_parameter_item_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_var_request_parameter_item* _message) {
+plc4c_return_code plc4c_s7_read_write_s7_var_request_parameter_item_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_s7_var_request_parameter_item* _message) {
plc4c_return_code _res = OK;
// Discriminator Field (itemType)
- plc4c_spi_write_unsigned_byte(buf, 8, plc4c_s7_read_write_s7_var_request_parameter_item_get_discriminator(_message->_type).itemType);
+ plc4c_spi_write_unsigned_byte(io, 8, plc4c_s7_read_write_s7_var_request_parameter_item_get_discriminator(_message->_type).itemType);
// Switch Field (Depending of the current type, serialize the sub-type elements)
switch(_message->_type) {
case plc4c_s7_read_write_s7_var_request_parameter_item_type_plc4c_s7_read_write_s7_var_request_parameter_item_address: {
// Implicit Field (itemLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_byte(buf, 8, plc4c_s7_read_write_s7_address_length_in_bytes(_message->s7_var_request_parameter_item_address_address));
+ _res = plc4c_spi_write_unsigned_byte(io, 8, plc4c_s7_read_write_s7_address_length_in_bytes(_message->s7_var_request_parameter_item_address_address));
if(_res != OK) {
return _res;
}
// Simple Field (address)
- _res = plc4c_s7_read_write_s7_address_serialize(buf, _message->s7_var_request_parameter_item_address_address);
+ _res = plc4c_s7_read_write_s7_address_serialize(io, _message->s7_var_request_parameter_item_address_address);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/szl_data_tree_item.c b/sandbox/plc4c/generated-sources/s7/src/szl_data_tree_item.c
index 99a321d..ab5b17a 100644
--- a/sandbox/plc4c/generated-sources/s7/src/szl_data_tree_item.c
+++ b/sandbox/plc4c/generated-sources/s7/src/szl_data_tree_item.c
@@ -23,8 +23,8 @@
// Parse function.
-plc4c_return_code plc4c_s7_read_write_szl_data_tree_item_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_szl_data_tree_item** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_s7_read_write_szl_data_tree_item_parse(plc4c_spi_read_buffer* io, plc4c_s7_read_write_szl_data_tree_item** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -36,7 +36,7 @@
// Simple Field (itemIndex)
uint16_t itemIndex = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &itemIndex);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &itemIndex);
if(_res != OK) {
return _res;
}
@@ -54,7 +54,7 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = malloc(sizeof(int8_t));
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) _value);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) _value);
if(_res != OK) {
return _res;
}
@@ -65,7 +65,7 @@
// Simple Field (moduleTypeId)
uint16_t moduleTypeId = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &moduleTypeId);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &moduleTypeId);
if(_res != OK) {
return _res;
}
@@ -73,7 +73,7 @@
// Simple Field (ausbg)
uint16_t ausbg = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &ausbg);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &ausbg);
if(_res != OK) {
return _res;
}
@@ -81,7 +81,7 @@
// Simple Field (ausbe)
uint16_t ausbe = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &ausbe);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &ausbe);
if(_res != OK) {
return _res;
}
@@ -90,11 +90,11 @@
return OK;
}
-plc4c_return_code plc4c_s7_read_write_szl_data_tree_item_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_szl_data_tree_item* _message) {
+plc4c_return_code plc4c_s7_read_write_szl_data_tree_item_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_szl_data_tree_item* _message) {
plc4c_return_code _res = OK;
// Simple Field (itemIndex)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->item_index);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->item_index);
if(_res != OK) {
return _res;
}
@@ -105,24 +105,24 @@
for(int curItem = 0; curItem < itemCount; curItem++) {
int8_t* _value = (int8_t*) plc4c_utils_list_get_value(_message->mlfb, curItem);
- plc4c_spi_write_signed_byte(buf, 8, *_value);
+ plc4c_spi_write_signed_byte(io, 8, *_value);
}
}
// Simple Field (moduleTypeId)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->module_type_id);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->module_type_id);
if(_res != OK) {
return _res;
}
// Simple Field (ausbg)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->ausbg);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->ausbg);
if(_res != OK) {
return _res;
}
// Simple Field (ausbe)
- _res = plc4c_spi_write_unsigned_short(buf, 16, _message->ausbe);
+ _res = plc4c_spi_write_unsigned_short(io, 16, _message->ausbe);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/szl_id.c b/sandbox/plc4c/generated-sources/s7/src/szl_id.c
index 78ac7ce..21a77ad 100644
--- a/sandbox/plc4c/generated-sources/s7/src/szl_id.c
+++ b/sandbox/plc4c/generated-sources/s7/src/szl_id.c
@@ -23,8 +23,8 @@
// Parse function.
-plc4c_return_code plc4c_s7_read_write_szl_id_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_szl_id** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_s7_read_write_szl_id_parse(plc4c_spi_read_buffer* io, plc4c_s7_read_write_szl_id** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -36,7 +36,7 @@
// Enum field (typeClass)
plc4c_s7_read_write_szl_module_type_class typeClass = plc4c_s7_read_write_szl_module_type_class_null();
- _res = plc4c_spi_read_signed_byte(buf, 4, (int8_t*) &typeClass);
+ _res = plc4c_spi_read_signed_byte(io, 4, (int8_t*) &typeClass);
if(_res != OK) {
return _res;
}
@@ -44,7 +44,7 @@
// Simple Field (sublistExtract)
unsigned int sublistExtract = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 4, (uint8_t*) &sublistExtract);
+ _res = plc4c_spi_read_unsigned_byte(io, 4, (uint8_t*) &sublistExtract);
if(_res != OK) {
return _res;
}
@@ -52,7 +52,7 @@
// Enum field (sublistList)
plc4c_s7_read_write_szl_sublist sublistList = plc4c_s7_read_write_szl_sublist_null();
- _res = plc4c_spi_read_signed_byte(buf, 8, (int8_t*) &sublistList);
+ _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &sublistList);
if(_res != OK) {
return _res;
}
@@ -61,23 +61,23 @@
return OK;
}
-plc4c_return_code plc4c_s7_read_write_szl_id_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_szl_id* _message) {
+plc4c_return_code plc4c_s7_read_write_szl_id_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_szl_id* _message) {
plc4c_return_code _res = OK;
// Enum field (typeClass)
- _res = plc4c_spi_write_signed_byte(buf, 4, _message->type_class);
+ _res = plc4c_spi_write_signed_byte(io, 4, _message->type_class);
if(_res != OK) {
return _res;
}
// Simple Field (sublistExtract)
- _res = plc4c_spi_write_unsigned_byte(buf, 4, _message->sublist_extract);
+ _res = plc4c_spi_write_unsigned_byte(io, 4, _message->sublist_extract);
if(_res != OK) {
return _res;
}
// Enum field (sublistList)
- _res = plc4c_spi_write_signed_byte(buf, 8, _message->sublist_list);
+ _res = plc4c_spi_write_signed_byte(io, 8, _message->sublist_list);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/tpkt_packet.c b/sandbox/plc4c/generated-sources/s7/src/tpkt_packet.c
index 05d51cc..28145d8 100644
--- a/sandbox/plc4c/generated-sources/s7/src/tpkt_packet.c
+++ b/sandbox/plc4c/generated-sources/s7/src/tpkt_packet.c
@@ -29,8 +29,8 @@
}
// Parse function.
-plc4c_return_code plc4c_s7_read_write_tpkt_packet_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_tpkt_packet** _message) {
- uint16_t startPos = plc4c_spi_read_get_pos(buf);
+plc4c_return_code plc4c_s7_read_write_tpkt_packet_parse(plc4c_spi_read_buffer* io, plc4c_s7_read_write_tpkt_packet** _message) {
+ uint16_t startPos = plc4c_spi_read_get_pos(io);
uint16_t curPos;
plc4c_return_code _res = OK;
@@ -42,7 +42,7 @@
// Const Field (protocolId)
uint8_t protocolId = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &protocolId);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &protocolId);
if(_res != OK) {
return _res;
}
@@ -54,7 +54,7 @@
// Reserved Field (Compartmentalized so the "reserved" variable can't leak)
{
uint8_t _reserved = 0;
- _res = plc4c_spi_read_unsigned_byte(buf, 8, (uint8_t*) &_reserved);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &_reserved);
if(_res != OK) {
return _res;
}
@@ -65,14 +65,14 @@
// Implicit Field (len) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
uint16_t len = 0;
- _res = plc4c_spi_read_unsigned_short(buf, 16, (uint16_t*) &len);
+ _res = plc4c_spi_read_unsigned_short(io, 16, (uint16_t*) &len);
if(_res != OK) {
return _res;
}
// Simple Field (payload)
plc4c_s7_read_write_cotp_packet* payload;
- _res = plc4c_s7_read_write_cotp_packet_parse(buf, (len) - (4), (void*) &payload);
+ _res = plc4c_s7_read_write_cotp_packet_parse(io, (len) - (4), (void*) &payload);
if(_res != OK) {
return _res;
}
@@ -81,26 +81,26 @@
return OK;
}
-plc4c_return_code plc4c_s7_read_write_tpkt_packet_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_tpkt_packet* _message) {
+plc4c_return_code plc4c_s7_read_write_tpkt_packet_serialize(plc4c_spi_write_buffer* io, plc4c_s7_read_write_tpkt_packet* _message) {
plc4c_return_code _res = OK;
// Const Field (protocolId)
- plc4c_spi_write_unsigned_byte(buf, 8, PLC4C_S7_READ_WRITE_TPKT_PACKET_PROTOCOL_ID());
+ plc4c_spi_write_unsigned_byte(io, 8, PLC4C_S7_READ_WRITE_TPKT_PACKET_PROTOCOL_ID());
// Reserved Field
- _res = plc4c_spi_write_unsigned_byte(buf, 8, 0x00);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, 0x00);
if(_res != OK) {
return _res;
}
// Implicit Field (len) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- _res = plc4c_spi_write_unsigned_short(buf, 16, (plc4c_s7_read_write_cotp_packet_length_in_bytes(_message->payload)) + (4));
+ _res = plc4c_spi_write_unsigned_short(io, 16, (plc4c_s7_read_write_cotp_packet_length_in_bytes(_message->payload)) + (4));
if(_res != OK) {
return _res;
}
// Simple Field (payload)
- _res = plc4c_s7_read_write_cotp_packet_serialize(buf, _message->payload);
+ _res = plc4c_s7_read_write_cotp_packet_serialize(io, _message->payload);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/spi/include/plc4c/spi/types_private.h b/sandbox/plc4c/spi/include/plc4c/spi/types_private.h
index 02fa91e..81a2049 100644
--- a/sandbox/plc4c/spi/include/plc4c/spi/types_private.h
+++ b/sandbox/plc4c/spi/include/plc4c/spi/types_private.h
@@ -222,14 +222,17 @@
size_t size;
union {
bool boolean_value;
- char char_value;
- unsigned char uchar_value;
- short short_value;
- unsigned short ushort_value;
- int int_value;
- unsigned int uint_value;
+ int8_t char_value;
+ uint8_t uchar_value;
+ int16_t short_value;
+ uint16_t ushort_value;
+ int32_t int_value;
+ uint32_t uint_value;
+ int64_t lint_value;
+ uint64_t ulint_value;
/* more */
float float_value;
+ double double_value;
char *pstring_value;
char *const_string_value;
void *pvoid_value;
diff --git a/sandbox/plc4c/spi/src/data.c b/sandbox/plc4c/spi/src/data.c
index 53284dd..6654e44 100644
--- a/sandbox/plc4c/spi/src/data.c
+++ b/sandbox/plc4c/spi/src/data.c
@@ -24,83 +24,93 @@
#include <stdint.h>
#include <stdio.h>
-plc4c_data *plc4c_data_create_boolean_data(bool b) {
+plc4c_data *plc4c_data_create_bool_data(bool b) {
plc4c_data *data = malloc(sizeof(plc4c_data));
data->data_type = PLC4C_BOOL;
data->size = sizeof(bool);
data->data.boolean_value = b;
+ data->custom_destroy = NULL;
+ data->custom_printf = NULL;
return data;
}
-plc4c_data *plc4c_data_create_char_data(char c) {
+plc4c_data *plc4c_data_create_int8_t_data(int8_t c) {
plc4c_data *data = malloc(sizeof(plc4c_data));
data->data_type = PLC4C_CHAR;
data->size = sizeof(char);
data->data.char_value = c;
+ data->custom_destroy = NULL;
+ data->custom_printf = NULL;
return data;
}
-plc4c_data *plc4c_data_create_uchar_data(unsigned char uc) {
+plc4c_data *plc4c_data_create_uint8_t_data(uint8_t uc) {
plc4c_data *data = malloc(sizeof(plc4c_data));
data->data_type = PLC4C_UCHAR;
data->size = sizeof(unsigned char);
data->data.uchar_value = uc;
+ data->custom_destroy = NULL;
+ data->custom_printf = NULL;
return data;
}
-plc4c_data *plc4c_data_create_short_data(short s) {
+plc4c_data *plc4c_data_create_int16_t_data(int16_t s) {
plc4c_data *data = malloc(sizeof(plc4c_data));
data->data_type = PLC4C_SHORT;
data->size = sizeof(short);
data->data.short_value = s;
+ data->custom_destroy = NULL;
+ data->custom_printf = NULL;
return data;
}
-plc4c_data *plc4c_data_create_ushort_data(unsigned short us) {
+plc4c_data *plc4c_data_create_uint16_t_data(uint16_t us) {
plc4c_data *data = malloc(sizeof(plc4c_data));
data->data_type = PLC4C_USHORT;
data->size = sizeof(unsigned short);
data->data.ushort_value = us;
+ data->custom_destroy = NULL;
+ data->custom_printf = NULL;
return data;
}
-plc4c_data *plc4c_data_create_int_data(int i) {
+plc4c_data *plc4c_data_create_int32_t_data(int32_t i) {
plc4c_data *data = malloc(sizeof(plc4c_data));
data->data_type = PLC4C_INT;
data->size = sizeof(int);
data->data.int_value = i;
+ data->custom_destroy = NULL;
+ data->custom_printf = NULL;
return data;
}
-plc4c_data *plc4c_data_create_uint_data(unsigned int ui) {
+plc4c_data *plc4c_data_create_uint32_t_data(uint32_t ui) {
plc4c_data *data = malloc(sizeof(plc4c_data));
data->data_type = PLC4C_UINT;
data->size = sizeof(unsigned int);
data->data.uint_value = ui;
+ data->custom_destroy = NULL;
+ data->custom_printf = NULL;
return data;
}
-plc4c_data *plc4c_data_create_string_data(unsigned int size, char *s) {
+plc4c_data *plc4c_data_create_int64_t_data(int64_t i) {
plc4c_data *data = malloc(sizeof(plc4c_data));
- data->data_type = PLC4C_STRING_POINTER;
- data->size = size;
- data->data.pstring_value = s;
+ data->data_type = PLC4C_LINT;
+ data->size = sizeof(int);
+ data->data.lint_value = i;
+ data->custom_destroy = NULL;
+ data->custom_printf = NULL;
return data;
}
-plc4c_data *plc4c_data_create_constant_string_data(unsigned int size, char *s) {
+plc4c_data *plc4c_data_create_uint64_t_data(uint64_t ui) {
plc4c_data *data = malloc(sizeof(plc4c_data));
- data->data_type = PLC4C_CONSTANT_STRING;
- data->size = size;
- data->data.const_string_value = s;
- return data;
-}
-
-plc4c_data *plc4c_data_create_void_pointer_data(void *v) {
- plc4c_data *data = malloc(sizeof(plc4c_data));
- data->data_type = PLC4C_VOID_POINTER;
- data->size = 0;
- data->data.pvoid_value = v;
+ data->data_type = PLC4C_ULINT;
+ data->size = sizeof(unsigned int);
+ data->data.ulint_value = ui;
+ data->custom_destroy = NULL;
+ data->custom_printf = NULL;
return data;
}
@@ -109,16 +119,61 @@
data->data_type = PLC4C_FLOAT;
data->size = sizeof(float);
data->data.float_value = f;
+ data->custom_destroy = NULL;
+ data->custom_printf = NULL;
+ return data;
+}
+
+plc4c_data *plc4c_data_create_double_data(double d) {
+ plc4c_data *data = malloc(sizeof(plc4c_data));
+ data->data_type = PLC4C_DOUBLE;
+ data->size = sizeof(float);
+ data->data.double_value = d;
+ data->custom_destroy = NULL;
+ data->custom_printf = NULL;
+ return data;
+}
+
+plc4c_data *plc4c_data_create_string_data(unsigned int size, char *s) {
+ plc4c_data *data = malloc(sizeof(plc4c_data));
+ data->data_type = PLC4C_STRING_POINTER;
+ data->size = size;
+ data->data.pstring_value = s;
+ data->custom_destroy = NULL;
+ data->custom_printf = NULL;
+ return data;
+}
+
+plc4c_data *plc4c_data_create_constant_string_data(unsigned int size, char *s) {
+ plc4c_data *data = malloc(sizeof(plc4c_data));
+ data->data_type = PLC4C_CONSTANT_STRING;
+ data->size = size;
+ data->data.const_string_value = s;
+ data->custom_destroy = NULL;
+ data->custom_printf = NULL;
+ return data;
+}
+
+plc4c_data *plc4c_data_create_void_pointer_data(void *v) {
+ plc4c_data *data = malloc(sizeof(plc4c_data));
+ data->data_type = PLC4C_VOID_POINTER;
+ data->size = 0;
+ data->data.pvoid_value = v;
+ data->custom_destroy = NULL;
+ data->custom_printf = NULL;
return data;
}
void plc4c_data_printf(plc4c_data *data) {
switch (data->data_type) {
+ case PLC4C_BOOL:
+ printf("%s", data->data.boolean_value ? "true" : "false");
+ break;
case PLC4C_CHAR:
- printf("%c", data->data.char_value);
+ printf("%d", data->data.char_value);
break;
case PLC4C_UCHAR:
- printf("%c", data->data.uchar_value);
+ printf("%d", data->data.uchar_value);
break;
case PLC4C_SHORT:
printf("%d", data->data.short_value);
@@ -132,6 +187,12 @@
case PLC4C_UINT:
printf("%iu", data->data.uint_value);
break;
+ case PLC4C_LINT:
+ printf("%d", data->data.lint_value);
+ break;
+ case PLC4C_ULINT:
+ printf("%d", data->data.ulint_value);
+ break;
case PLC4C_FLOAT:
printf("%f", data->data.float_value);
break;