You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2020/06/04 13:10:49 UTC
[plc4x] branch feature/c-code-generation updated: - Continued
implementing the templates for gnerating C parsers/serializers
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch feature/c-code-generation
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/feature/c-code-generation by this push:
new 8799494 - Continued implementing the templates for gnerating C parsers/serializers
8799494 is described below
commit 879949431cc07f6c57d3be26047df1a713ce2435
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Thu Jun 4 15:10:41 2020 +0200
- Continued implementing the templates for gnerating C parsers/serializers
---
.../plc4x/language/c/CLanguageTemplateHelper.java | 350 +++++++++++++++------
.../resources/templates/c/pojo-template-c.ftlh | 44 ++-
.../resources/templates/c/pojo-template-h.ftlh | 70 +++--
.../resources/templates/java/pojo-template.ftlh | 2 +
.../s7/src/main/resources/protocols/s7/s7.mspec | 4 +-
.../generated-sources/modbus/includes/modbus_pdu.h | 11 +
.../includes/modbus_pdu_read_file_record_request.h | 2 +-
.../modbus_pdu_read_file_record_response.h | 2 +-
.../modbus_pdu_write_file_record_request.h | 2 +-
.../modbus_pdu_write_file_record_response.h | 2 +-
.../modbus/src/modbus_constants.c | 7 +-
.../generated-sources/modbus/src/modbus_pdu.c | 234 +++++++++-----
.../modbus/src/modbus_pdu_diagnostic_request.c | 9 +-
.../modbus/src/modbus_pdu_error.c | 8 +-
.../src/modbus_pdu_get_com_event_log_request.c | 7 +-
.../src/modbus_pdu_get_com_event_log_response.c | 10 +-
...odbus_pdu_mask_write_holding_register_request.c | 10 +-
...dbus_pdu_mask_write_holding_register_response.c | 10 +-
.../modbus/src/modbus_pdu_read_coils_request.c | 9 +-
.../modbus/src/modbus_pdu_read_coils_response.c | 7 +-
...modbus_pdu_read_device_identification_request.c | 7 +-
...odbus_pdu_read_device_identification_response.c | 7 +-
.../src/modbus_pdu_read_discrete_inputs_request.c | 9 +-
.../src/modbus_pdu_read_discrete_inputs_response.c | 7 +-
.../src/modbus_pdu_read_exception_status_request.c | 7 +-
.../modbus_pdu_read_exception_status_response.c | 8 +-
.../src/modbus_pdu_read_fifo_queue_request.c | 8 +-
.../src/modbus_pdu_read_fifo_queue_response.c | 7 +-
.../src/modbus_pdu_read_file_record_request.c | 7 +-
.../src/modbus_pdu_read_file_record_request_item.c | 11 +-
.../src/modbus_pdu_read_file_record_response.c | 7 +-
.../modbus_pdu_read_file_record_response_item.c | 8 +-
.../modbus_pdu_read_holding_registers_request.c | 9 +-
.../modbus_pdu_read_holding_registers_response.c | 7 +-
.../src/modbus_pdu_read_input_registers_request.c | 9 +-
.../src/modbus_pdu_read_input_registers_response.c | 7 +-
...read_write_multiple_holding_registers_request.c | 11 +-
...ead_write_multiple_holding_registers_response.c | 7 +-
.../src/modbus_pdu_report_server_id_request.c | 7 +-
.../src/modbus_pdu_report_server_id_response.c | 7 +-
.../src/modbus_pdu_write_file_record_request.c | 7 +-
.../modbus_pdu_write_file_record_request_item.c | 10 +-
.../src/modbus_pdu_write_file_record_response.c | 7 +-
.../modbus_pdu_write_file_record_response_item.c | 10 +-
.../src/modbus_pdu_write_multiple_coils_request.c | 9 +-
.../src/modbus_pdu_write_multiple_coils_response.c | 9 +-
..._pdu_write_multiple_holding_registers_request.c | 9 +-
...pdu_write_multiple_holding_registers_response.c | 9 +-
.../src/modbus_pdu_write_single_coil_request.c | 9 +-
.../src/modbus_pdu_write_single_coil_response.c | 9 +-
.../src/modbus_pdu_write_single_register_request.c | 9 +-
.../modbus_pdu_write_single_register_response.c | 9 +-
.../modbus/src/modbus_serial_adu.c | 11 +-
.../generated-sources/modbus/src/modbus_tcp_adu.c | 10 +-
.../generated-sources/s7/includes/cotp_packet.h | 9 +
.../s7/includes/cotp_packet_connection_request.h | 4 +-
.../s7/includes/cotp_packet_connection_response.h | 4 +-
.../s7/includes/cotp_packet_data.h | 2 +-
.../s7/includes/cotp_packet_disconnect_request.h | 4 +-
.../s7/includes/cotp_packet_disconnect_response.h | 2 +-
.../s7/includes/cotp_packet_tpdu_error.h | 2 +-
.../generated-sources/s7/includes/cotp_parameter.h | 9 +
.../s7/includes/cotp_parameter_tpdu_size.h | 2 +-
.../generated-sources/s7/includes/cotp_tpdu_size.h | 2 +-
.../generated-sources/s7/includes/s7_address.h | 9 +
.../generated-sources/s7/includes/s7_address_any.h | 2 +-
.../generated-sources/s7/includes/s7_message.h | 9 +
.../s7/includes/s7_message_request.h | 2 +-
.../s7/includes/s7_message_response.h | 2 +-
.../s7/includes/s7_message_response_data.h | 2 +-
.../s7/includes/s7_message_user_data.h | 2 +-
.../generated-sources/s7/includes/s7_parameter.h | 10 +
.../s7/includes/s7_parameter_read_var_request.h | 2 +-
.../s7/includes/s7_parameter_user_data.h | 2 +-
.../s7/includes/s7_parameter_user_data_item.h | 9 +
.../s7/includes/s7_parameter_write_var_request.h | 2 +-
.../generated-sources/s7/includes/s7_payload.h | 13 +-
.../s7/includes/s7_payload_read_var_response.h | 5 +-
.../s7/includes/s7_payload_user_data.h | 5 +-
.../s7/includes/s7_payload_user_data_item.h | 9 +
..._user_data_item_cpu_function_read_szl_request.h | 2 +-
...user_data_item_cpu_function_read_szl_response.h | 4 +-
.../s7/includes/s7_payload_write_var_request.h | 5 +-
.../s7/includes/s7_payload_write_var_response.h | 5 +-
.../s7/includes/s7_var_request_parameter_item.h | 9 +
.../plc4c/generated-sources/s7/src/cotp_packet.c | 54 +++-
.../s7/src/cotp_packet_connection_request.c | 9 +-
.../s7/src/cotp_packet_connection_response.c | 9 +-
.../generated-sources/s7/src/cotp_packet_data.c | 9 +-
.../s7/src/cotp_packet_disconnect_request.c | 9 +-
.../s7/src/cotp_packet_disconnect_response.c | 9 +-
.../s7/src/cotp_packet_tpdu_error.c | 9 +-
.../generated-sources/s7/src/cotp_parameter.c | 48 ++-
.../s7/src/cotp_parameter_called_tsap.c | 8 +-
.../s7/src/cotp_parameter_calling_tsap.c | 8 +-
.../s7/src/cotp_parameter_checksum.c | 8 +-
...p_parameter_disconnect_additional_information.c | 7 +-
.../s7/src/cotp_parameter_tpdu_size.c | 7 +-
.../plc4c/generated-sources/s7/src/s7_address.c | 24 +-
.../generated-sources/s7/src/s7_address_any.c | 11 +-
.../plc4c/generated-sources/s7/src/s7_message.c | 43 ++-
.../generated-sources/s7/src/s7_message_request.c | 7 +-
.../generated-sources/s7/src/s7_message_response.c | 9 +-
.../s7/src/s7_message_response_data.c | 9 +-
.../s7/src/s7_message_user_data.c | 7 +-
.../plc4c/generated-sources/s7/src/s7_parameter.c | 54 +++-
.../s7/src/s7_parameter_read_var_request.c | 7 +-
.../s7/src/s7_parameter_read_var_response.c | 8 +-
.../s7/src/s7_parameter_setup_communication.c | 10 +-
.../s7/src/s7_parameter_user_data.c | 7 +-
.../s7/src/s7_parameter_user_data_item.c | 24 +-
.../s7_parameter_user_data_item_cpu_functions.c | 12 +-
.../s7/src/s7_parameter_write_var_request.c | 7 +-
.../s7/src/s7_parameter_write_var_response.c | 8 +-
.../plc4c/generated-sources/s7/src/s7_payload.c | 44 ++-
.../s7/src/s7_payload_read_var_response.c | 9 +-
.../s7/src/s7_payload_user_data.c | 9 +-
.../s7/src/s7_payload_user_data_item.c | 32 +-
..._user_data_item_cpu_function_read_szl_request.c | 7 +-
...user_data_item_cpu_function_read_szl_response.c | 7 +-
.../s7/src/s7_payload_write_var_request.c | 9 +-
.../s7/src/s7_payload_write_var_response.c | 9 +-
.../s7/src/s7_var_payload_data_item.c | 8 +-
.../s7/src/s7_var_payload_status_item.c | 7 +-
.../s7/src/s7_var_request_parameter_item.c | 24 +-
.../s7/src/s7_var_request_parameter_item_address.c | 8 +-
.../generated-sources/s7/src/szl_data_tree_item.c | 11 +-
sandbox/plc4c/generated-sources/s7/src/szl_id.c | 8 +-
.../plc4c/generated-sources/s7/src/tpkt_packet.c | 8 +-
129 files changed, 1289 insertions(+), 586 deletions(-)
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 436ccde..40367c9 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
@@ -28,7 +28,6 @@ import org.apache.plc4x.plugins.codegenerator.types.enums.EnumValue;
import org.apache.plc4x.plugins.codegenerator.types.fields.*;
import org.apache.plc4x.plugins.codegenerator.types.references.*;
import org.apache.plc4x.plugins.codegenerator.types.terms.*;
-import sun.tools.tree.ArrayExpression;
import java.util.*;
import java.util.function.Function;
@@ -63,6 +62,7 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
/**
* Check if this is an abstract type ...
+ *
* @param typeDefinition the type definition
* @return true if this is an abstract type
*/
@@ -78,12 +78,23 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
return typeDefinition instanceof DiscriminatedComplexTypeDefinition;
}
- public List<DiscriminatedComplexTypeDefinition> getDiscriminatedSubTypes(
- ComplexTypeDefinition complexTypeDefinition) {
- // Sebastian would be proud of me ;-)
- SwitchField switchField = (SwitchField) complexTypeDefinition.getFields().stream().filter(
- field -> field instanceof SwitchField).findFirst().orElse(null);
- if(switchField != null) {
+ private SwitchField getSwitchField() {
+ return getSwitchField(thisType);
+ }
+
+ private SwitchField getSwitchField(TypeDefinition type) {
+ if (type instanceof ComplexTypeDefinition) {
+ ComplexTypeDefinition complexTypeDefinition = (ComplexTypeDefinition) type;
+ // Sebastian would be proud of me ;-)
+ return (SwitchField) complexTypeDefinition.getFields().stream().filter(
+ field -> field instanceof SwitchField).findFirst().orElse(null);
+ }
+ return null;
+ }
+
+ public List<DiscriminatedComplexTypeDefinition> getDiscriminatedSubTypes() {
+ SwitchField switchField = getSwitchField();
+ if (switchField != null) {
return switchField.getCases();
}
return Collections.emptyList();
@@ -131,13 +142,12 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
public String camelCaseToSnakeCase(String camelCase) {
StringBuilder snakeCase = new StringBuilder();
final char[] chars = camelCase.toCharArray();
- for(int i = 0; i < chars.length; i++) {
+ for (int i = 0; i < chars.length; i++) {
String lowerCaseChar = String.valueOf(chars[i]).toLowerCase();
// If the previous letter is a lowercase letter and this one is uppercase, create a new snake-segment.
if ((i > 0) && !Character.isUpperCase(chars[i - 1]) && Character.isUpperCase(chars[i])) {
snakeCase.append('_').append(lowerCaseChar);
- }
- else if((i < (chars.length - 2)) && Character.isUpperCase(chars[i]) && !Character.isUpperCase(chars[i + 1])) {
+ } else if ((i < (chars.length - 2)) && Character.isUpperCase(chars[i]) && !Character.isUpperCase(chars[i + 1])) {
snakeCase.append('_').append(lowerCaseChar);
}
// If this is uppercase and the previous one is too ... just make this letter lowercase.
@@ -177,7 +187,7 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
}
}
// If this is an array with variable length, then we have to use our "plc4c_list" to store the data.
- if((field instanceof ArrayField) && (!isFixedValueExpression(((ArrayField) field).getLoopExpression()))) {
+ if ((field instanceof ArrayField) && (!isFixedValueExpression(((ArrayField) field).getLoopExpression()))) {
return "plc4c_list";
}
TypeReference typeReference = field.getType();
@@ -201,19 +211,19 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
case UINT:
case INT: {
StringBuilder sb = new StringBuilder();
- if(simpleTypeReference.getBaseType() == SimpleTypeReference.SimpleBaseType.UINT) {
+ if (simpleTypeReference.getBaseType() == SimpleTypeReference.SimpleBaseType.UINT) {
sb.append("u");
}
- if(simpleTypeReference.getSizeInBits() % 64 == 0) {
+ if (simpleTypeReference.getSizeInBits() % 64 == 0) {
sb.append("int64_t");
- } else if(simpleTypeReference.getSizeInBits() % 32 == 0) {
+ } else if (simpleTypeReference.getSizeInBits() % 32 == 0) {
sb.append("int32_t");
- } else if(simpleTypeReference.getSizeInBits() % 16 == 0) {
+ } else if (simpleTypeReference.getSizeInBits() % 16 == 0) {
sb.append("int16_t");
- } else if(simpleTypeReference.getSizeInBits() % 8 == 0) {
+ } else if (simpleTypeReference.getSizeInBits() % 8 == 0) {
sb.append("int8_t");
} else {
- if(simpleTypeReference.getBaseType() == SimpleTypeReference.SimpleBaseType.UINT) {
+ if (simpleTypeReference.getBaseType() == SimpleTypeReference.SimpleBaseType.UINT) {
// We already have the "u" in there ...
sb.append("nsigned ");
}
@@ -250,13 +260,13 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
}
public String getLoopExpressionSuffix(TypedField field) {
- if(field instanceof ArrayField) {
+ if (field instanceof ArrayField) {
ArrayField arrayField = (ArrayField) field;
- if(arrayField.getLoopType() == ArrayField.LoopType.COUNT) {
+ if (arrayField.getLoopType() == ArrayField.LoopType.COUNT) {
Term countTerm = arrayField.getLoopExpression();
if (isFixedValueExpression(countTerm)) {
int evaluatedCount = evaluateFixedValueExpression(countTerm);
- return "[" + evaluatedCount +"]";
+ return "[" + evaluatedCount + "]";
}
}
}
@@ -279,7 +289,7 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
case UINT:
case INT:
// If the bit-size is exactly one of the built-in tpye-sizes, omit the suffix.
- if((simpleTypeReference.getSizeInBits() == 8) || (simpleTypeReference.getSizeInBits() == 16) ||
+ if ((simpleTypeReference.getSizeInBits() == 8) || (simpleTypeReference.getSizeInBits() == 16) ||
(simpleTypeReference.getSizeInBits() == 32) || (simpleTypeReference.getSizeInBits() == 64)) {
return "";
}
@@ -287,7 +297,7 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
case FLOAT:
case UFLOAT:
// If the bit-size is exactly one of the built-in tpye-sizes, omit the suffix.
- if((simpleTypeReference.getSizeInBits() == 32) || (simpleTypeReference.getSizeInBits() == 64)) {
+ if ((simpleTypeReference.getSizeInBits() == 32) || (simpleTypeReference.getSizeInBits() == 64)) {
return "";
}
return " : " + simpleTypeReference.getSizeInBits();
@@ -337,9 +347,9 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
public String escapeEnumValue(TypeReference typeReference, String valueString) {
// Currently the only case in which here complex type references are used are when referencing enum constants.
- if(typeReference instanceof ComplexTypeReference) {
+ if (typeReference instanceof ComplexTypeReference) {
// C doesn't like NULL values for enums, so we have to return something else (we'll treat -1 as NULL)
- if("null".equals(valueString)) {
+ if ("null".equals(valueString)) {
return "-1";
}
ComplexTypeReference complexTypeReference = (ComplexTypeReference) typeReference;
@@ -364,22 +374,23 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
/**
* Check if the expression doesn't reference any variables.
* If this is the case, the expression can be evaluated at code-generation time.
+ *
* @param term term
* @return true if it doesn't reference any variable literals.
*/
private boolean isFixedValueExpression(Term term) {
- if(term instanceof VariableLiteral) {
+ if (term instanceof VariableLiteral) {
return false;
}
- if(term instanceof UnaryTerm) {
+ if (term instanceof UnaryTerm) {
UnaryTerm unaryTerm = (UnaryTerm) term;
return isFixedValueExpression(unaryTerm.getA());
}
- if(term instanceof BinaryTerm) {
+ if (term instanceof BinaryTerm) {
BinaryTerm binaryTerm = (BinaryTerm) term;
return isFixedValueExpression(binaryTerm.getA()) && isFixedValueExpression(binaryTerm.getB());
}
- if(term instanceof TernaryTerm) {
+ if (term instanceof TernaryTerm) {
TernaryTerm ternaryTerm = (TernaryTerm) term;
return isFixedValueExpression(ternaryTerm.getA()) && isFixedValueExpression(ternaryTerm.getB()) &&
isFixedValueExpression(ternaryTerm.getC());
@@ -393,25 +404,25 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
}
private String toString(Term term) {
- if(term instanceof NullLiteral) {
+ if (term instanceof NullLiteral) {
return "null";
}
- if(term instanceof BooleanLiteral) {
+ if (term instanceof BooleanLiteral) {
return Boolean.toString(((BooleanLiteral) term).getValue());
}
- if(term instanceof NumericLiteral) {
+ if (term instanceof NumericLiteral) {
return ((NumericLiteral) term).getNumber().toString();
}
- if(term instanceof StringLiteral) {
+ if (term instanceof StringLiteral) {
return "\"" + ((StringLiteral) term).getValue() + "\"";
}
- if(term instanceof UnaryTerm) {
+ if (term instanceof UnaryTerm) {
return ((UnaryTerm) term).getOperation() + toString(((UnaryTerm) term).getA());
}
- if(term instanceof BinaryTerm) {
+ if (term instanceof BinaryTerm) {
return toString(((BinaryTerm) term).getA()) + ((BinaryTerm) term).getOperation() + toString(((BinaryTerm) term).getB());
}
- if(term instanceof TernaryTerm) {
+ if (term instanceof TernaryTerm) {
return "(" + toString(((TernaryTerm) term).getA()) + ") ? (" + toString(((TernaryTerm) term).getB()) +
") : (" + toString(((TernaryTerm) term).getC()) + ")";
}
@@ -457,7 +468,7 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
}
case FLOAT: {
FloatTypeReference floatTypeReference = (FloatTypeReference) simpleTypeReference;
- if(floatTypeReference.getSizeInBits() <= 32) {
+ if (floatTypeReference.getSizeInBits() <= 32) {
return "plc4c_spi_read_float(buf, " + floatTypeReference.getSizeInBits() + ")";
} else {
return "plc4c_spi_read_double(buf, " + floatTypeReference.getSizeInBits() + ")";
@@ -472,18 +483,6 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
return "Hurz";
}
- public Collection<String> switchTypeImports() {
- if(thisType instanceof ComplexTypeDefinition) {
- ComplexTypeDefinition complexTypeDefinition = (ComplexTypeDefinition) thisType;
- SwitchField switchField = (SwitchField) complexTypeDefinition.getFields().stream().filter(field -> field instanceof SwitchField).findFirst().orElse(null);
- if(switchField != null) {
- return switchField.getCases().stream().map(
- sc -> camelCaseToSnakeCase(sc.getName())).collect(Collectors.toList());
- }
- }
- return Collections.emptyList();
- }
-
public String toSwitchExpression(String expression) {
StringBuilder sb = new StringBuilder();
Pattern pattern = Pattern.compile("([^\\.]*)\\.([a-zA-Z\\d]+)(.*)");
@@ -507,22 +506,22 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
}
private String toExpression(TypedField field, Term term, Function<Term, String> variableExpressionGenerator) {
- if(term == null) {
+ if (term == null) {
return "";
}
- if(term instanceof Literal) {
- if(term instanceof NullLiteral) {
+ if (term instanceof Literal) {
+ if (term instanceof NullLiteral) {
return "null";
- } else if(term instanceof BooleanLiteral) {
+ } else if (term instanceof BooleanLiteral) {
return Boolean.toString(((BooleanLiteral) term).getValue());
- } else if(term instanceof NumericLiteral) {
+ } else if (term instanceof NumericLiteral) {
return ((NumericLiteral) term).getNumber().toString();
- } else if(term instanceof StringLiteral) {
+ } else if (term instanceof StringLiteral) {
return "\"" + ((StringLiteral) term).getValue() + "\"";
- } else if(term instanceof VariableLiteral) {
+ } else if (term instanceof VariableLiteral) {
VariableLiteral variableLiteral = (VariableLiteral) term;
// If this literal references an Enum type, then we have to output it differently.
- if(types.get(variableLiteral.getName()) instanceof EnumTypeDefinition) {
+ if (types.get(variableLiteral.getName()) instanceof EnumTypeDefinition) {
return variableLiteral.getName() + "." + variableLiteral.getChild().getName();
} else {
return variableExpressionGenerator.apply(term);
@@ -533,7 +532,7 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
} else if (term instanceof UnaryTerm) {
UnaryTerm ut = (UnaryTerm) term;
Term a = ut.getA();
- switch(ut.getOperation()) {
+ switch (ut.getOperation()) {
case "!":
return "!(" + toExpression(field, a, variableExpressionGenerator) + ")";
case "-":
@@ -556,11 +555,11 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
}
} else if (term instanceof TernaryTerm) {
TernaryTerm tt = (TernaryTerm) term;
- if("if".equals(tt.getOperation())) {
+ if ("if".equals(tt.getOperation())) {
Term a = tt.getA();
Term b = tt.getB();
Term c = tt.getC();
- return "((" + toExpression(field, a, variableExpressionGenerator) + ") ? " + toExpression(field, b, variableExpressionGenerator) + " : " + toExpression(field, c, variableExpressionGenerator) + ")";
+ return "((" + toExpression(field, a, variableExpressionGenerator) + ") ? " + toExpression(field, b, variableExpressionGenerator) + " : " + toExpression(field, c, variableExpressionGenerator) + ")";
} else {
throw new RuntimeException("Unsupported ternary operation type " + tt.getOperation());
}
@@ -572,18 +571,17 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
private String toVariableParseExpression(TypedField field, Term term, Argument[] parserArguments) {
VariableLiteral vl = (VariableLiteral) term;
// CAST expressions are special as we need to add a ".class" to the second parameter in Java.
- if("CAST".equals(vl.getName())) {
+ if ("CAST".equals(vl.getName())) {
StringBuilder sb = new StringBuilder(vl.getName());
- if((vl.getArgs() == null) || (vl.getArgs().size() != 2)) {
+ if ((vl.getArgs() == null) || (vl.getArgs().size() != 2)) {
throw new RuntimeException("A CAST expression expects exactly two arguments.");
}
sb.append("(").append(toVariableParseExpression(field, vl.getArgs().get(0), parserArguments))
.append(", ").append(((VariableLiteral) vl.getArgs().get(1)).getName()).append(".class)");
return sb.toString() + ((vl.getChild() != null) ? "." + toVariableExpressionRest(vl.getChild()) : "");
- }
- else if("STATIC_CALL".equals(vl.getName())) {
+ } else if ("STATIC_CALL".equals(vl.getName())) {
StringBuilder sb = new StringBuilder();
- if(!(vl.getArgs().get(0) instanceof StringLiteral)) {
+ if (!(vl.getArgs().get(0) instanceof StringLiteral)) {
throw new RuntimeException("Expecting the first argument of a 'STATIC_CALL' to be a StringLiteral");
}
// Get the class and method name
@@ -591,17 +589,17 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
// Cut off the double-quptes
methodName = methodName.substring(1, methodName.length() - 1);
sb.append(methodName).append("(");
- for(int i = 1; i < vl.getArgs().size(); i++) {
+ for (int i = 1; i < vl.getArgs().size(); i++) {
Term arg = vl.getArgs().get(i);
- if(i > 1) {
+ if (i > 1) {
sb.append(", ");
}
- if(arg instanceof VariableLiteral) {
+ if (arg instanceof VariableLiteral) {
VariableLiteral va = (VariableLiteral) arg;
// "io" is the default name of the reader argument which is always available.
boolean isParserArg = "io".equals(va.getName());
boolean isTypeArg = "_type".equals(va.getName());
- if(!isParserArg && !isTypeArg && parserArguments != null) {
+ if (!isParserArg && !isTypeArg && parserArguments != null) {
for (Argument parserArgument : parserArguments) {
if (parserArgument.getName().equals(va.getName())) {
isParserArg = true;
@@ -609,11 +607,11 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
}
}
}
- if(isParserArg) {
+ if (isParserArg) {
sb.append(va.getName() + ((va.getChild() != null) ? "." + toVariableExpressionRest(va.getChild()) : ""));
}
// We have to manually evaluate the type information at code-generation time.
- else if(isTypeArg) {
+ else if (isTypeArg) {
String part = va.getChild().getName();
switch (part) {
case "name":
@@ -632,7 +630,7 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
} else {
sb.append(toVariableParseExpression(field, va, null));
}
- } else if(arg instanceof StringLiteral) {
+ } else if (arg instanceof StringLiteral) {
sb.append(((StringLiteral) arg).getValue());
}
}
@@ -640,13 +638,13 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
return sb.toString();
}
// All uppercase names are not fields, but utility methods.
- else if(vl.getName().equals(vl.getName().toUpperCase())) {
+ else if (vl.getName().equals(vl.getName().toUpperCase())) {
StringBuilder sb = new StringBuilder(vl.getName());
- if(vl.getArgs() != null) {
+ if (vl.getArgs() != null) {
sb.append("(");
boolean firstArg = true;
- for(Term arg : vl.getArgs()) {
- if(!firstArg) {
+ for (Term arg : vl.getArgs()) {
+ if (!firstArg) {
sb.append(", ");
}
sb.append(toParseExpression(field, arg, parserArguments));
@@ -654,7 +652,7 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
}
sb.append(")");
}
- if(vl.getIndex() != VariableLiteral.NO_INDEX) {
+ if (vl.getIndex() != VariableLiteral.NO_INDEX) {
sb.append("[").append(vl.getIndex()).append("]");
}
return sb.toString() + ((vl.getChild() != null) ? "." + toVariableExpressionRest(vl.getChild()) : "");
@@ -664,25 +662,25 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
private String toVariableSerializationExpression(TypedField field, Term term, Argument[] serialzerArguments) {
VariableLiteral vl = (VariableLiteral) term;
- if("STATIC_CALL".equals(vl.getName())) {
+ if ("STATIC_CALL".equals(vl.getName())) {
StringBuilder sb = new StringBuilder();
- if(!(vl.getArgs().get(0) instanceof StringLiteral)) {
+ if (!(vl.getArgs().get(0) instanceof StringLiteral)) {
throw new RuntimeException("Expecting the first argument of a 'STATIC_CALL' to be a StringLiteral");
}
String methodName = ((StringLiteral) vl.getArgs().get(0)).getValue();
methodName = methodName.substring(1, methodName.length() - 1);
sb.append(methodName).append("(");
- for(int i = 1; i < vl.getArgs().size(); i++) {
+ for (int i = 1; i < vl.getArgs().size(); i++) {
Term arg = vl.getArgs().get(i);
- if(i > 1) {
+ if (i > 1) {
sb.append(", ");
}
- if(arg instanceof VariableLiteral) {
+ if (arg instanceof VariableLiteral) {
VariableLiteral va = (VariableLiteral) arg;
// "io" and "_value" are always available in every parser.
boolean isSerializerArg = "io".equals(va.getName()) || "_value".equals(va.getName()) || "element".equals(va.getName());
boolean isTypeArg = "_type".equals(va.getName());
- if(!isSerializerArg && !isTypeArg && serialzerArguments != null) {
+ if (!isSerializerArg && !isTypeArg && serialzerArguments != null) {
for (Argument serializerArgument : serialzerArguments) {
if (serializerArgument.getName().equals(va.getName())) {
isSerializerArg = true;
@@ -690,9 +688,9 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
}
}
}
- if(isSerializerArg) {
+ if (isSerializerArg) {
sb.append(va.getName() + ((va.getChild() != null) ? "." + toVariableExpressionRest(va.getChild()) : ""));
- } else if(isTypeArg) {
+ } else if (isTypeArg) {
String part = va.getChild().getName();
switch (part) {
case "name":
@@ -711,7 +709,7 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
} else {
sb.append(toVariableSerializationExpression(field, va, null));
}
- } else if(arg instanceof StringLiteral) {
+ } else if (arg instanceof StringLiteral) {
sb.append(((StringLiteral) arg).getValue());
}
}
@@ -739,21 +737,21 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
}
}*/
// All uppercase names are not fields, but utility methods.
- else if(vl.getName().equals(vl.getName().toUpperCase())) {
+ else if (vl.getName().equals(vl.getName().toUpperCase())) {
StringBuilder sb = new StringBuilder(vl.getName());
- if(vl.getArgs() != null) {
+ if (vl.getArgs() != null) {
sb.append("(");
boolean firstArg = true;
- for(Term arg : vl.getArgs()) {
- if(!firstArg) {
+ for (Term arg : vl.getArgs()) {
+ if (!firstArg) {
sb.append(", ");
}
- if(arg instanceof VariableLiteral) {
+ if (arg instanceof VariableLiteral) {
VariableLiteral va = (VariableLiteral) arg;
boolean isSerializerArg = "io".equals(va.getName());
boolean isTypeArg = "_type".equals(va.getName());
- if(!isSerializerArg && !isTypeArg && serialzerArguments != null) {
+ if (!isSerializerArg && !isTypeArg && serialzerArguments != null) {
for (Argument serializerArgument : serialzerArguments) {
if (serializerArgument.getName().equals(va.getName())) {
isSerializerArg = true;
@@ -761,9 +759,9 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
}
}
}
- if(isSerializerArg) {
+ if (isSerializerArg) {
sb.append(va.getName() + ((va.getChild() != null) ? "." + toVariableExpressionRest(va.getChild()) : ""));
- } else if(isTypeArg) {
+ } else if (isTypeArg) {
String part = va.getChild().getName();
switch (part) {
case "name":
@@ -782,7 +780,7 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
} else {
sb.append(toVariableSerializationExpression(field, va, null));
}
- } else if(arg instanceof StringLiteral) {
+ } else if (arg instanceof StringLiteral) {
sb.append(((StringLiteral) arg).getValue());
}
firstArg = false;
@@ -794,7 +792,7 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
// The synthetic checksumRawData is a local field and should not be accessed as bean property.
boolean isSerializerArg = "checksumRawData".equals(vl.getName()) || "_value".equals(vl.getName()) || "element".equals(vl.getName());
boolean isTypeArg = "_type".equals(vl.getName());
- if(!isSerializerArg && !isTypeArg && serialzerArguments != null) {
+ if (!isSerializerArg && !isTypeArg && serialzerArguments != null) {
for (Argument serializerArgument : serialzerArguments) {
if (serializerArgument.getName().equals(vl.getName())) {
isSerializerArg = true;
@@ -802,20 +800,20 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
}
}
}
- if(isSerializerArg) {
+ if (isSerializerArg) {
return vl.getName() + ((vl.getChild() != null) ? "." + toVariableExpressionRest(vl.getChild()) : "");
- } else if(isTypeArg) {
+ } else if (isTypeArg) {
String part = vl.getChild().getName();
switch (part) {
case "name":
- return"\"" + field.getTypeName() + "\"";
+ return "\"" + field.getTypeName() + "\"";
case "length":
- return"\"" + ((SimpleTypeReference) field).getSizeInBits() + "\"";
+ return "\"" + ((SimpleTypeReference) field).getSizeInBits() + "\"";
case "encoding":
String encoding = ((StringTypeReference) field.getType()).getEncoding();
// Cut off the single quotes.
encoding = encoding.substring(1, encoding.length() - 1);
- return"\"" + encoding + "\"";
+ return "\"" + encoding + "\"";
default:
return "";
}
@@ -855,7 +853,7 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
public String getReservedValue(ReservedField reservedField) {
final String languageTypeName = getLanguageTypeName(reservedField.getType());
- if("BigInteger".equals(languageTypeName)) {
+ if ("BigInteger".equals(languageTypeName)) {
return "BigInteger.valueOf(" + reservedField.getReferenceValue() + ")";
} else {
return "(" + languageTypeName + ") " + reservedField.getReferenceValue();
@@ -863,7 +861,7 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
}
public SimpleTypeReference getEnumBaseType(TypeReference enumType) {
- if(!(enumType instanceof ComplexTypeReference)) {
+ if (!(enumType instanceof ComplexTypeReference)) {
throw new RuntimeException("type reference for enum types must be of type complex type");
}
ComplexTypeReference complexType = (ComplexTypeReference) enumType;
@@ -871,4 +869,152 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
return (SimpleTypeReference) enumTypeDefinition.getType();
}
+ public Collection<String> getIncludeTypesForHFiles() {
+ Set<String> imports = new TreeSet<>();
+ // Add all the complex types references in parser arguments.
+ if (thisType.getParserArguments() != null) {
+ for (Argument parserArgument : thisType.getParserArguments()) {
+ if (parserArgument.getType() instanceof ComplexTypeReference) {
+ ComplexTypeReference complexTypeReference = (ComplexTypeReference) parserArgument.getType();
+ imports.add(camelCaseToSnakeCase(complexTypeReference.getName()));
+ }
+ }
+ }
+ // Add all the complex types referenced in field declarations.
+ for (ComplexTypeReference complexTypeReferencesInField : getComplexTypeReferencesInFields()) {
+ imports.add(camelCaseToSnakeCase(complexTypeReferencesInField.getName()));
+ }
+ // If this is a discriminated tpye, add an import to the parent type.
+ if (thisType instanceof DiscriminatedComplexTypeDefinition) {
+ DiscriminatedComplexTypeDefinition dicriminatedType = (DiscriminatedComplexTypeDefinition) thisType;
+ imports.add(camelCaseToSnakeCase(dicriminatedType.getParentType().getName()));
+ }
+ return imports;
+ }
+
+ public Collection<String> getIncludeTypesForCFiles() {
+ List<String> imports = new LinkedList<>();
+ SwitchField switchField = getSwitchField();
+ if (switchField != null) {
+ imports.addAll(switchField.getCases().stream().map(
+ sc -> camelCaseToSnakeCase(sc.getName())).collect(Collectors.toList()));
+ }
+ // Add a reference to the current types header file itself.
+ imports.add(camelCaseToSnakeCase(thisType.getName()));
+ return imports;
+ }
+
+ private String getDiscriminatorName(String discriminatorExpression) {
+ return discriminatorExpression.replaceAll("[.\\[\\]()]", "_");
+ }
+
+ private Optional<TypeReference> getDiscriminatorType(ComplexTypeDefinition parentType, String disciminatorExpression) {
+ final String fieldName = (disciminatorExpression.contains(".")) ?
+ disciminatorExpression.substring(0, disciminatorExpression.indexOf('.')) : disciminatorExpression;
+ final String rest = (disciminatorExpression.contains(".")) ?
+ disciminatorExpression.substring(disciminatorExpression.indexOf('.') + 1) : null;
+
+ Optional<TypeReference> type = Optional.empty();
+ // Check if this segment is referring to a field.
+ final Optional<Field> regularField = parentType.getFields().stream().filter(field ->
+ ((field instanceof PropertyField) && ((PropertyField) field).getName().equals(fieldName)) ||
+ ((field instanceof ImplicitField) && ((ImplicitField) field).getName().equals(fieldName)) ||
+ ((field instanceof DiscriminatorField) && ((DiscriminatorField) field).getName().equals(fieldName))).findFirst();
+ if (regularField.isPresent()) {
+ final Field field = regularField.get();
+ if (field instanceof PropertyField) {
+ type = Optional.of(((PropertyField) field).getType());
+ } else if (field instanceof ImplicitField) {
+ type = Optional.of(((ImplicitField) field).getType());
+ } else if (field instanceof DiscriminatorField) {
+ type = Optional.of(((DiscriminatorField) field).getType());
+ }
+ }
+
+ // If we haven't found a field with the given name, continue searching in the arguments.
+ if (!type.isPresent()) {
+ // Check if this segment is referring to an argument.
+ final Optional<Argument> argument = Arrays.stream(parentType.getParserArguments()).filter(
+ curArgument -> curArgument.getName().equals(fieldName)).findFirst();
+ if(argument.isPresent()) {
+ type = Optional.of(argument.get().getType());
+ }
+ }
+
+ // If we found something but there's a "rest" left, we got to use the type we
+ // found in this level, get that type's definition and continue from there.
+ if (type.isPresent() && (rest != null)) {
+ TypeReference typeReference = type.get();
+ if(typeReference instanceof ComplexTypeReference) {
+ ComplexTypeReference complexTypeReference = (ComplexTypeReference) typeReference;
+ final TypeDefinition typeDefinition = this.types.get(complexTypeReference.getName());
+ if(typeDefinition instanceof ComplexTypeDefinition) {
+ return getDiscriminatorType((ComplexTypeDefinition) typeDefinition, rest);
+ }
+ }
+ }
+ return type;
+ }
+
+ public Map<String, TypeReference> getDiscriminatorTypes() {
+ // Get the parent type (Which contains the typeSwitch field)
+ ComplexTypeDefinition parentType;
+ if (thisType instanceof DiscriminatedComplexTypeDefinition) {
+ parentType = (ComplexTypeDefinition) thisType.getParentType();
+ } else {
+ parentType = (ComplexTypeDefinition) thisType;
+ }
+ // Get the typeSwitch field from that.
+ final SwitchField switchField = getSwitchField(parentType);
+ if (switchField != null) {
+ Map<String, TypeReference> discriminatorTypes = new TreeMap<>();
+ for (String discriminatorExpression : switchField.getDiscriminatorNames()) {
+ // Get some symbolic name we can use.
+ String discriminatorName = getDiscriminatorName(discriminatorExpression);
+ Optional<TypeReference> discriminatorType = getDiscriminatorType(parentType, discriminatorExpression);
+ discriminatorTypes.put(discriminatorName, discriminatorType.orElse(null));
+ }
+ return discriminatorTypes;
+ }
+ return Collections.emptyMap();
+ }
+
+ public Map<String, Map<String, String>> getDiscriminatorValues() {
+ // Get the parent type (Which contains the typeSwitch field)
+ ComplexTypeDefinition parentType;
+ if (thisType instanceof DiscriminatedComplexTypeDefinition) {
+ parentType = (ComplexTypeDefinition) thisType.getParentType();
+ } else {
+ parentType = (ComplexTypeDefinition) thisType;
+ }
+ // Get the typeSwitch field from that.
+ final SwitchField switchField = getSwitchField(parentType);
+ if (switchField != null) {
+ // Get the symbolic names of all discriminators
+ String[] discriminatorNames = new String[switchField.getDiscriminatorNames().length];
+ for (int i = 0; i < switchField.getDiscriminatorNames().length; i++) {
+ discriminatorNames[i] = getDiscriminatorName(switchField.getDiscriminatorNames()[i]);
+ }
+ // Build a map containing the named discriminator values for every case
+ // of the typeSwitch.
+ Map<String, Map<String, String>> discriminatorTypes = new TreeMap<>();
+ for (DiscriminatedComplexTypeDefinition switchCase : switchField.getCases()) {
+ discriminatorTypes.put(switchCase.getName(), new TreeMap<>());
+ for(int i = 0; i < discriminatorNames.length; i++) {
+ String discriminatorName = discriminatorNames[i];
+ String discriminatorValue;
+ if(i < switchCase.getDiscriminatorValues().length) {
+ discriminatorValue = switchCase.getDiscriminatorValues()[i];
+ } else {
+ discriminatorValue = null;
+ }
+ discriminatorTypes.get(switchCase.getName()).put(
+ discriminatorName, discriminatorValue);
+ }
+ }
+ return discriminatorTypes;
+ }
+ return Collections.emptyMap();
+ }
+
}
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 f8d19cb..0c86d87 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
@@ -40,20 +40,45 @@ ${helper.setConstants(type, protocolName, outputFlavor)}${helper.getSourceDirect
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-<#-- Add an import for any sub-type defined -->
-<#if helper.switchTypeImports()?has_content>
- <#list helper.switchTypeImports() as typeImport>
+<#-- Add any needed import statements -->
+<#if helper.getIncludeTypesForCFiles()?has_content>
+ <#list helper.getIncludeTypesForCFiles() as typeImport>
#include "${typeImport}.h"
</#list>
</#if>
+<#-- Helper function to get the discriminator for a given enum type constant -->
+<#if helper.isAbstractType(type)>
+
+// Array of discriminator values that match the enum type constants.
+// (The order is identical to the enum constants so we can use the
+// enum constant to directly access a given types discriminator values)
+const plc4c_${helper.getCTypeName(type.name)}_discriminator plc4c_${helper.getCTypeName(type.name)}_discriminators[] = {
+ <#if helper.getDiscriminatorValues()?has_content>
+ <#list helper.getDiscriminatorValues() as name, typeValues>
+ {/* ${helper.getCTypeName(name)} */
+ <#list typeValues as key, value>.${key} = <#if value??>${value}<#else>-1</#if><#sep>, </#list>}<#sep >,
+</#list>
+ </#if>
-#include "${helper.camelCaseToSnakeCase(typeName)}.h"
+};
-plc4c_return_code plc4c_${helper.getCTypeName(type.name)}_parse(plc4c_spi_read_buffer* buf, <#if type.parserArguments?has_content><#list type.parserArguments as parserArgument>${helper.getLanguageTypeName(parserArgument.type)} ${parserArgument.name}<#sep>, </#list>, </#if>plc4c_${helper.getCTypeName(type.name)}** message) {
+// Function returning the discriminator values for a given type constant.
+plc4c_${helper.getCTypeName(type.name)}_discriminator plc4c_${helper.getCTypeName(type.name)}_get_discriminator(plc4c_${helper.getCTypeName(type.name)}_type type) {
+ return plc4c_${helper.getCTypeName(type.name)}_discriminators[type];
+}
+</#if>
+
+// Parse function.
+plc4c_return_code plc4c_${helper.getCTypeName(type.name)}_parse(plc4c_spi_read_buffer* buf, <#if type.parserArguments?has_content><#list type.parserArguments as parserArgument>${helper.getLanguageTypeName(parserArgument.type)}<#if !helper.isSimpleType(parserArgument.type)>*</#if> ${parserArgument.name}<#sep>, </#list>, </#if>plc4c_${helper.getCTypeName(type.name)}** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_${helper.getCTypeName(type.name)}* msg = malloc(sizeof(plc4c_${helper.getCTypeName(type.name)}));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+<#if type.getPropertyFields()?has_content>
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)(<#list type.getPropertyFields() as field>${helper.getLanguageTypeNameForField(field)}<#sep >, </#list>) = NULL;
+</#if>
<#list type.fields as field>
<#switch field.typeName>
<#case "checksum">
@@ -99,7 +124,6 @@ plc4c_return_code plc4c_${helper.getCTypeName(type.name)}_parse(plc4c_spi_read_b
// Manual Field (${field.name})
${helper.getLanguageTypeNameForField(field)} ${field.name} = (${helper.getLanguageTypeNameForField(field)}) (${helper.toParseExpression(field, field.parseExpression, type.parserArguments)});
- msg->${helper.camelCaseToSnakeCase(field.name)} = ${field.name};
<#break>
<#case "optional">
@@ -146,15 +170,13 @@ plc4c_return_code plc4c_${helper.getCTypeName(type.name)}_parse(plc4c_spi_read_b
${helper.getLanguageTypeNameForField(field)}* ${field.name} = NULL;
plc4c_${helper.getCTypeName(field.type.name)}_parse(buf<#if field.params?has_content>, <#list field.params as parserTerm>${helper.toParseExpression(field, parserTerm, type.parserArguments)}<#sep>, </#sep></#list></#if>, &${field.name});
</#if>
- <#-- Update the protpery in the struct -->
- msg->${helper.camelCaseToSnakeCase(field.name)} = ${field.name};
<#break>
<#case "switch">
// Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
<#list field.cases as case>
- <#if case.discriminatorValues?has_content>if(<#list case.discriminatorValues as discriminatorValue>plc4c_spi_evaluation_helper_equals(${helper.toSwitchExpression(field.discriminatorNames[discriminatorValue?index])?no_esc}, ${discriminatorValue})<#sep> && </#sep></#list>) </#if>{
- plc4c_${helper.getCTypeName(case.name)}_parse(buf<#if case.parserArguments?has_content>, <#list case.parserArguments as parserArgument>${parserArgument.name}<#sep>, </#sep></#list></#if>, NULL/* Disabled for now */);
+ <#if case.discriminatorValues?has_content>if(<#list case.discriminatorValues as discriminatorValue><#if case.discriminatorValues?size > 1>(</#if>${helper.toSwitchExpression(field.discriminatorNames[discriminatorValue?index])?no_esc} == ${discriminatorValue}<#if case.discriminatorValues?size > 1>)</#if><#sep> && </#sep></#list>) </#if>{
+ plc4c_${helper.getCTypeName(case.name)}_parse(buf<#if case.parserArguments?has_content>, <#list case.parserArguments as parserArgument>${parserArgument.name}<#sep>, </#sep></#list></#if>, &msg);
}<#sep> else </#sep>
</#list>
<#break>
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 7f64361..7ac9125 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
@@ -44,34 +44,57 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
-<#if helper.getComplexTypeReferencesInFields()?has_content>
-<#list helper.getComplexTypeReferencesInFields() as complexType>
-#include "${helper.camelCaseToSnakeCase(complexType.getName())}.h"
-</#list>
-</#if>
-<#if helper.isDiscriminatedType(type)>
-#include "${helper.camelCaseToSnakeCase(type.parentType.name)}.h"
+<#--
+ Add any import statements for partent-types, complex types used in properties or parser arguments.
+-->
+<#if helper.getIncludeTypesForHFiles()?has_content>
+ <#list helper.getIncludeTypesForHFiles() as typeImport>
+#include "${typeImport}.h"
+ </#list>
</#if>
- <#--
- Abstract types only occur as parents in the case of discriminated types.
- As C doesn't have any form of polymorph type-system, we need to save the type information in the
- data-structure. So with this enum we're doing exactly this. It will be used in the serializers and
- parsers and stored in discriminated types.
- -->
+<#--
+ Abstract types only occur as parents in the case of discriminated types.
+ As C doesn't have any form of polymorph type-system, we need to save the type information in the
+ data-structure. So with this enum we're doing exactly this. It will be used in the serializers and
+ parsers and stored in discriminated types.
+-->
<#if helper.isAbstractType(type)>
+// Structure used to contain the discriminator values for discriminated types using this as a parent
+struct plc4c_${helper.getCTypeName(type.name)}_discriminator {
+<#if helper.getDiscriminatorTypes()?has_content>
+ <#list helper.getDiscriminatorTypes()?keys as discriminatorName>
+ ${helper.getLanguageTypeName(helper.getDiscriminatorTypes()[discriminatorName])} ${discriminatorName};
+ </#list>
+</#if>
+};
+typedef struct plc4c_${helper.getCTypeName(type.name)}_discriminator plc4c_${helper.getCTypeName(type.name)}_discriminator;
+
// Enum assigning each sub-type an individual id.
enum plc4c_${helper.getCTypeName(type.name)}_type {
- <#list helper.getDiscriminatedSubTypes(type) as subtype>
+ <#list helper.getDiscriminatedSubTypes() as subtype>
plc4c_${helper.getCTypeName(type.name)}_type_${helper.getCTypeName(subtype.name)} = ${subtype?index}<#sep>,
</#list>
};
typedef enum plc4c_${helper.getCTypeName(type.name)}_type plc4c_${helper.getCTypeName(type.name)}_type;
+
+// Function to get the discriminator values for a given type.
+plc4c_${helper.getCTypeName(type.name)}_discriminator plc4c_${helper.getCTypeName(type.name)}_get_discriminator(plc4c_${helper.getCTypeName(type.name)}_type type);
</#if>
- <#--
- When using const fields, output the constant reference values
- as defines so we can use them elsewhere
- -->
+<#--#if helper.isDiscriminatedType(type)>
+
+// Discriminator values used by the parser to determine the type to be used. All values have to apply.
+const void*[] DISCRIMINATOR_VALUES = {
+ <#list type.discriminatorValues as discriminatorValue>
+ <#- There are rare occasions where the discriminator is defined by a parser argument, in this case we currently can't detect the type ->
+ (${helper.getDiscriminatorConstantType(type, discriminatorValue?index)}) ${discriminatorValue}<#sep>, </#sep>
+ </#list>
+};
+</#if-->
+<#--
+ When using const fields, output the constant reference values
+ as global const values so we can use them elsewhere.
+-->
<#if type.constFields?has_content>
// Constant values.
@@ -80,6 +103,9 @@ const ${helper.getLanguageTypeNameForField(field)} ${helper.getCTypeName(type.na
</#list>
</#if>
+<#--
+ Create the general data-structure for this type
+-->
struct plc4c_${helper.getCTypeName(type.name)} {
<#if helper.isAbstractType(type)>
plc4c_${helper.getCTypeName(type.name)}_type _type;
@@ -93,8 +119,14 @@ struct plc4c_${helper.getCTypeName(type.name)} {
};
typedef struct plc4c_${helper.getCTypeName(type.name)} plc4c_${helper.getCTypeName(type.name)};
-plc4c_return_code plc4c_${helper.getCTypeName(type.name)}_parse(plc4c_spi_read_buffer* buf, <#if type.parserArguments?has_content><#list type.parserArguments as parserArgument>${helper.getLanguageTypeName(parserArgument.type)} ${parserArgument.name}<#sep>, </#list>, </#if>plc4c_${helper.getCTypeName(type.name)}** message);
+<#--
+ Define the parse-method for elements of this tpye
+-->
+plc4c_return_code plc4c_${helper.getCTypeName(type.name)}_parse(plc4c_spi_read_buffer* buf, <#if type.parserArguments?has_content><#list type.parserArguments as parserArgument>${helper.getLanguageTypeName(parserArgument.type)}<#if !helper.isSimpleType(parserArgument.type)>*</#if> ${parserArgument.name}<#sep>, </#list>, </#if>plc4c_${helper.getCTypeName(type.name)}** message);
+<#--
+ Define the serialize-method for elements of this tpye
+-->
plc4c_return_code plc4c_${helper.getCTypeName(type.name)}_serialize(plc4c_spi_write_buffer* buf, plc4c_${helper.getCTypeName(type.name)}* message);
#ifdef __cplusplus
diff --git a/build-utils/language-java/src/main/resources/templates/java/pojo-template.ftlh b/build-utils/language-java/src/main/resources/templates/java/pojo-template.ftlh
index 3697670..bbaa147 100644
--- a/build-utils/language-java/src/main/resources/templates/java/pojo-template.ftlh
+++ b/build-utils/language-java/src/main/resources/templates/java/pojo-template.ftlh
@@ -103,6 +103,8 @@ public<#if type.abstract> abstract</#if> class ${typeName}<#if type.parentType??
public Object[] getDiscriminatorValues() {
return DISCRIMINATOR_VALUES;
}
+
+ public
</#if>
<#list type.propertyFields as field>
diff --git a/protocols/s7/src/main/resources/protocols/s7/s7.mspec b/protocols/s7/src/main/resources/protocols/s7/s7.mspec
index 47a7202..5b91e79 100644
--- a/protocols/s7/src/main/resources/protocols/s7/s7.mspec
+++ b/protocols/s7/src/main/resources/protocols/s7/s7.mspec
@@ -212,7 +212,7 @@
// Payloads
[discriminatedType 'S7Payload' [uint 8 'messageType', S7Parameter 'parameter']
- [typeSwitch 'parameter.discriminatorValues[0]', 'messageType'
+ [typeSwitch 'parameter.parameterType', 'messageType'
['0x04','0x03' S7PayloadReadVarResponse
[array S7VarPayloadDataItem 'items' count 'CAST(parameter, S7ParameterReadVarResponse).numItems' ['lastItem']]
]
@@ -366,7 +366,7 @@
]
]
-[enum int 8 'COTPTpduSize' [uint 8 'sizeInBytes']
+[enum int 8 'COTPTpduSize' [uint 16 'sizeInBytes']
['0x07' SIZE_128 ['128']]
['0x08' SIZE_256 ['256']]
['0x09' SIZE_512 ['512']]
diff --git a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu.h b/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu.h
index 1c2ffc7..dac5cff 100644
--- a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu.h
+++ b/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu.h
@@ -26,6 +26,14 @@ extern "C" {
#include <stdint.h>
#include <plc4c/utils/list.h>
+// Structure used to contain the discriminator values for discriminated types using this as a parent
+struct plc4c_modbus_read_write_modbus_pdu_discriminator {
+ bool error;
+ unsigned int function;
+ bool response;
+};
+typedef struct plc4c_modbus_read_write_modbus_pdu_discriminator plc4c_modbus_read_write_modbus_pdu_discriminator;
+
// Enum assigning each sub-type an individual id.
enum plc4c_modbus_read_write_modbus_pdu_type {
plc4c_modbus_read_write_modbus_pdu_type_modbus_read_write_modbus_pdu_error = 0,
@@ -66,6 +74,9 @@ enum plc4c_modbus_read_write_modbus_pdu_type {
plc4c_modbus_read_write_modbus_pdu_type_modbus_read_write_modbus_pdu_read_device_identification_response = 35};
typedef enum plc4c_modbus_read_write_modbus_pdu_type plc4c_modbus_read_write_modbus_pdu_type;
+// Function to get the discriminator values for a given type.
+plc4c_modbus_read_write_modbus_pdu_discriminator plc4c_modbus_read_write_modbus_pdu_get_discriminator(plc4c_modbus_read_write_modbus_pdu_type type);
+
struct plc4c_modbus_read_write_modbus_pdu {
plc4c_modbus_read_write_modbus_pdu_type _type;
};
diff --git a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_read_file_record_request.h b/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_read_file_record_request.h
index 7fd3533..9b9bdb1 100644
--- a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_read_file_record_request.h
+++ b/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_read_file_record_request.h
@@ -25,8 +25,8 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
-#include "modbus_pdu_read_file_record_request_item.h"
#include "modbus_pdu.h"
+#include "modbus_pdu_read_file_record_request_item.h"
struct plc4c_modbus_read_write_modbus_pdu_read_file_record_request {
plc4c_modbus_read_write_modbus_pdu_type _type;
diff --git a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_read_file_record_response.h b/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_read_file_record_response.h
index cc57ab2..4da8f4d 100644
--- a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_read_file_record_response.h
+++ b/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_read_file_record_response.h
@@ -25,8 +25,8 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
-#include "modbus_pdu_read_file_record_response_item.h"
#include "modbus_pdu.h"
+#include "modbus_pdu_read_file_record_response_item.h"
struct plc4c_modbus_read_write_modbus_pdu_read_file_record_response {
plc4c_modbus_read_write_modbus_pdu_type _type;
diff --git a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_write_file_record_request.h b/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_write_file_record_request.h
index fc9ddb9..b1fc449 100644
--- a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_write_file_record_request.h
+++ b/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_write_file_record_request.h
@@ -25,8 +25,8 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
-#include "modbus_pdu_write_file_record_request_item.h"
#include "modbus_pdu.h"
+#include "modbus_pdu_write_file_record_request_item.h"
struct plc4c_modbus_read_write_modbus_pdu_write_file_record_request {
plc4c_modbus_read_write_modbus_pdu_type _type;
diff --git a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_write_file_record_response.h b/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_write_file_record_response.h
index dc7f88b..e89beee 100644
--- a/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_write_file_record_response.h
+++ b/sandbox/plc4c/generated-sources/modbus/includes/modbus_pdu_write_file_record_response.h
@@ -25,8 +25,8 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
-#include "modbus_pdu_write_file_record_response_item.h"
#include "modbus_pdu.h"
+#include "modbus_pdu_write_file_record_response_item.h"
struct plc4c_modbus_read_write_modbus_pdu_write_file_record_response {
plc4c_modbus_read_write_modbus_pdu_type _type;
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_constants.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_constants.c
index 81774ed..d542952 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_constants.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_constants.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_constants.h"
+// 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);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_constants* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_constants));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Const Field (modbusTcpDefaultPort)
uint16_t modbusTcpDefaultPort = plc4c_spi_read_unsigned_int(buf, 16);
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu.c
index 007dc69..a319fd3 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu.c
@@ -57,14 +57,100 @@
#include "modbus_pdu_report_server_id_response.h"
#include "modbus_pdu_read_device_identification_request.h"
#include "modbus_pdu_read_device_identification_response.h"
-
#include "modbus_pdu.h"
+// Array of discriminator values that match the enum type constants.
+// (The order is identical to the enum constants so we can use the
+// enum constant to directly access a given types discriminator values)
+const plc4c_modbus_read_write_modbus_pdu_discriminator plc4c_modbus_read_write_modbus_pdu_discriminators[] = {
+ {/* modbus_read_write_modbus_pdu_diagnostic_request */
+ .error = false, .function = 0x08, .response = false},
+ {/* modbus_read_write_modbus_pdu_error */
+ .error = true, .function = -1, .response = -1},
+ {/* modbus_read_write_modbus_pdu_get_com_event_log_request */
+ .error = false, .function = 0x0C, .response = false},
+ {/* modbus_read_write_modbus_pdu_get_com_event_log_response */
+ .error = false, .function = 0x0C, .response = true},
+ {/* modbus_read_write_modbus_pdu_mask_write_holding_register_request */
+ .error = false, .function = 0x16, .response = false},
+ {/* modbus_read_write_modbus_pdu_mask_write_holding_register_response */
+ .error = false, .function = 0x16, .response = true},
+ {/* modbus_read_write_modbus_pdu_read_coils_request */
+ .error = false, .function = 0x01, .response = false},
+ {/* modbus_read_write_modbus_pdu_read_coils_response */
+ .error = false, .function = 0x01, .response = true},
+ {/* modbus_read_write_modbus_pdu_read_device_identification_request */
+ .error = false, .function = 0x2B, .response = false},
+ {/* modbus_read_write_modbus_pdu_read_device_identification_response */
+ .error = false, .function = 0x2B, .response = true},
+ {/* modbus_read_write_modbus_pdu_read_discrete_inputs_request */
+ .error = false, .function = 0x02, .response = false},
+ {/* modbus_read_write_modbus_pdu_read_discrete_inputs_response */
+ .error = false, .function = 0x02, .response = true},
+ {/* modbus_read_write_modbus_pdu_read_exception_status_request */
+ .error = false, .function = 0x07, .response = false},
+ {/* modbus_read_write_modbus_pdu_read_exception_status_response */
+ .error = false, .function = 0x07, .response = true},
+ {/* modbus_read_write_modbus_pdu_read_fifo_queue_request */
+ .error = false, .function = 0x18, .response = false},
+ {/* modbus_read_write_modbus_pdu_read_fifo_queue_response */
+ .error = false, .function = 0x18, .response = true},
+ {/* modbus_read_write_modbus_pdu_read_file_record_request */
+ .error = false, .function = 0x14, .response = false},
+ {/* modbus_read_write_modbus_pdu_read_file_record_response */
+ .error = false, .function = 0x14, .response = true},
+ {/* modbus_read_write_modbus_pdu_read_holding_registers_request */
+ .error = false, .function = 0x03, .response = false},
+ {/* modbus_read_write_modbus_pdu_read_holding_registers_response */
+ .error = false, .function = 0x03, .response = true},
+ {/* modbus_read_write_modbus_pdu_read_input_registers_request */
+ .error = false, .function = 0x04, .response = false},
+ {/* modbus_read_write_modbus_pdu_read_input_registers_response */
+ .error = false, .function = 0x04, .response = true},
+ {/* modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_request */
+ .error = false, .function = 0x17, .response = false},
+ {/* modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_response */
+ .error = false, .function = 0x17, .response = true},
+ {/* modbus_read_write_modbus_pdu_report_server_id_request */
+ .error = false, .function = 0x11, .response = false},
+ {/* modbus_read_write_modbus_pdu_report_server_id_response */
+ .error = false, .function = 0x11, .response = true},
+ {/* modbus_read_write_modbus_pdu_write_file_record_request */
+ .error = false, .function = 0x15, .response = false},
+ {/* modbus_read_write_modbus_pdu_write_file_record_response */
+ .error = false, .function = 0x15, .response = true},
+ {/* modbus_read_write_modbus_pdu_write_multiple_coils_request */
+ .error = false, .function = 0x0F, .response = false},
+ {/* modbus_read_write_modbus_pdu_write_multiple_coils_response */
+ .error = false, .function = 0x0F, .response = true},
+ {/* modbus_read_write_modbus_pdu_write_multiple_holding_registers_request */
+ .error = false, .function = 0x10, .response = false},
+ {/* modbus_read_write_modbus_pdu_write_multiple_holding_registers_response */
+ .error = false, .function = 0x10, .response = true},
+ {/* modbus_read_write_modbus_pdu_write_single_coil_request */
+ .error = false, .function = 0x05, .response = false},
+ {/* modbus_read_write_modbus_pdu_write_single_coil_response */
+ .error = false, .function = 0x05, .response = true},
+ {/* modbus_read_write_modbus_pdu_write_single_register_request */
+ .error = false, .function = 0x06, .response = false},
+ {/* modbus_read_write_modbus_pdu_write_single_register_response */
+ .error = false, .function = 0x06, .response = true}
+};
+
+// Function returning the discriminator values for a given type constant.
+plc4c_modbus_read_write_modbus_pdu_discriminator plc4c_modbus_read_write_modbus_pdu_get_discriminator(plc4c_modbus_read_write_modbus_pdu_type type) {
+ return plc4c_modbus_read_write_modbus_pdu_discriminators[type];
+}
+
+// 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);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Implicit Field (error) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
bool error = plc4c_spi_read_bit(buf);
@@ -73,113 +159,113 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
unsigned int function = plc4c_spi_read_unsigned_short(buf, 7);
// Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
- if(plc4c_spi_evaluation_helper_equals(error, true)) {
- plc4c_modbus_read_write_modbus_pdu_error_parse(buf, response, NULL/* Disabled for now */);
+ if(error == true) {
+ plc4c_modbus_read_write_modbus_pdu_error_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x02) && plc4c_spi_evaluation_helper_equals(response, false)) {
- plc4c_modbus_read_write_modbus_pdu_read_discrete_inputs_request_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x02) && (response == false)) {
+ plc4c_modbus_read_write_modbus_pdu_read_discrete_inputs_request_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x02) && plc4c_spi_evaluation_helper_equals(response, true)) {
- plc4c_modbus_read_write_modbus_pdu_read_discrete_inputs_response_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x02) && (response == true)) {
+ plc4c_modbus_read_write_modbus_pdu_read_discrete_inputs_response_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x01) && plc4c_spi_evaluation_helper_equals(response, false)) {
- plc4c_modbus_read_write_modbus_pdu_read_coils_request_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x01) && (response == false)) {
+ plc4c_modbus_read_write_modbus_pdu_read_coils_request_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x01) && plc4c_spi_evaluation_helper_equals(response, true)) {
- plc4c_modbus_read_write_modbus_pdu_read_coils_response_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x01) && (response == true)) {
+ plc4c_modbus_read_write_modbus_pdu_read_coils_response_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x05) && plc4c_spi_evaluation_helper_equals(response, false)) {
- plc4c_modbus_read_write_modbus_pdu_write_single_coil_request_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x05) && (response == false)) {
+ plc4c_modbus_read_write_modbus_pdu_write_single_coil_request_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x05) && plc4c_spi_evaluation_helper_equals(response, true)) {
- plc4c_modbus_read_write_modbus_pdu_write_single_coil_response_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x05) && (response == true)) {
+ plc4c_modbus_read_write_modbus_pdu_write_single_coil_response_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x0F) && plc4c_spi_evaluation_helper_equals(response, false)) {
- plc4c_modbus_read_write_modbus_pdu_write_multiple_coils_request_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x0F) && (response == false)) {
+ plc4c_modbus_read_write_modbus_pdu_write_multiple_coils_request_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x0F) && plc4c_spi_evaluation_helper_equals(response, true)) {
- plc4c_modbus_read_write_modbus_pdu_write_multiple_coils_response_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x0F) && (response == true)) {
+ plc4c_modbus_read_write_modbus_pdu_write_multiple_coils_response_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x04) && plc4c_spi_evaluation_helper_equals(response, false)) {
- plc4c_modbus_read_write_modbus_pdu_read_input_registers_request_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x04) && (response == false)) {
+ plc4c_modbus_read_write_modbus_pdu_read_input_registers_request_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x04) && plc4c_spi_evaluation_helper_equals(response, true)) {
- plc4c_modbus_read_write_modbus_pdu_read_input_registers_response_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x04) && (response == true)) {
+ plc4c_modbus_read_write_modbus_pdu_read_input_registers_response_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x03) && plc4c_spi_evaluation_helper_equals(response, false)) {
- plc4c_modbus_read_write_modbus_pdu_read_holding_registers_request_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x03) && (response == false)) {
+ plc4c_modbus_read_write_modbus_pdu_read_holding_registers_request_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x03) && plc4c_spi_evaluation_helper_equals(response, true)) {
- plc4c_modbus_read_write_modbus_pdu_read_holding_registers_response_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x03) && (response == true)) {
+ plc4c_modbus_read_write_modbus_pdu_read_holding_registers_response_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x06) && plc4c_spi_evaluation_helper_equals(response, false)) {
- plc4c_modbus_read_write_modbus_pdu_write_single_register_request_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x06) && (response == false)) {
+ plc4c_modbus_read_write_modbus_pdu_write_single_register_request_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x06) && plc4c_spi_evaluation_helper_equals(response, true)) {
- plc4c_modbus_read_write_modbus_pdu_write_single_register_response_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x06) && (response == true)) {
+ plc4c_modbus_read_write_modbus_pdu_write_single_register_response_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x10) && plc4c_spi_evaluation_helper_equals(response, false)) {
- plc4c_modbus_read_write_modbus_pdu_write_multiple_holding_registers_request_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x10) && (response == false)) {
+ plc4c_modbus_read_write_modbus_pdu_write_multiple_holding_registers_request_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x10) && plc4c_spi_evaluation_helper_equals(response, true)) {
- plc4c_modbus_read_write_modbus_pdu_write_multiple_holding_registers_response_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x10) && (response == true)) {
+ plc4c_modbus_read_write_modbus_pdu_write_multiple_holding_registers_response_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x17) && plc4c_spi_evaluation_helper_equals(response, false)) {
- plc4c_modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_request_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x17) && (response == false)) {
+ plc4c_modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_request_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x17) && plc4c_spi_evaluation_helper_equals(response, true)) {
- plc4c_modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_response_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x17) && (response == true)) {
+ plc4c_modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_response_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x16) && plc4c_spi_evaluation_helper_equals(response, false)) {
- plc4c_modbus_read_write_modbus_pdu_mask_write_holding_register_request_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x16) && (response == false)) {
+ plc4c_modbus_read_write_modbus_pdu_mask_write_holding_register_request_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x16) && plc4c_spi_evaluation_helper_equals(response, true)) {
- plc4c_modbus_read_write_modbus_pdu_mask_write_holding_register_response_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x16) && (response == true)) {
+ plc4c_modbus_read_write_modbus_pdu_mask_write_holding_register_response_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x18) && plc4c_spi_evaluation_helper_equals(response, false)) {
- plc4c_modbus_read_write_modbus_pdu_read_fifo_queue_request_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x18) && (response == false)) {
+ plc4c_modbus_read_write_modbus_pdu_read_fifo_queue_request_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x18) && plc4c_spi_evaluation_helper_equals(response, true)) {
- plc4c_modbus_read_write_modbus_pdu_read_fifo_queue_response_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x18) && (response == true)) {
+ plc4c_modbus_read_write_modbus_pdu_read_fifo_queue_response_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x14) && plc4c_spi_evaluation_helper_equals(response, false)) {
- plc4c_modbus_read_write_modbus_pdu_read_file_record_request_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x14) && (response == false)) {
+ plc4c_modbus_read_write_modbus_pdu_read_file_record_request_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x14) && plc4c_spi_evaluation_helper_equals(response, true)) {
- plc4c_modbus_read_write_modbus_pdu_read_file_record_response_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x14) && (response == true)) {
+ plc4c_modbus_read_write_modbus_pdu_read_file_record_response_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x15) && plc4c_spi_evaluation_helper_equals(response, false)) {
- plc4c_modbus_read_write_modbus_pdu_write_file_record_request_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x15) && (response == false)) {
+ plc4c_modbus_read_write_modbus_pdu_write_file_record_request_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x15) && plc4c_spi_evaluation_helper_equals(response, true)) {
- plc4c_modbus_read_write_modbus_pdu_write_file_record_response_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x15) && (response == true)) {
+ plc4c_modbus_read_write_modbus_pdu_write_file_record_response_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x07) && plc4c_spi_evaluation_helper_equals(response, false)) {
- plc4c_modbus_read_write_modbus_pdu_read_exception_status_request_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x07) && (response == false)) {
+ plc4c_modbus_read_write_modbus_pdu_read_exception_status_request_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x07) && plc4c_spi_evaluation_helper_equals(response, true)) {
- plc4c_modbus_read_write_modbus_pdu_read_exception_status_response_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x07) && (response == true)) {
+ plc4c_modbus_read_write_modbus_pdu_read_exception_status_response_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x08) && plc4c_spi_evaluation_helper_equals(response, false)) {
- plc4c_modbus_read_write_modbus_pdu_diagnostic_request_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x08) && (response == false)) {
+ plc4c_modbus_read_write_modbus_pdu_diagnostic_request_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x0C) && plc4c_spi_evaluation_helper_equals(response, false)) {
- plc4c_modbus_read_write_modbus_pdu_get_com_event_log_request_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x0C) && (response == false)) {
+ plc4c_modbus_read_write_modbus_pdu_get_com_event_log_request_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x0C) && plc4c_spi_evaluation_helper_equals(response, true)) {
- plc4c_modbus_read_write_modbus_pdu_get_com_event_log_response_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x0C) && (response == true)) {
+ plc4c_modbus_read_write_modbus_pdu_get_com_event_log_response_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x11) && plc4c_spi_evaluation_helper_equals(response, false)) {
- plc4c_modbus_read_write_modbus_pdu_report_server_id_request_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x11) && (response == false)) {
+ plc4c_modbus_read_write_modbus_pdu_report_server_id_request_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x11) && plc4c_spi_evaluation_helper_equals(response, true)) {
- plc4c_modbus_read_write_modbus_pdu_report_server_id_response_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x11) && (response == true)) {
+ plc4c_modbus_read_write_modbus_pdu_report_server_id_response_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x2B) && plc4c_spi_evaluation_helper_equals(response, false)) {
- plc4c_modbus_read_write_modbus_pdu_read_device_identification_request_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x2B) && (response == false)) {
+ plc4c_modbus_read_write_modbus_pdu_read_device_identification_request_parse(buf, response, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(error, false) && plc4c_spi_evaluation_helper_equals(function, 0x2B) && plc4c_spi_evaluation_helper_equals(response, true)) {
- plc4c_modbus_read_write_modbus_pdu_read_device_identification_response_parse(buf, response, NULL/* Disabled for now */);
+ if((error == false) && (function == 0x2B) && (response == true)) {
+ plc4c_modbus_read_write_modbus_pdu_read_device_identification_response_parse(buf, response, &msg);
}
return OK;
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_diagnostic_request.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_diagnostic_request.c
index 24f8ef7..3e4cffc 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_diagnostic_request.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_diagnostic_request.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_diagnostic_request.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_diagnostic_request_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_diagnostic_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_diagnostic_request* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_diagnostic_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (status)
uint16_t status = plc4c_spi_read_unsigned_int(buf, 16);
- msg->status = status;
// Simple Field (eventCount)
uint16_t eventCount = plc4c_spi_read_unsigned_int(buf, 16);
- msg->event_count = eventCount;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_error.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_error.c
index a8c771b..4f5de4b 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_error.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_error.c
@@ -21,18 +21,20 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_error.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_error_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_error** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_error* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_error));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (exceptionCode)
uint8_t exceptionCode = plc4c_spi_read_unsigned_short(buf, 8);
- msg->exception_code = exceptionCode;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_get_com_event_log_request.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_get_com_event_log_request.c
index 2e23ea2..164b680 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_get_com_event_log_request.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_get_com_event_log_request.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_get_com_event_log_request.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_get_com_event_log_request_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_get_com_event_log_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_get_com_event_log_request* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_get_com_event_log_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_get_com_event_log_response.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_get_com_event_log_response.c
index 51574ef..8c6fe01 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_get_com_event_log_response.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_get_com_event_log_response.c
@@ -21,29 +21,29 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_get_com_event_log_response.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_get_com_event_log_response_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_get_com_event_log_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_get_com_event_log_response* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_get_com_event_log_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
// Simple Field (status)
uint16_t status = plc4c_spi_read_unsigned_int(buf, 16);
- msg->status = status;
// Simple Field (eventCount)
uint16_t eventCount = plc4c_spi_read_unsigned_int(buf, 16);
- msg->event_count = eventCount;
// Simple Field (messageCount)
uint16_t messageCount = plc4c_spi_read_unsigned_int(buf, 16);
- msg->message_count = messageCount;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_mask_write_holding_register_request.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_mask_write_holding_register_request.c
index 433096a..e7f043f 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_mask_write_holding_register_request.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_mask_write_holding_register_request.c
@@ -21,26 +21,26 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_mask_write_holding_register_request.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_mask_write_holding_register_request_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_mask_write_holding_register_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_mask_write_holding_register_request* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_mask_write_holding_register_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (referenceAddress)
uint16_t referenceAddress = plc4c_spi_read_unsigned_int(buf, 16);
- msg->reference_address = referenceAddress;
// Simple Field (andMask)
uint16_t andMask = plc4c_spi_read_unsigned_int(buf, 16);
- msg->and_mask = andMask;
// Simple Field (orMask)
uint16_t orMask = plc4c_spi_read_unsigned_int(buf, 16);
- msg->or_mask = orMask;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_mask_write_holding_register_response.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_mask_write_holding_register_response.c
index 833a240..53dff96 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_mask_write_holding_register_response.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_mask_write_holding_register_response.c
@@ -21,26 +21,26 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_mask_write_holding_register_response.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_mask_write_holding_register_response_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_mask_write_holding_register_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_mask_write_holding_register_response* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_mask_write_holding_register_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (referenceAddress)
uint16_t referenceAddress = plc4c_spi_read_unsigned_int(buf, 16);
- msg->reference_address = referenceAddress;
// Simple Field (andMask)
uint16_t andMask = plc4c_spi_read_unsigned_int(buf, 16);
- msg->and_mask = andMask;
// Simple Field (orMask)
uint16_t orMask = plc4c_spi_read_unsigned_int(buf, 16);
- msg->or_mask = orMask;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_coils_request.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_coils_request.c
index 31623dd..a877a0d 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_coils_request.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_coils_request.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_coils_request.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_coils_request_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_read_coils_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_coils_request* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_coils_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (startingAddress)
uint16_t startingAddress = plc4c_spi_read_unsigned_int(buf, 16);
- msg->starting_address = startingAddress;
// Simple Field (quantity)
uint16_t quantity = plc4c_spi_read_unsigned_int(buf, 16);
- msg->quantity = quantity;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_coils_response.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_coils_response.c
index d52961a..00bdaa8 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_coils_response.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_coils_response.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_coils_response.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_coils_response_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_read_coils_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_coils_response* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_coils_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_device_identification_request.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_device_identification_request.c
index 3ac7929..57c1f85 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_device_identification_request.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_device_identification_request.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_device_identification_request.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_device_identification_request_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_read_device_identification_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_device_identification_request* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_device_identification_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_device_identification_response.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_device_identification_response.c
index 9117860..2b17cb9 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_device_identification_response.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_device_identification_response.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_device_identification_response.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_device_identification_response_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_read_device_identification_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_device_identification_response* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_device_identification_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_discrete_inputs_request.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_discrete_inputs_request.c
index 866940c..76b0a98 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_discrete_inputs_request.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_discrete_inputs_request.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_discrete_inputs_request.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_discrete_inputs_request_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_read_discrete_inputs_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_discrete_inputs_request* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_discrete_inputs_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (startingAddress)
uint16_t startingAddress = plc4c_spi_read_unsigned_int(buf, 16);
- msg->starting_address = startingAddress;
// Simple Field (quantity)
uint16_t quantity = plc4c_spi_read_unsigned_int(buf, 16);
- msg->quantity = quantity;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_discrete_inputs_response.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_discrete_inputs_response.c
index cb0c60f..86da991 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_discrete_inputs_response.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_discrete_inputs_response.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_discrete_inputs_response.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_discrete_inputs_response_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_read_discrete_inputs_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_discrete_inputs_response* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_discrete_inputs_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_exception_status_request.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_exception_status_request.c
index e66b7f2..ffea691 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_exception_status_request.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_exception_status_request.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_exception_status_request.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_exception_status_request_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_read_exception_status_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_exception_status_request* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_exception_status_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_exception_status_response.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_exception_status_response.c
index 567ce6f..9970a54 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_exception_status_response.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_exception_status_response.c
@@ -21,18 +21,20 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_exception_status_response.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_exception_status_response_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_read_exception_status_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_exception_status_response* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_exception_status_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (value)
uint8_t value = plc4c_spi_read_unsigned_short(buf, 8);
- msg->value = value;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_fifo_queue_request.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_fifo_queue_request.c
index bf14a47..67fc990 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_fifo_queue_request.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_fifo_queue_request.c
@@ -21,18 +21,20 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_fifo_queue_request.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_fifo_queue_request_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_read_fifo_queue_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_fifo_queue_request* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_fifo_queue_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (fifoPointerAddress)
uint16_t fifoPointerAddress = plc4c_spi_read_unsigned_int(buf, 16);
- msg->fifo_pointer_address = fifoPointerAddress;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_fifo_queue_response.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_fifo_queue_response.c
index 51487c5..6a5ce61 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_fifo_queue_response.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_fifo_queue_response.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_fifo_queue_response.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_fifo_queue_response_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_read_fifo_queue_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_fifo_queue_response* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_fifo_queue_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// 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 = plc4c_spi_read_unsigned_int(buf, 16);
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_file_record_request.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_file_record_request.c
index 956fae1..59824e3 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_file_record_request.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_file_record_request.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_file_record_request.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_file_record_request_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_read_file_record_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_file_record_request* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_file_record_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
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 e5ca52c..ebae231 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
@@ -21,30 +21,29 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_file_record_request_item.h"
+// 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);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_file_record_request_item));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (referenceType)
uint8_t referenceType = plc4c_spi_read_unsigned_short(buf, 8);
- msg->reference_type = referenceType;
// Simple Field (fileNumber)
uint16_t fileNumber = plc4c_spi_read_unsigned_int(buf, 16);
- msg->file_number = fileNumber;
// Simple Field (recordNumber)
uint16_t recordNumber = plc4c_spi_read_unsigned_int(buf, 16);
- msg->record_number = recordNumber;
// Simple Field (recordLength)
uint16_t recordLength = plc4c_spi_read_unsigned_int(buf, 16);
- msg->record_length = recordLength;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_file_record_response.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_file_record_response.c
index 10149d0..051d2c2 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_file_record_response.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_file_record_response.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_file_record_response.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_file_record_response_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_read_file_record_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_file_record_response* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_file_record_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
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 e135d25..c689a36 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
@@ -21,21 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_file_record_response_item.h"
+// 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);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_file_record_response_item));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
// Simple Field (referenceType)
uint8_t referenceType = plc4c_spi_read_unsigned_short(buf, 8);
- msg->reference_type = referenceType;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_holding_registers_request.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_holding_registers_request.c
index a75cbb7..60f25a0 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_holding_registers_request.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_holding_registers_request.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_holding_registers_request.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_holding_registers_request_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_read_holding_registers_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_holding_registers_request* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_holding_registers_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (startingAddress)
uint16_t startingAddress = plc4c_spi_read_unsigned_int(buf, 16);
- msg->starting_address = startingAddress;
// Simple Field (quantity)
uint16_t quantity = plc4c_spi_read_unsigned_int(buf, 16);
- msg->quantity = quantity;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_holding_registers_response.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_holding_registers_response.c
index 2474213..57891fd 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_holding_registers_response.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_holding_registers_response.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_holding_registers_response.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_holding_registers_response_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_read_holding_registers_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_holding_registers_response* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_holding_registers_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_input_registers_request.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_input_registers_request.c
index 34221b1..b3843a6 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_input_registers_request.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_input_registers_request.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_input_registers_request.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_input_registers_request_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_read_input_registers_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_input_registers_request* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_input_registers_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (startingAddress)
uint16_t startingAddress = plc4c_spi_read_unsigned_int(buf, 16);
- msg->starting_address = startingAddress;
// Simple Field (quantity)
uint16_t quantity = plc4c_spi_read_unsigned_int(buf, 16);
- msg->quantity = quantity;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_input_registers_response.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_input_registers_response.c
index 2b949eb..17a957f 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_input_registers_response.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_input_registers_response.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_input_registers_response.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_input_registers_response_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_read_input_registers_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_input_registers_response* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_input_registers_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_write_multiple_holding_registers_request.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_write_multiple_holding_registers_request.c
index 52a225c..d90943c 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_write_multiple_holding_registers_request.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_write_multiple_holding_registers_request.c
@@ -21,30 +21,29 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_write_multiple_holding_registers_request.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_request_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_request* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (readStartingAddress)
uint16_t readStartingAddress = plc4c_spi_read_unsigned_int(buf, 16);
- msg->read_starting_address = readStartingAddress;
// Simple Field (readQuantity)
uint16_t readQuantity = plc4c_spi_read_unsigned_int(buf, 16);
- msg->read_quantity = readQuantity;
// Simple Field (writeStartingAddress)
uint16_t writeStartingAddress = plc4c_spi_read_unsigned_int(buf, 16);
- msg->write_starting_address = writeStartingAddress;
// Simple Field (writeQuantity)
uint16_t writeQuantity = plc4c_spi_read_unsigned_int(buf, 16);
- msg->write_quantity = writeQuantity;
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_write_multiple_holding_registers_response.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_write_multiple_holding_registers_response.c
index 17ca89e..a26f2dd 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_write_multiple_holding_registers_response.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_read_write_multiple_holding_registers_response.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_read_write_multiple_holding_registers_response.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_response_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_response* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_report_server_id_request.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_report_server_id_request.c
index b2b01f7..45fc18f 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_report_server_id_request.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_report_server_id_request.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_report_server_id_request.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_report_server_id_request_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_report_server_id_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_report_server_id_request* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_report_server_id_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_report_server_id_response.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_report_server_id_response.c
index c1222fe..46ced15 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_report_server_id_response.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_report_server_id_response.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_report_server_id_response.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_report_server_id_response_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_report_server_id_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_report_server_id_response* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_report_server_id_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_request.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_request.c
index df2088d..9daa6d7 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_request.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_request.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_write_file_record_request.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_request_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_write_file_record_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_write_file_record_request* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_write_file_record_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
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 9d40141..3cba1b9 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
@@ -21,26 +21,26 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_write_file_record_request_item.h"
+// 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);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_write_file_record_request_item));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (referenceType)
uint8_t referenceType = plc4c_spi_read_unsigned_short(buf, 8);
- msg->reference_type = referenceType;
// Simple Field (fileNumber)
uint16_t fileNumber = plc4c_spi_read_unsigned_int(buf, 16);
- msg->file_number = fileNumber;
// Simple Field (recordNumber)
uint16_t recordNumber = plc4c_spi_read_unsigned_int(buf, 16);
- msg->record_number = recordNumber;
// 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 = plc4c_spi_read_unsigned_int(buf, 16);
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_response.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_response.c
index 152bfe9..9dd1fb2 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_response.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_file_record_response.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_write_file_record_response.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_file_record_response_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_write_file_record_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_write_file_record_response* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_write_file_record_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
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 aa8283a..3a76612 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
@@ -21,26 +21,26 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_write_file_record_response_item.h"
+// 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);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_write_file_record_response_item));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (referenceType)
uint8_t referenceType = plc4c_spi_read_unsigned_short(buf, 8);
- msg->reference_type = referenceType;
// Simple Field (fileNumber)
uint16_t fileNumber = plc4c_spi_read_unsigned_int(buf, 16);
- msg->file_number = fileNumber;
// Simple Field (recordNumber)
uint16_t recordNumber = plc4c_spi_read_unsigned_int(buf, 16);
- msg->record_number = recordNumber;
// 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 = plc4c_spi_read_unsigned_int(buf, 16);
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_multiple_coils_request.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_multiple_coils_request.c
index d6f1815..7e5189f 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_multiple_coils_request.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_multiple_coils_request.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_write_multiple_coils_request.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_multiple_coils_request_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_write_multiple_coils_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_write_multiple_coils_request* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_write_multiple_coils_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (startingAddress)
uint16_t startingAddress = plc4c_spi_read_unsigned_int(buf, 16);
- msg->starting_address = startingAddress;
// Simple Field (quantity)
uint16_t quantity = plc4c_spi_read_unsigned_int(buf, 16);
- msg->quantity = quantity;
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_multiple_coils_response.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_multiple_coils_response.c
index 63ad564..92509df 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_multiple_coils_response.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_multiple_coils_response.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_write_multiple_coils_response.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_multiple_coils_response_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_write_multiple_coils_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_write_multiple_coils_response* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_write_multiple_coils_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (startingAddress)
uint16_t startingAddress = plc4c_spi_read_unsigned_int(buf, 16);
- msg->starting_address = startingAddress;
// Simple Field (quantity)
uint16_t quantity = plc4c_spi_read_unsigned_int(buf, 16);
- msg->quantity = quantity;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_multiple_holding_registers_request.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_multiple_holding_registers_request.c
index 16df2df..15bbd5f 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_multiple_holding_registers_request.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_multiple_holding_registers_request.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_write_multiple_holding_registers_request.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_multiple_holding_registers_request_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_write_multiple_holding_registers_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_write_multiple_holding_registers_request* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_write_multiple_holding_registers_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (startingAddress)
uint16_t startingAddress = plc4c_spi_read_unsigned_int(buf, 16);
- msg->starting_address = startingAddress;
// Simple Field (quantity)
uint16_t quantity = plc4c_spi_read_unsigned_int(buf, 16);
- msg->quantity = quantity;
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_multiple_holding_registers_response.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_multiple_holding_registers_response.c
index 783d1c6..bf4bc5e 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_multiple_holding_registers_response.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_multiple_holding_registers_response.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_write_multiple_holding_registers_response.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_multiple_holding_registers_response_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_write_multiple_holding_registers_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_write_multiple_holding_registers_response* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_write_multiple_holding_registers_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (startingAddress)
uint16_t startingAddress = plc4c_spi_read_unsigned_int(buf, 16);
- msg->starting_address = startingAddress;
// Simple Field (quantity)
uint16_t quantity = plc4c_spi_read_unsigned_int(buf, 16);
- msg->quantity = quantity;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_single_coil_request.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_single_coil_request.c
index a30555c..8f26d0e 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_single_coil_request.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_single_coil_request.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_write_single_coil_request.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_single_coil_request_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_write_single_coil_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_write_single_coil_request* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_write_single_coil_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (address)
uint16_t address = plc4c_spi_read_unsigned_int(buf, 16);
- msg->address = address;
// Simple Field (value)
uint16_t value = plc4c_spi_read_unsigned_int(buf, 16);
- msg->value = value;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_single_coil_response.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_single_coil_response.c
index d43928d..55ed96a 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_single_coil_response.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_single_coil_response.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_write_single_coil_response.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_single_coil_response_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_write_single_coil_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_write_single_coil_response* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_write_single_coil_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (address)
uint16_t address = plc4c_spi_read_unsigned_int(buf, 16);
- msg->address = address;
// Simple Field (value)
uint16_t value = plc4c_spi_read_unsigned_int(buf, 16);
- msg->value = value;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_single_register_request.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_single_register_request.c
index 9d21ee6..6778c37 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_single_register_request.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_single_register_request.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_write_single_register_request.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_single_register_request_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_write_single_register_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_write_single_register_request* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_write_single_register_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (address)
uint16_t address = plc4c_spi_read_unsigned_int(buf, 16);
- msg->address = address;
// Simple Field (value)
uint16_t value = plc4c_spi_read_unsigned_int(buf, 16);
- msg->value = value;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_single_register_response.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_single_register_response.c
index ca74c75..0798317 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_single_register_response.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu_write_single_register_response.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_pdu_write_single_register_response.h"
+// Parse function.
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_write_single_register_response_parse(plc4c_spi_read_buffer* buf, bool response, plc4c_modbus_read_write_modbus_pdu_write_single_register_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_pdu_write_single_register_response* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_pdu_write_single_register_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (address)
uint16_t address = plc4c_spi_read_unsigned_int(buf, 16);
- msg->address = address;
// Simple Field (value)
uint16_t value = plc4c_spi_read_unsigned_int(buf, 16);
- msg->value = value;
return OK;
}
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 de5bef3..e98f1c9 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_serial_adu.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_serial_adu.c
@@ -21,18 +21,20 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_serial_adu.h"
+// 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);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_serial_adu* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_serial_adu));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (transactionId)
uint16_t transactionId = plc4c_spi_read_unsigned_int(buf, 16);
- msg->transaction_id = transactionId;
// Reserved Field (Compartmentalized so the "reserved" variable can't leak)
{
@@ -44,16 +46,13 @@ plc4c_return_code plc4c_modbus_read_write_modbus_serial_adu_parse(plc4c_spi_read
// Simple Field (length)
uint16_t length = plc4c_spi_read_unsigned_int(buf, 16);
- msg->length = length;
// Simple Field (address)
uint8_t address = plc4c_spi_read_unsigned_short(buf, 8);
- msg->address = address;
// Simple Field (pdu)
plc4c_modbus_read_write_modbus_pdu* pdu = NULL;
plc4c_modbus_read_write_modbus_pdu_parse(buf, response, &pdu);
- msg->pdu = pdu;
return OK;
}
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 cefbc85..34506e5 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_tcp_adu.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_tcp_adu.c
@@ -21,18 +21,20 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "modbus_tcp_adu.h"
+// 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);
uint16_t curPos;
- plc4c_modbus_read_write_modbus_tcp_adu* msg = malloc(sizeof(plc4c_modbus_read_write_modbus_tcp_adu));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (transactionIdentifier)
uint16_t transactionIdentifier = plc4c_spi_read_unsigned_int(buf, 16);
- msg->transaction_identifier = transactionIdentifier;
// Const Field (protocolIdentifier)
uint16_t protocolIdentifier = plc4c_spi_read_unsigned_int(buf, 16);
@@ -46,12 +48,10 @@ plc4c_return_code plc4c_modbus_read_write_modbus_tcp_adu_parse(plc4c_spi_read_bu
// Simple Field (unitIdentifier)
uint8_t unitIdentifier = plc4c_spi_read_unsigned_short(buf, 8);
- msg->unit_identifier = unitIdentifier;
// Simple Field (pdu)
plc4c_modbus_read_write_modbus_pdu* pdu = NULL;
plc4c_modbus_read_write_modbus_pdu_parse(buf, response, &pdu);
- msg->pdu = pdu;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/includes/cotp_packet.h b/sandbox/plc4c/generated-sources/s7/includes/cotp_packet.h
index c612308..61236f5 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/cotp_packet.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/cotp_packet.h
@@ -28,6 +28,12 @@ extern "C" {
#include "cotp_parameter.h"
#include "s7_message.h"
+// Structure used to contain the discriminator values for discriminated types using this as a parent
+struct plc4c_s7_read_write_cotp_packet_discriminator {
+ uint8_t tpduCode;
+};
+typedef struct plc4c_s7_read_write_cotp_packet_discriminator plc4c_s7_read_write_cotp_packet_discriminator;
+
// Enum assigning each sub-type an individual id.
enum plc4c_s7_read_write_cotp_packet_type {
plc4c_s7_read_write_cotp_packet_type_s7_read_write_cotp_packet_data = 0,
@@ -38,6 +44,9 @@ enum plc4c_s7_read_write_cotp_packet_type {
plc4c_s7_read_write_cotp_packet_type_s7_read_write_cotp_packet_tpdu_error = 5};
typedef enum plc4c_s7_read_write_cotp_packet_type plc4c_s7_read_write_cotp_packet_type;
+// Function to get the discriminator values for a given type.
+plc4c_s7_read_write_cotp_packet_discriminator plc4c_s7_read_write_cotp_packet_get_discriminator(plc4c_s7_read_write_cotp_packet_type type);
+
struct plc4c_s7_read_write_cotp_packet {
plc4c_s7_read_write_cotp_packet_type _type;
plc4c_list* parameters;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_connection_request.h b/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_connection_request.h
index caa8bc3..d4e2a38 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_connection_request.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_connection_request.h
@@ -25,10 +25,10 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
+#include "cotp_packet.h"
#include "cotp_parameter.h"
-#include "s7_message.h"
#include "cotp_protocol_class.h"
-#include "cotp_packet.h"
+#include "s7_message.h"
struct plc4c_s7_read_write_cotp_packet_connection_request {
plc4c_s7_read_write_cotp_packet_type _type;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_connection_response.h b/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_connection_response.h
index 90712c0..d83392f 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_connection_response.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_connection_response.h
@@ -25,10 +25,10 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
+#include "cotp_packet.h"
#include "cotp_parameter.h"
-#include "s7_message.h"
#include "cotp_protocol_class.h"
-#include "cotp_packet.h"
+#include "s7_message.h"
struct plc4c_s7_read_write_cotp_packet_connection_response {
plc4c_s7_read_write_cotp_packet_type _type;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_data.h b/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_data.h
index cc13512..f746e1c 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_data.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_data.h
@@ -25,9 +25,9 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
+#include "cotp_packet.h"
#include "cotp_parameter.h"
#include "s7_message.h"
-#include "cotp_packet.h"
struct plc4c_s7_read_write_cotp_packet_data {
plc4c_s7_read_write_cotp_packet_type _type;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_disconnect_request.h b/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_disconnect_request.h
index c7c1a87..a1a3ca3 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_disconnect_request.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_disconnect_request.h
@@ -25,10 +25,10 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
+#include "cotp_packet.h"
#include "cotp_parameter.h"
-#include "s7_message.h"
#include "cotp_protocol_class.h"
-#include "cotp_packet.h"
+#include "s7_message.h"
struct plc4c_s7_read_write_cotp_packet_disconnect_request {
plc4c_s7_read_write_cotp_packet_type _type;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_disconnect_response.h b/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_disconnect_response.h
index 4dac72a..3e28c67 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_disconnect_response.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_disconnect_response.h
@@ -25,9 +25,9 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
+#include "cotp_packet.h"
#include "cotp_parameter.h"
#include "s7_message.h"
-#include "cotp_packet.h"
struct plc4c_s7_read_write_cotp_packet_disconnect_response {
plc4c_s7_read_write_cotp_packet_type _type;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_tpdu_error.h b/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_tpdu_error.h
index 9274876..6cd5b86 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_tpdu_error.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/cotp_packet_tpdu_error.h
@@ -25,9 +25,9 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
+#include "cotp_packet.h"
#include "cotp_parameter.h"
#include "s7_message.h"
-#include "cotp_packet.h"
struct plc4c_s7_read_write_cotp_packet_tpdu_error {
plc4c_s7_read_write_cotp_packet_type _type;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/cotp_parameter.h b/sandbox/plc4c/generated-sources/s7/includes/cotp_parameter.h
index 9ba1750..5db2814 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/cotp_parameter.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/cotp_parameter.h
@@ -26,6 +26,12 @@ extern "C" {
#include <stdint.h>
#include <plc4c/utils/list.h>
+// Structure used to contain the discriminator values for discriminated types using this as a parent
+struct plc4c_s7_read_write_cotp_parameter_discriminator {
+ uint8_t parameterType;
+};
+typedef struct plc4c_s7_read_write_cotp_parameter_discriminator plc4c_s7_read_write_cotp_parameter_discriminator;
+
// Enum assigning each sub-type an individual id.
enum plc4c_s7_read_write_cotp_parameter_type {
plc4c_s7_read_write_cotp_parameter_type_s7_read_write_cotp_parameter_tpdu_size = 0,
@@ -35,6 +41,9 @@ enum plc4c_s7_read_write_cotp_parameter_type {
plc4c_s7_read_write_cotp_parameter_type_s7_read_write_cotp_parameter_disconnect_additional_information = 4};
typedef enum plc4c_s7_read_write_cotp_parameter_type plc4c_s7_read_write_cotp_parameter_type;
+// Function to get the discriminator values for a given type.
+plc4c_s7_read_write_cotp_parameter_discriminator plc4c_s7_read_write_cotp_parameter_get_discriminator(plc4c_s7_read_write_cotp_parameter_type type);
+
struct plc4c_s7_read_write_cotp_parameter {
plc4c_s7_read_write_cotp_parameter_type _type;
};
diff --git a/sandbox/plc4c/generated-sources/s7/includes/cotp_parameter_tpdu_size.h b/sandbox/plc4c/generated-sources/s7/includes/cotp_parameter_tpdu_size.h
index 8d9a44f..8c39e08 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/cotp_parameter_tpdu_size.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/cotp_parameter_tpdu_size.h
@@ -25,8 +25,8 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
-#include "cotp_tpdu_size.h"
#include "cotp_parameter.h"
+#include "cotp_tpdu_size.h"
struct plc4c_s7_read_write_cotp_parameter_tpdu_size {
plc4c_s7_read_write_cotp_parameter_type _type;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/cotp_tpdu_size.h b/sandbox/plc4c/generated-sources/s7/includes/cotp_tpdu_size.h
index d2b5c19..5087daa 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/cotp_tpdu_size.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/cotp_tpdu_size.h
@@ -37,7 +37,7 @@ enum plc4c_s7_read_write_cotp_tpdu_size {
typedef enum plc4c_s7_read_write_cotp_tpdu_size plc4c_s7_read_write_cotp_tpdu_size;
-uint8_t plc4c_s7_read_write_cotp_tpdu_size_get_size_in_bytes(plc4c_s7_read_write_cotp_tpdu_size value) {
+uint16_t plc4c_s7_read_write_cotp_tpdu_size_get_size_in_bytes(plc4c_s7_read_write_cotp_tpdu_size value) {
switch(value) {
case 7: { /* '0x07' */
return 128;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_address.h b/sandbox/plc4c/generated-sources/s7/includes/s7_address.h
index 3976fc8..88aee52 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_address.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_address.h
@@ -26,11 +26,20 @@ extern "C" {
#include <stdint.h>
#include <plc4c/utils/list.h>
+// Structure used to contain the discriminator values for discriminated types using this as a parent
+struct plc4c_s7_read_write_s7_address_discriminator {
+ uint8_t addressType;
+};
+typedef struct plc4c_s7_read_write_s7_address_discriminator plc4c_s7_read_write_s7_address_discriminator;
+
// Enum assigning each sub-type an individual id.
enum plc4c_s7_read_write_s7_address_type {
plc4c_s7_read_write_s7_address_type_s7_read_write_s7_address_any = 0};
typedef enum plc4c_s7_read_write_s7_address_type plc4c_s7_read_write_s7_address_type;
+// Function to get the discriminator values for a given type.
+plc4c_s7_read_write_s7_address_discriminator plc4c_s7_read_write_s7_address_get_discriminator(plc4c_s7_read_write_s7_address_type type);
+
struct plc4c_s7_read_write_s7_address {
plc4c_s7_read_write_s7_address_type _type;
};
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_address_any.h b/sandbox/plc4c/generated-sources/s7/includes/s7_address_any.h
index 926ada6..4918717 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_address_any.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_address_any.h
@@ -25,9 +25,9 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
-#include "transport_size.h"
#include "memory_area.h"
#include "s7_address.h"
+#include "transport_size.h"
struct plc4c_s7_read_write_s7_address_any {
plc4c_s7_read_write_s7_address_type _type;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_message.h b/sandbox/plc4c/generated-sources/s7/includes/s7_message.h
index 5043cb9..35276a5 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_message.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_message.h
@@ -28,6 +28,12 @@ extern "C" {
#include "s7_parameter.h"
#include "s7_payload.h"
+// Structure used to contain the discriminator values for discriminated types using this as a parent
+struct plc4c_s7_read_write_s7_message_discriminator {
+ uint8_t messageType;
+};
+typedef struct plc4c_s7_read_write_s7_message_discriminator plc4c_s7_read_write_s7_message_discriminator;
+
// Enum assigning each sub-type an individual id.
enum plc4c_s7_read_write_s7_message_type {
plc4c_s7_read_write_s7_message_type_s7_read_write_s7_message_request = 0,
@@ -36,6 +42,9 @@ enum plc4c_s7_read_write_s7_message_type {
plc4c_s7_read_write_s7_message_type_s7_read_write_s7_message_user_data = 3};
typedef enum plc4c_s7_read_write_s7_message_type plc4c_s7_read_write_s7_message_type;
+// Function to get the discriminator values for a given type.
+plc4c_s7_read_write_s7_message_discriminator plc4c_s7_read_write_s7_message_get_discriminator(plc4c_s7_read_write_s7_message_type type);
+
// Constant values.
const uint8_t S7_READ_WRITE_S7_MESSAGE_PROTOCOL_ID = 0x32;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_message_request.h b/sandbox/plc4c/generated-sources/s7/includes/s7_message_request.h
index 5a32198..a05699c 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_message_request.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_message_request.h
@@ -25,9 +25,9 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
+#include "s7_message.h"
#include "s7_parameter.h"
#include "s7_payload.h"
-#include "s7_message.h"
struct plc4c_s7_read_write_s7_message_request {
plc4c_s7_read_write_s7_message_type _type;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_message_response.h b/sandbox/plc4c/generated-sources/s7/includes/s7_message_response.h
index 31544e7..cb4c27d 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_message_response.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_message_response.h
@@ -25,9 +25,9 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
+#include "s7_message.h"
#include "s7_parameter.h"
#include "s7_payload.h"
-#include "s7_message.h"
struct plc4c_s7_read_write_s7_message_response {
plc4c_s7_read_write_s7_message_type _type;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_message_response_data.h b/sandbox/plc4c/generated-sources/s7/includes/s7_message_response_data.h
index 7089033..4f3e713 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_message_response_data.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_message_response_data.h
@@ -25,9 +25,9 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
+#include "s7_message.h"
#include "s7_parameter.h"
#include "s7_payload.h"
-#include "s7_message.h"
struct plc4c_s7_read_write_s7_message_response_data {
plc4c_s7_read_write_s7_message_type _type;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_message_user_data.h b/sandbox/plc4c/generated-sources/s7/includes/s7_message_user_data.h
index 2b9e246..b56aa64 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_message_user_data.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_message_user_data.h
@@ -25,9 +25,9 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
+#include "s7_message.h"
#include "s7_parameter.h"
#include "s7_payload.h"
-#include "s7_message.h"
struct plc4c_s7_read_write_s7_message_user_data {
plc4c_s7_read_write_s7_message_type _type;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_parameter.h b/sandbox/plc4c/generated-sources/s7/includes/s7_parameter.h
index 36d53a2..4ea84f8 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_parameter.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_parameter.h
@@ -26,6 +26,13 @@ extern "C" {
#include <stdint.h>
#include <plc4c/utils/list.h>
+// Structure used to contain the discriminator values for discriminated types using this as a parent
+struct plc4c_s7_read_write_s7_parameter_discriminator {
+ uint8_t messageType;
+ uint8_t parameterType;
+};
+typedef struct plc4c_s7_read_write_s7_parameter_discriminator plc4c_s7_read_write_s7_parameter_discriminator;
+
// Enum assigning each sub-type an individual id.
enum plc4c_s7_read_write_s7_parameter_type {
plc4c_s7_read_write_s7_parameter_type_s7_read_write_s7_parameter_setup_communication = 0,
@@ -36,6 +43,9 @@ enum plc4c_s7_read_write_s7_parameter_type {
plc4c_s7_read_write_s7_parameter_type_s7_read_write_s7_parameter_user_data = 5};
typedef enum plc4c_s7_read_write_s7_parameter_type plc4c_s7_read_write_s7_parameter_type;
+// Function to get the discriminator values for a given type.
+plc4c_s7_read_write_s7_parameter_discriminator plc4c_s7_read_write_s7_parameter_get_discriminator(plc4c_s7_read_write_s7_parameter_type type);
+
struct plc4c_s7_read_write_s7_parameter {
plc4c_s7_read_write_s7_parameter_type _type;
};
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_parameter_read_var_request.h b/sandbox/plc4c/generated-sources/s7/includes/s7_parameter_read_var_request.h
index 5fb945d..67aaa73 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_parameter_read_var_request.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_parameter_read_var_request.h
@@ -25,8 +25,8 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
-#include "s7_var_request_parameter_item.h"
#include "s7_parameter.h"
+#include "s7_var_request_parameter_item.h"
struct plc4c_s7_read_write_s7_parameter_read_var_request {
plc4c_s7_read_write_s7_parameter_type _type;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_parameter_user_data.h b/sandbox/plc4c/generated-sources/s7/includes/s7_parameter_user_data.h
index 5374da3..30e1543 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_parameter_user_data.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_parameter_user_data.h
@@ -25,8 +25,8 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
-#include "s7_parameter_user_data_item.h"
#include "s7_parameter.h"
+#include "s7_parameter_user_data_item.h"
struct plc4c_s7_read_write_s7_parameter_user_data {
plc4c_s7_read_write_s7_parameter_type _type;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_parameter_user_data_item.h b/sandbox/plc4c/generated-sources/s7/includes/s7_parameter_user_data_item.h
index fa3f84f..da179f1 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_parameter_user_data_item.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_parameter_user_data_item.h
@@ -26,11 +26,20 @@ extern "C" {
#include <stdint.h>
#include <plc4c/utils/list.h>
+// Structure used to contain the discriminator values for discriminated types using this as a parent
+struct plc4c_s7_read_write_s7_parameter_user_data_item_discriminator {
+ uint8_t itemType;
+};
+typedef struct plc4c_s7_read_write_s7_parameter_user_data_item_discriminator plc4c_s7_read_write_s7_parameter_user_data_item_discriminator;
+
// Enum assigning each sub-type an individual id.
enum plc4c_s7_read_write_s7_parameter_user_data_item_type {
plc4c_s7_read_write_s7_parameter_user_data_item_type_s7_read_write_s7_parameter_user_data_item_cpu_functions = 0};
typedef enum plc4c_s7_read_write_s7_parameter_user_data_item_type plc4c_s7_read_write_s7_parameter_user_data_item_type;
+// Function to get the discriminator values for a given type.
+plc4c_s7_read_write_s7_parameter_user_data_item_discriminator plc4c_s7_read_write_s7_parameter_user_data_item_get_discriminator(plc4c_s7_read_write_s7_parameter_user_data_item_type type);
+
struct plc4c_s7_read_write_s7_parameter_user_data_item {
plc4c_s7_read_write_s7_parameter_user_data_item_type _type;
};
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_parameter_write_var_request.h b/sandbox/plc4c/generated-sources/s7/includes/s7_parameter_write_var_request.h
index e5c6b60..4ddcf97 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_parameter_write_var_request.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_parameter_write_var_request.h
@@ -25,8 +25,8 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
-#include "s7_var_request_parameter_item.h"
#include "s7_parameter.h"
+#include "s7_var_request_parameter_item.h"
struct plc4c_s7_read_write_s7_parameter_write_var_request {
plc4c_s7_read_write_s7_parameter_type _type;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_payload.h b/sandbox/plc4c/generated-sources/s7/includes/s7_payload.h
index 628e022..1526bfe 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_payload.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_payload.h
@@ -25,6 +25,14 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
+#include "s7_parameter.h"
+
+// Structure used to contain the discriminator values for discriminated types using this as a parent
+struct plc4c_s7_read_write_s7_payload_discriminator {
+ uint8_t messageType;
+ uint8_t parameter_parameterType;
+};
+typedef struct plc4c_s7_read_write_s7_payload_discriminator plc4c_s7_read_write_s7_payload_discriminator;
// Enum assigning each sub-type an individual id.
enum plc4c_s7_read_write_s7_payload_type {
@@ -34,12 +42,15 @@ enum plc4c_s7_read_write_s7_payload_type {
plc4c_s7_read_write_s7_payload_type_s7_read_write_s7_payload_user_data = 3};
typedef enum plc4c_s7_read_write_s7_payload_type plc4c_s7_read_write_s7_payload_type;
+// Function to get the discriminator values for a given type.
+plc4c_s7_read_write_s7_payload_discriminator plc4c_s7_read_write_s7_payload_get_discriminator(plc4c_s7_read_write_s7_payload_type type);
+
struct plc4c_s7_read_write_s7_payload {
plc4c_s7_read_write_s7_payload_type _type;
};
typedef struct plc4c_s7_read_write_s7_payload plc4c_s7_read_write_s7_payload;
-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* 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_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_payload* message);
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_payload_read_var_response.h b/sandbox/plc4c/generated-sources/s7/includes/s7_payload_read_var_response.h
index b4601a6..5e0c652 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_payload_read_var_response.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_payload_read_var_response.h
@@ -25,8 +25,9 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
-#include "s7_var_payload_data_item.h"
+#include "s7_parameter.h"
#include "s7_payload.h"
+#include "s7_var_payload_data_item.h"
struct plc4c_s7_read_write_s7_payload_read_var_response {
plc4c_s7_read_write_s7_payload_type _type;
@@ -34,7 +35,7 @@ struct plc4c_s7_read_write_s7_payload_read_var_response {
};
typedef struct plc4c_s7_read_write_s7_payload_read_var_response plc4c_s7_read_write_s7_payload_read_var_response;
-plc4c_return_code plc4c_s7_read_write_s7_payload_read_var_response_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter parameter, plc4c_s7_read_write_s7_payload_read_var_response** message);
+plc4c_return_code plc4c_s7_read_write_s7_payload_read_var_response_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter* parameter, plc4c_s7_read_write_s7_payload_read_var_response** message);
plc4c_return_code plc4c_s7_read_write_s7_payload_read_var_response_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_payload_read_var_response* message);
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_payload_user_data.h b/sandbox/plc4c/generated-sources/s7/includes/s7_payload_user_data.h
index 83f714b..709d2c3 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_payload_user_data.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_payload_user_data.h
@@ -25,8 +25,9 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
-#include "s7_payload_user_data_item.h"
+#include "s7_parameter.h"
#include "s7_payload.h"
+#include "s7_payload_user_data_item.h"
struct plc4c_s7_read_write_s7_payload_user_data {
plc4c_s7_read_write_s7_payload_type _type;
@@ -34,7 +35,7 @@ struct plc4c_s7_read_write_s7_payload_user_data {
};
typedef struct plc4c_s7_read_write_s7_payload_user_data plc4c_s7_read_write_s7_payload_user_data;
-plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter parameter, plc4c_s7_read_write_s7_payload_user_data** message);
+plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter* parameter, plc4c_s7_read_write_s7_payload_user_data** message);
plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_payload_user_data* message);
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_payload_user_data_item.h b/sandbox/plc4c/generated-sources/s7/includes/s7_payload_user_data_item.h
index 72beb17..0ab2349 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_payload_user_data_item.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_payload_user_data_item.h
@@ -29,12 +29,21 @@ extern "C" {
#include "data_transport_size.h"
#include "szl_id.h"
+// Structure used to contain the discriminator values for discriminated types using this as a parent
+struct plc4c_s7_read_write_s7_payload_user_data_item_discriminator {
+ unsigned int cpuFunctionType;
+};
+typedef struct plc4c_s7_read_write_s7_payload_user_data_item_discriminator plc4c_s7_read_write_s7_payload_user_data_item_discriminator;
+
// Enum assigning each sub-type an individual id.
enum plc4c_s7_read_write_s7_payload_user_data_item_type {
plc4c_s7_read_write_s7_payload_user_data_item_type_s7_read_write_s7_payload_user_data_item_cpu_function_read_szl_request = 0,
plc4c_s7_read_write_s7_payload_user_data_item_type_s7_read_write_s7_payload_user_data_item_cpu_function_read_szl_response = 1};
typedef enum plc4c_s7_read_write_s7_payload_user_data_item_type plc4c_s7_read_write_s7_payload_user_data_item_type;
+// Function to get the discriminator values for a given type.
+plc4c_s7_read_write_s7_payload_user_data_item_discriminator plc4c_s7_read_write_s7_payload_user_data_item_get_discriminator(plc4c_s7_read_write_s7_payload_user_data_item_type type);
+
struct plc4c_s7_read_write_s7_payload_user_data_item {
plc4c_s7_read_write_s7_payload_user_data_item_type _type;
plc4c_s7_read_write_data_transport_error_code* return_code;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_payload_user_data_item_cpu_function_read_szl_request.h b/sandbox/plc4c/generated-sources/s7/includes/s7_payload_user_data_item_cpu_function_read_szl_request.h
index dd3db17..71b52aa 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_payload_user_data_item_cpu_function_read_szl_request.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_payload_user_data_item_cpu_function_read_szl_request.h
@@ -27,8 +27,8 @@ extern "C" {
#include <plc4c/utils/list.h>
#include "data_transport_error_code.h"
#include "data_transport_size.h"
-#include "szl_id.h"
#include "s7_payload_user_data_item.h"
+#include "szl_id.h"
struct plc4c_s7_read_write_s7_payload_user_data_item_cpu_function_read_szl_request {
plc4c_s7_read_write_s7_payload_user_data_item_type _type;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_payload_user_data_item_cpu_function_read_szl_response.h b/sandbox/plc4c/generated-sources/s7/includes/s7_payload_user_data_item_cpu_function_read_szl_response.h
index 1c46ee6..52a4af9 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_payload_user_data_item_cpu_function_read_szl_response.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_payload_user_data_item_cpu_function_read_szl_response.h
@@ -27,9 +27,9 @@ extern "C" {
#include <plc4c/utils/list.h>
#include "data_transport_error_code.h"
#include "data_transport_size.h"
-#include "szl_id.h"
-#include "szl_data_tree_item.h"
#include "s7_payload_user_data_item.h"
+#include "szl_data_tree_item.h"
+#include "szl_id.h"
// Constant values.
const uint16_t S7_READ_WRITE_S7_PAYLOAD_USER_DATA_ITEM_CPU_FUNCTION_READ_SZL_RESPONSE_SZL_ITEM_LENGTH = 28;
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_payload_write_var_request.h b/sandbox/plc4c/generated-sources/s7/includes/s7_payload_write_var_request.h
index 4e88a93..def42a7 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_payload_write_var_request.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_payload_write_var_request.h
@@ -25,8 +25,9 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
-#include "s7_var_payload_data_item.h"
+#include "s7_parameter.h"
#include "s7_payload.h"
+#include "s7_var_payload_data_item.h"
struct plc4c_s7_read_write_s7_payload_write_var_request {
plc4c_s7_read_write_s7_payload_type _type;
@@ -34,7 +35,7 @@ struct plc4c_s7_read_write_s7_payload_write_var_request {
};
typedef struct plc4c_s7_read_write_s7_payload_write_var_request plc4c_s7_read_write_s7_payload_write_var_request;
-plc4c_return_code plc4c_s7_read_write_s7_payload_write_var_request_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter parameter, plc4c_s7_read_write_s7_payload_write_var_request** message);
+plc4c_return_code plc4c_s7_read_write_s7_payload_write_var_request_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter* parameter, plc4c_s7_read_write_s7_payload_write_var_request** message);
plc4c_return_code plc4c_s7_read_write_s7_payload_write_var_request_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_payload_write_var_request* message);
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_payload_write_var_response.h b/sandbox/plc4c/generated-sources/s7/includes/s7_payload_write_var_response.h
index 7854ae4..70ea775 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_payload_write_var_response.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_payload_write_var_response.h
@@ -25,8 +25,9 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/utils/list.h>
-#include "s7_var_payload_status_item.h"
+#include "s7_parameter.h"
#include "s7_payload.h"
+#include "s7_var_payload_status_item.h"
struct plc4c_s7_read_write_s7_payload_write_var_response {
plc4c_s7_read_write_s7_payload_type _type;
@@ -34,7 +35,7 @@ struct plc4c_s7_read_write_s7_payload_write_var_response {
};
typedef struct plc4c_s7_read_write_s7_payload_write_var_response plc4c_s7_read_write_s7_payload_write_var_response;
-plc4c_return_code plc4c_s7_read_write_s7_payload_write_var_response_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter parameter, plc4c_s7_read_write_s7_payload_write_var_response** message);
+plc4c_return_code plc4c_s7_read_write_s7_payload_write_var_response_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter* parameter, plc4c_s7_read_write_s7_payload_write_var_response** message);
plc4c_return_code plc4c_s7_read_write_s7_payload_write_var_response_serialize(plc4c_spi_write_buffer* buf, plc4c_s7_read_write_s7_payload_write_var_response* message);
diff --git a/sandbox/plc4c/generated-sources/s7/includes/s7_var_request_parameter_item.h b/sandbox/plc4c/generated-sources/s7/includes/s7_var_request_parameter_item.h
index 72188be..3e54aa2 100644
--- a/sandbox/plc4c/generated-sources/s7/includes/s7_var_request_parameter_item.h
+++ b/sandbox/plc4c/generated-sources/s7/includes/s7_var_request_parameter_item.h
@@ -26,11 +26,20 @@ extern "C" {
#include <stdint.h>
#include <plc4c/utils/list.h>
+// Structure used to contain the discriminator values for discriminated types using this as a parent
+struct plc4c_s7_read_write_s7_var_request_parameter_item_discriminator {
+ uint8_t itemType;
+};
+typedef struct plc4c_s7_read_write_s7_var_request_parameter_item_discriminator plc4c_s7_read_write_s7_var_request_parameter_item_discriminator;
+
// Enum assigning each sub-type an individual id.
enum plc4c_s7_read_write_s7_var_request_parameter_item_type {
plc4c_s7_read_write_s7_var_request_parameter_item_type_s7_read_write_s7_var_request_parameter_item_address = 0};
typedef enum plc4c_s7_read_write_s7_var_request_parameter_item_type plc4c_s7_read_write_s7_var_request_parameter_item_type;
+// Function to get the discriminator values for a given type.
+plc4c_s7_read_write_s7_var_request_parameter_item_discriminator plc4c_s7_read_write_s7_var_request_parameter_item_get_discriminator(plc4c_s7_read_write_s7_var_request_parameter_item_type type);
+
struct plc4c_s7_read_write_s7_var_request_parameter_item {
plc4c_s7_read_write_s7_var_request_parameter_item_type _type;
};
diff --git a/sandbox/plc4c/generated-sources/s7/src/cotp_packet.c b/sandbox/plc4c/generated-sources/s7/src/cotp_packet.c
index 49af465..0b55881 100644
--- a/sandbox/plc4c/generated-sources/s7/src/cotp_packet.c
+++ b/sandbox/plc4c/generated-sources/s7/src/cotp_packet.c
@@ -27,14 +27,40 @@
#include "cotp_packet_disconnect_request.h"
#include "cotp_packet_disconnect_response.h"
#include "cotp_packet_tpdu_error.h"
-
#include "cotp_packet.h"
+// Array of discriminator values that match the enum type constants.
+// (The order is identical to the enum constants so we can use the
+// enum constant to directly access a given types discriminator values)
+const plc4c_s7_read_write_cotp_packet_discriminator plc4c_s7_read_write_cotp_packet_discriminators[] = {
+ {/* s7_read_write_cotp_packet_connection_request */
+ .tpduCode = 0xE0},
+ {/* s7_read_write_cotp_packet_connection_response */
+ .tpduCode = 0xD0},
+ {/* s7_read_write_cotp_packet_data */
+ .tpduCode = 0xF0},
+ {/* s7_read_write_cotp_packet_disconnect_request */
+ .tpduCode = 0x80},
+ {/* s7_read_write_cotp_packet_disconnect_response */
+ .tpduCode = 0xC0},
+ {/* s7_read_write_cotp_packet_tpdu_error */
+ .tpduCode = 0x70}
+};
+
+// Function returning the discriminator values for a given type constant.
+plc4c_s7_read_write_cotp_packet_discriminator plc4c_s7_read_write_cotp_packet_get_discriminator(plc4c_s7_read_write_cotp_packet_type type) {
+ return plc4c_s7_read_write_cotp_packet_discriminators[type];
+}
+
+// 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);
uint16_t curPos;
- plc4c_s7_read_write_cotp_packet* msg = malloc(sizeof(plc4c_s7_read_write_cotp_packet));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
@@ -43,23 +69,23 @@ plc4c_return_code plc4c_s7_read_write_cotp_packet_parse(plc4c_spi_read_buffer* b
uint8_t tpduCode = plc4c_spi_read_unsigned_short(buf, 8);
// Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
- if(plc4c_spi_evaluation_helper_equals(tpduCode, 0xF0)) {
- plc4c_s7_read_write_cotp_packet_data_parse(buf, cotpLen, NULL/* Disabled for now */);
+ if(tpduCode == 0xF0) {
+ plc4c_s7_read_write_cotp_packet_data_parse(buf, cotpLen, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(tpduCode, 0xE0)) {
- plc4c_s7_read_write_cotp_packet_connection_request_parse(buf, cotpLen, NULL/* Disabled for now */);
+ if(tpduCode == 0xE0) {
+ plc4c_s7_read_write_cotp_packet_connection_request_parse(buf, cotpLen, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(tpduCode, 0xD0)) {
- plc4c_s7_read_write_cotp_packet_connection_response_parse(buf, cotpLen, NULL/* Disabled for now */);
+ if(tpduCode == 0xD0) {
+ plc4c_s7_read_write_cotp_packet_connection_response_parse(buf, cotpLen, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(tpduCode, 0x80)) {
- plc4c_s7_read_write_cotp_packet_disconnect_request_parse(buf, cotpLen, NULL/* Disabled for now */);
+ if(tpduCode == 0x80) {
+ plc4c_s7_read_write_cotp_packet_disconnect_request_parse(buf, cotpLen, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(tpduCode, 0xC0)) {
- plc4c_s7_read_write_cotp_packet_disconnect_response_parse(buf, cotpLen, NULL/* Disabled for now */);
+ if(tpduCode == 0xC0) {
+ plc4c_s7_read_write_cotp_packet_disconnect_response_parse(buf, cotpLen, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(tpduCode, 0x70)) {
- plc4c_s7_read_write_cotp_packet_tpdu_error_parse(buf, cotpLen, NULL/* Disabled for now */);
+ if(tpduCode == 0x70) {
+ plc4c_s7_read_write_cotp_packet_tpdu_error_parse(buf, cotpLen, &msg);
}
// Optional Field (payload) (Can be skipped, if a given expression evaluates to false)
diff --git a/sandbox/plc4c/generated-sources/s7/src/cotp_packet_connection_request.c b/sandbox/plc4c/generated-sources/s7/src/cotp_packet_connection_request.c
index ca2fde1..3f145a6 100644
--- a/sandbox/plc4c/generated-sources/s7/src/cotp_packet_connection_request.c
+++ b/sandbox/plc4c/generated-sources/s7/src/cotp_packet_connection_request.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "cotp_packet_connection_request.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_cotp_packet_connection_request_parse(plc4c_spi_read_buffer* buf, uint16_t cotpLen, plc4c_s7_read_write_cotp_packet_connection_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_cotp_packet_connection_request* msg = malloc(sizeof(plc4c_s7_read_write_cotp_packet_connection_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (destinationReference)
uint16_t destinationReference = plc4c_spi_read_unsigned_int(buf, 16);
- msg->destination_reference = destinationReference;
// Simple Field (sourceReference)
uint16_t sourceReference = plc4c_spi_read_unsigned_int(buf, 16);
- msg->source_reference = sourceReference;
// Enum field (protocolClass)
plc4c_s7_read_write_cotp_protocol_class protocolClass = plc4c_spi_read_byte(buf, 8);
diff --git a/sandbox/plc4c/generated-sources/s7/src/cotp_packet_connection_response.c b/sandbox/plc4c/generated-sources/s7/src/cotp_packet_connection_response.c
index 4c606a1..213e284 100644
--- a/sandbox/plc4c/generated-sources/s7/src/cotp_packet_connection_response.c
+++ b/sandbox/plc4c/generated-sources/s7/src/cotp_packet_connection_response.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "cotp_packet_connection_response.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_cotp_packet_connection_response_parse(plc4c_spi_read_buffer* buf, uint16_t cotpLen, plc4c_s7_read_write_cotp_packet_connection_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_cotp_packet_connection_response* msg = malloc(sizeof(plc4c_s7_read_write_cotp_packet_connection_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (destinationReference)
uint16_t destinationReference = plc4c_spi_read_unsigned_int(buf, 16);
- msg->destination_reference = destinationReference;
// Simple Field (sourceReference)
uint16_t sourceReference = plc4c_spi_read_unsigned_int(buf, 16);
- msg->source_reference = sourceReference;
// Enum field (protocolClass)
plc4c_s7_read_write_cotp_protocol_class protocolClass = plc4c_spi_read_byte(buf, 8);
diff --git a/sandbox/plc4c/generated-sources/s7/src/cotp_packet_data.c b/sandbox/plc4c/generated-sources/s7/src/cotp_packet_data.c
index 02325c8..1f3ef1d 100644
--- a/sandbox/plc4c/generated-sources/s7/src/cotp_packet_data.c
+++ b/sandbox/plc4c/generated-sources/s7/src/cotp_packet_data.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "cotp_packet_data.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_cotp_packet_data_parse(plc4c_spi_read_buffer* buf, uint16_t cotpLen, plc4c_s7_read_write_cotp_packet_data** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_cotp_packet_data* msg = malloc(sizeof(plc4c_s7_read_write_cotp_packet_data));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (eot)
bool eot = plc4c_spi_read_bit(buf);
- msg->eot = eot;
// Simple Field (tpduRef)
unsigned int tpduRef = plc4c_spi_read_unsigned_short(buf, 7);
- msg->tpdu_ref = tpduRef;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/cotp_packet_disconnect_request.c b/sandbox/plc4c/generated-sources/s7/src/cotp_packet_disconnect_request.c
index 8532843..cb01362 100644
--- a/sandbox/plc4c/generated-sources/s7/src/cotp_packet_disconnect_request.c
+++ b/sandbox/plc4c/generated-sources/s7/src/cotp_packet_disconnect_request.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "cotp_packet_disconnect_request.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_cotp_packet_disconnect_request_parse(plc4c_spi_read_buffer* buf, uint16_t cotpLen, plc4c_s7_read_write_cotp_packet_disconnect_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_cotp_packet_disconnect_request* msg = malloc(sizeof(plc4c_s7_read_write_cotp_packet_disconnect_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (destinationReference)
uint16_t destinationReference = plc4c_spi_read_unsigned_int(buf, 16);
- msg->destination_reference = destinationReference;
// Simple Field (sourceReference)
uint16_t sourceReference = plc4c_spi_read_unsigned_int(buf, 16);
- msg->source_reference = sourceReference;
// Enum field (protocolClass)
plc4c_s7_read_write_cotp_protocol_class protocolClass = plc4c_spi_read_byte(buf, 8);
diff --git a/sandbox/plc4c/generated-sources/s7/src/cotp_packet_disconnect_response.c b/sandbox/plc4c/generated-sources/s7/src/cotp_packet_disconnect_response.c
index e23e46d..75ea554 100644
--- a/sandbox/plc4c/generated-sources/s7/src/cotp_packet_disconnect_response.c
+++ b/sandbox/plc4c/generated-sources/s7/src/cotp_packet_disconnect_response.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "cotp_packet_disconnect_response.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_cotp_packet_disconnect_response_parse(plc4c_spi_read_buffer* buf, uint16_t cotpLen, plc4c_s7_read_write_cotp_packet_disconnect_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_cotp_packet_disconnect_response* msg = malloc(sizeof(plc4c_s7_read_write_cotp_packet_disconnect_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (destinationReference)
uint16_t destinationReference = plc4c_spi_read_unsigned_int(buf, 16);
- msg->destination_reference = destinationReference;
// Simple Field (sourceReference)
uint16_t sourceReference = plc4c_spi_read_unsigned_int(buf, 16);
- msg->source_reference = sourceReference;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/cotp_packet_tpdu_error.c b/sandbox/plc4c/generated-sources/s7/src/cotp_packet_tpdu_error.c
index 1fa6ce0..b090cf6 100644
--- a/sandbox/plc4c/generated-sources/s7/src/cotp_packet_tpdu_error.c
+++ b/sandbox/plc4c/generated-sources/s7/src/cotp_packet_tpdu_error.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "cotp_packet_tpdu_error.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_cotp_packet_tpdu_error_parse(plc4c_spi_read_buffer* buf, uint16_t cotpLen, plc4c_s7_read_write_cotp_packet_tpdu_error** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_cotp_packet_tpdu_error* msg = malloc(sizeof(plc4c_s7_read_write_cotp_packet_tpdu_error));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (destinationReference)
uint16_t destinationReference = plc4c_spi_read_unsigned_int(buf, 16);
- msg->destination_reference = destinationReference;
// Simple Field (rejectCause)
uint8_t rejectCause = plc4c_spi_read_unsigned_short(buf, 8);
- msg->reject_cause = rejectCause;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/cotp_parameter.c b/sandbox/plc4c/generated-sources/s7/src/cotp_parameter.c
index 171298c..be86263 100644
--- a/sandbox/plc4c/generated-sources/s7/src/cotp_parameter.c
+++ b/sandbox/plc4c/generated-sources/s7/src/cotp_parameter.c
@@ -26,14 +26,38 @@
#include "cotp_parameter_called_tsap.h"
#include "cotp_parameter_checksum.h"
#include "cotp_parameter_disconnect_additional_information.h"
-
#include "cotp_parameter.h"
+// Array of discriminator values that match the enum type constants.
+// (The order is identical to the enum constants so we can use the
+// enum constant to directly access a given types discriminator values)
+const plc4c_s7_read_write_cotp_parameter_discriminator plc4c_s7_read_write_cotp_parameter_discriminators[] = {
+ {/* s7_read_write_cotp_parameter_called_tsap */
+ .parameterType = 0xC2},
+ {/* s7_read_write_cotp_parameter_calling_tsap */
+ .parameterType = 0xC1},
+ {/* s7_read_write_cotp_parameter_checksum */
+ .parameterType = 0xC3},
+ {/* s7_read_write_cotp_parameter_disconnect_additional_information */
+ .parameterType = 0xE0},
+ {/* s7_read_write_cotp_parameter_tpdu_size */
+ .parameterType = 0xC0}
+};
+
+// Function returning the discriminator values for a given type constant.
+plc4c_s7_read_write_cotp_parameter_discriminator plc4c_s7_read_write_cotp_parameter_get_discriminator(plc4c_s7_read_write_cotp_parameter_type type) {
+ return plc4c_s7_read_write_cotp_parameter_discriminators[type];
+}
+
+// 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);
uint16_t curPos;
- plc4c_s7_read_write_cotp_parameter* msg = malloc(sizeof(plc4c_s7_read_write_cotp_parameter));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Discriminator Field (parameterType) (Used as input to a switch field)
uint8_t parameterType = plc4c_spi_read_unsigned_short(buf, 8);
@@ -42,20 +66,20 @@ plc4c_return_code plc4c_s7_read_write_cotp_parameter_parse(plc4c_spi_read_buffer
uint8_t parameterLength = plc4c_spi_read_unsigned_short(buf, 8);
// Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
- if(plc4c_spi_evaluation_helper_equals(parameterType, 0xC0)) {
- plc4c_s7_read_write_cotp_parameter_tpdu_size_parse(buf, rest, NULL/* Disabled for now */);
+ if(parameterType == 0xC0) {
+ plc4c_s7_read_write_cotp_parameter_tpdu_size_parse(buf, rest, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(parameterType, 0xC1)) {
- plc4c_s7_read_write_cotp_parameter_calling_tsap_parse(buf, rest, NULL/* Disabled for now */);
+ if(parameterType == 0xC1) {
+ plc4c_s7_read_write_cotp_parameter_calling_tsap_parse(buf, rest, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(parameterType, 0xC2)) {
- plc4c_s7_read_write_cotp_parameter_called_tsap_parse(buf, rest, NULL/* Disabled for now */);
+ if(parameterType == 0xC2) {
+ plc4c_s7_read_write_cotp_parameter_called_tsap_parse(buf, rest, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(parameterType, 0xC3)) {
- plc4c_s7_read_write_cotp_parameter_checksum_parse(buf, rest, NULL/* Disabled for now */);
+ if(parameterType == 0xC3) {
+ plc4c_s7_read_write_cotp_parameter_checksum_parse(buf, rest, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(parameterType, 0xE0)) {
- plc4c_s7_read_write_cotp_parameter_disconnect_additional_information_parse(buf, rest, NULL/* Disabled for now */);
+ if(parameterType == 0xE0) {
+ plc4c_s7_read_write_cotp_parameter_disconnect_additional_information_parse(buf, rest, &msg);
}
return OK;
diff --git a/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_called_tsap.c b/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_called_tsap.c
index 121e0c8..1dbbd13 100644
--- a/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_called_tsap.c
+++ b/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_called_tsap.c
@@ -21,18 +21,20 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "cotp_parameter_called_tsap.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_cotp_parameter_called_tsap_parse(plc4c_spi_read_buffer* buf, uint8_t rest, plc4c_s7_read_write_cotp_parameter_called_tsap** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_cotp_parameter_called_tsap* msg = malloc(sizeof(plc4c_s7_read_write_cotp_parameter_called_tsap));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (tsapId)
uint16_t tsapId = plc4c_spi_read_unsigned_int(buf, 16);
- msg->tsap_id = tsapId;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_calling_tsap.c b/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_calling_tsap.c
index ac9e13c..9710330 100644
--- a/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_calling_tsap.c
+++ b/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_calling_tsap.c
@@ -21,18 +21,20 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "cotp_parameter_calling_tsap.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_cotp_parameter_calling_tsap_parse(plc4c_spi_read_buffer* buf, uint8_t rest, plc4c_s7_read_write_cotp_parameter_calling_tsap** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_cotp_parameter_calling_tsap* msg = malloc(sizeof(plc4c_s7_read_write_cotp_parameter_calling_tsap));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (tsapId)
uint16_t tsapId = plc4c_spi_read_unsigned_int(buf, 16);
- msg->tsap_id = tsapId;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_checksum.c b/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_checksum.c
index 0e8a3ef..6793191 100644
--- a/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_checksum.c
+++ b/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_checksum.c
@@ -21,18 +21,20 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "cotp_parameter_checksum.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_cotp_parameter_checksum_parse(plc4c_spi_read_buffer* buf, uint8_t rest, plc4c_s7_read_write_cotp_parameter_checksum** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_cotp_parameter_checksum* msg = malloc(sizeof(plc4c_s7_read_write_cotp_parameter_checksum));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (crc)
uint8_t crc = plc4c_spi_read_unsigned_short(buf, 8);
- msg->crc = crc;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_disconnect_additional_information.c b/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_disconnect_additional_information.c
index acbb30c..3094452 100644
--- a/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_disconnect_additional_information.c
+++ b/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_disconnect_additional_information.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "cotp_parameter_disconnect_additional_information.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_cotp_parameter_disconnect_additional_information_parse(plc4c_spi_read_buffer* buf, uint8_t rest, plc4c_s7_read_write_cotp_parameter_disconnect_additional_information** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_cotp_parameter_disconnect_additional_information* msg = malloc(sizeof(plc4c_s7_read_write_cotp_parameter_disconnect_additional_information));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_tpdu_size.c b/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_tpdu_size.c
index bab4c04..66fc3c1 100644
--- a/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_tpdu_size.c
+++ b/sandbox/plc4c/generated-sources/s7/src/cotp_parameter_tpdu_size.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "cotp_parameter_tpdu_size.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_cotp_parameter_tpdu_size_parse(plc4c_spi_read_buffer* buf, uint8_t rest, plc4c_s7_read_write_cotp_parameter_tpdu_size** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_cotp_parameter_tpdu_size* msg = malloc(sizeof(plc4c_s7_read_write_cotp_parameter_tpdu_size));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Enum field (tpduSize)
plc4c_s7_read_write_cotp_tpdu_size tpduSize = plc4c_spi_read_byte(buf, 8);
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_address.c b/sandbox/plc4c/generated-sources/s7/src/s7_address.c
index 2fd7f23..ed074f8 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_address.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_address.c
@@ -22,21 +22,37 @@
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
#include "s7_address_any.h"
-
#include "s7_address.h"
+// Array of discriminator values that match the enum type constants.
+// (The order is identical to the enum constants so we can use the
+// enum constant to directly access a given types discriminator values)
+const plc4c_s7_read_write_s7_address_discriminator plc4c_s7_read_write_s7_address_discriminators[] = {
+ {/* s7_read_write_s7_address_any */
+ .addressType = 0x10}
+};
+
+// Function returning the discriminator values for a given type constant.
+plc4c_s7_read_write_s7_address_discriminator plc4c_s7_read_write_s7_address_get_discriminator(plc4c_s7_read_write_s7_address_type type) {
+ return plc4c_s7_read_write_s7_address_discriminators[type];
+}
+
+// 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);
uint16_t curPos;
- plc4c_s7_read_write_s7_address* msg = malloc(sizeof(plc4c_s7_read_write_s7_address));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Discriminator Field (addressType) (Used as input to a switch field)
uint8_t addressType = plc4c_spi_read_unsigned_short(buf, 8);
// Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
- if(plc4c_spi_evaluation_helper_equals(addressType, 0x10)) {
- plc4c_s7_read_write_s7_address_any_parse(buf, NULL/* Disabled for now */);
+ if(addressType == 0x10) {
+ plc4c_s7_read_write_s7_address_any_parse(buf, &msg);
}
return OK;
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_address_any.c b/sandbox/plc4c/generated-sources/s7/src/s7_address_any.c
index 7d0a242..6c365ba 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_address_any.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_address_any.c
@@ -21,25 +21,26 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_address_any.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_s7_address_any_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_s7_address_any** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_s7_address_any* msg = malloc(sizeof(plc4c_s7_read_write_s7_address_any));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Enum field (transportSize)
plc4c_s7_read_write_transport_size transportSize = plc4c_spi_read_byte(buf, 8);
// Simple Field (numberOfElements)
uint16_t numberOfElements = plc4c_spi_read_unsigned_int(buf, 16);
- msg->number_of_elements = numberOfElements;
// Simple Field (dbNumber)
uint16_t dbNumber = plc4c_spi_read_unsigned_int(buf, 16);
- msg->db_number = dbNumber;
// Enum field (area)
plc4c_s7_read_write_memory_area area = plc4c_spi_read_byte(buf, 8);
@@ -54,11 +55,9 @@ plc4c_return_code plc4c_s7_read_write_s7_address_any_parse(plc4c_spi_read_buffer
// Simple Field (byteAddress)
uint16_t byteAddress = plc4c_spi_read_unsigned_int(buf, 16);
- msg->byte_address = byteAddress;
// Simple Field (bitAddress)
unsigned int bitAddress = plc4c_spi_read_unsigned_byte(buf, 3);
- msg->bit_address = bitAddress;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_message.c b/sandbox/plc4c/generated-sources/s7/src/s7_message.c
index 74ff2ad..00cc5e0 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_message.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_message.c
@@ -25,14 +25,36 @@
#include "s7_message_response.h"
#include "s7_message_response_data.h"
#include "s7_message_user_data.h"
-
#include "s7_message.h"
+// Array of discriminator values that match the enum type constants.
+// (The order is identical to the enum constants so we can use the
+// enum constant to directly access a given types discriminator values)
+const plc4c_s7_read_write_s7_message_discriminator plc4c_s7_read_write_s7_message_discriminators[] = {
+ {/* s7_read_write_s7_message_request */
+ .messageType = 0x01},
+ {/* s7_read_write_s7_message_response */
+ .messageType = 0x02},
+ {/* s7_read_write_s7_message_response_data */
+ .messageType = 0x03},
+ {/* s7_read_write_s7_message_user_data */
+ .messageType = 0x07}
+};
+
+// Function returning the discriminator values for a given type constant.
+plc4c_s7_read_write_s7_message_discriminator plc4c_s7_read_write_s7_message_get_discriminator(plc4c_s7_read_write_s7_message_type type) {
+ return plc4c_s7_read_write_s7_message_discriminators[type];
+}
+
+// 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);
uint16_t curPos;
- plc4c_s7_read_write_s7_message* msg = malloc(sizeof(plc4c_s7_read_write_s7_message));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Const Field (protocolId)
uint8_t protocolId = plc4c_spi_read_unsigned_short(buf, 8);
@@ -54,7 +76,6 @@ plc4c_return_code plc4c_s7_read_write_s7_message_parse(plc4c_spi_read_buffer* bu
// Simple Field (tpduReference)
uint16_t tpduReference = plc4c_spi_read_unsigned_int(buf, 16);
- msg->tpdu_reference = tpduReference;
// 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 = plc4c_spi_read_unsigned_int(buf, 16);
@@ -63,17 +84,17 @@ plc4c_return_code plc4c_s7_read_write_s7_message_parse(plc4c_spi_read_buffer* bu
uint16_t payloadLength = plc4c_spi_read_unsigned_int(buf, 16);
// Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
- if(plc4c_spi_evaluation_helper_equals(messageType, 0x01)) {
- plc4c_s7_read_write_s7_message_request_parse(buf, NULL/* Disabled for now */);
+ if(messageType == 0x01) {
+ plc4c_s7_read_write_s7_message_request_parse(buf, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(messageType, 0x02)) {
- plc4c_s7_read_write_s7_message_response_parse(buf, NULL/* Disabled for now */);
+ if(messageType == 0x02) {
+ plc4c_s7_read_write_s7_message_response_parse(buf, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(messageType, 0x03)) {
- plc4c_s7_read_write_s7_message_response_data_parse(buf, NULL/* Disabled for now */);
+ if(messageType == 0x03) {
+ plc4c_s7_read_write_s7_message_response_data_parse(buf, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(messageType, 0x07)) {
- plc4c_s7_read_write_s7_message_user_data_parse(buf, NULL/* Disabled for now */);
+ if(messageType == 0x07) {
+ plc4c_s7_read_write_s7_message_user_data_parse(buf, &msg);
}
// Optional Field (parameter) (Can be skipped, if a given expression evaluates to false)
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_message_request.c b/sandbox/plc4c/generated-sources/s7/src/s7_message_request.c
index 915cdbc..c9e4292 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_message_request.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_message_request.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_message_request.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_s7_message_request_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_s7_message_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_s7_message_request* msg = malloc(sizeof(plc4c_s7_read_write_s7_message_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_message_response.c b/sandbox/plc4c/generated-sources/s7/src/s7_message_response.c
index 8d622e3..0b8dfe4 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_message_response.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_message_response.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_message_response.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_s7_message_response_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_s7_message_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_s7_message_response* msg = malloc(sizeof(plc4c_s7_read_write_s7_message_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (errorClass)
uint8_t errorClass = plc4c_spi_read_unsigned_short(buf, 8);
- msg->error_class = errorClass;
// Simple Field (errorCode)
uint8_t errorCode = plc4c_spi_read_unsigned_short(buf, 8);
- msg->error_code = errorCode;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_message_response_data.c b/sandbox/plc4c/generated-sources/s7/src/s7_message_response_data.c
index 9febd68..44c6420 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_message_response_data.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_message_response_data.c
@@ -21,22 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_message_response_data.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_s7_message_response_data_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_s7_message_response_data** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_s7_message_response_data* msg = malloc(sizeof(plc4c_s7_read_write_s7_message_response_data));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (errorClass)
uint8_t errorClass = plc4c_spi_read_unsigned_short(buf, 8);
- msg->error_class = errorClass;
// Simple Field (errorCode)
uint8_t errorCode = plc4c_spi_read_unsigned_short(buf, 8);
- msg->error_code = errorCode;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_message_user_data.c b/sandbox/plc4c/generated-sources/s7/src/s7_message_user_data.c
index c9fe829..7046605 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_message_user_data.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_message_user_data.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_message_user_data.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_s7_message_user_data_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_s7_message_user_data** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_s7_message_user_data* msg = malloc(sizeof(plc4c_s7_read_write_s7_message_user_data));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_parameter.c b/sandbox/plc4c/generated-sources/s7/src/s7_parameter.c
index 3774cb3..3f1d98c 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_parameter.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_parameter.c
@@ -27,36 +27,62 @@
#include "s7_parameter_write_var_request.h"
#include "s7_parameter_write_var_response.h"
#include "s7_parameter_user_data.h"
-
#include "s7_parameter.h"
+// Array of discriminator values that match the enum type constants.
+// (The order is identical to the enum constants so we can use the
+// enum constant to directly access a given types discriminator values)
+const plc4c_s7_read_write_s7_parameter_discriminator plc4c_s7_read_write_s7_parameter_discriminators[] = {
+ {/* s7_read_write_s7_parameter_read_var_request */
+ .messageType = 0x01, .parameterType = 0x04},
+ {/* s7_read_write_s7_parameter_read_var_response */
+ .messageType = 0x03, .parameterType = 0x04},
+ {/* s7_read_write_s7_parameter_setup_communication */
+ .messageType = -1, .parameterType = 0xF0},
+ {/* s7_read_write_s7_parameter_user_data */
+ .messageType = 0x07, .parameterType = 0x00},
+ {/* s7_read_write_s7_parameter_write_var_request */
+ .messageType = 0x01, .parameterType = 0x05},
+ {/* s7_read_write_s7_parameter_write_var_response */
+ .messageType = 0x03, .parameterType = 0x05}
+};
+
+// Function returning the discriminator values for a given type constant.
+plc4c_s7_read_write_s7_parameter_discriminator plc4c_s7_read_write_s7_parameter_get_discriminator(plc4c_s7_read_write_s7_parameter_type type) {
+ return plc4c_s7_read_write_s7_parameter_discriminators[type];
+}
+
+// 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);
uint16_t curPos;
- plc4c_s7_read_write_s7_parameter* msg = malloc(sizeof(plc4c_s7_read_write_s7_parameter));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Discriminator Field (parameterType) (Used as input to a switch field)
uint8_t parameterType = plc4c_spi_read_unsigned_short(buf, 8);
// Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
- if(plc4c_spi_evaluation_helper_equals(parameterType, 0xF0)) {
- plc4c_s7_read_write_s7_parameter_setup_communication_parse(buf, messageType, NULL/* Disabled for now */);
+ if(parameterType == 0xF0) {
+ plc4c_s7_read_write_s7_parameter_setup_communication_parse(buf, messageType, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(parameterType, 0x04) && plc4c_spi_evaluation_helper_equals(messageType, 0x01)) {
- plc4c_s7_read_write_s7_parameter_read_var_request_parse(buf, messageType, NULL/* Disabled for now */);
+ if((parameterType == 0x04) && (messageType == 0x01)) {
+ plc4c_s7_read_write_s7_parameter_read_var_request_parse(buf, messageType, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(parameterType, 0x04) && plc4c_spi_evaluation_helper_equals(messageType, 0x03)) {
- plc4c_s7_read_write_s7_parameter_read_var_response_parse(buf, messageType, NULL/* Disabled for now */);
+ if((parameterType == 0x04) && (messageType == 0x03)) {
+ plc4c_s7_read_write_s7_parameter_read_var_response_parse(buf, messageType, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(parameterType, 0x05) && plc4c_spi_evaluation_helper_equals(messageType, 0x01)) {
- plc4c_s7_read_write_s7_parameter_write_var_request_parse(buf, messageType, NULL/* Disabled for now */);
+ if((parameterType == 0x05) && (messageType == 0x01)) {
+ plc4c_s7_read_write_s7_parameter_write_var_request_parse(buf, messageType, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(parameterType, 0x05) && plc4c_spi_evaluation_helper_equals(messageType, 0x03)) {
- plc4c_s7_read_write_s7_parameter_write_var_response_parse(buf, messageType, NULL/* Disabled for now */);
+ if((parameterType == 0x05) && (messageType == 0x03)) {
+ plc4c_s7_read_write_s7_parameter_write_var_response_parse(buf, messageType, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(parameterType, 0x00) && plc4c_spi_evaluation_helper_equals(messageType, 0x07)) {
- plc4c_s7_read_write_s7_parameter_user_data_parse(buf, messageType, NULL/* Disabled for now */);
+ if((parameterType == 0x00) && (messageType == 0x07)) {
+ plc4c_s7_read_write_s7_parameter_user_data_parse(buf, messageType, &msg);
}
return OK;
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_parameter_read_var_request.c b/sandbox/plc4c/generated-sources/s7/src/s7_parameter_read_var_request.c
index 6e72536..45a1e4a 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_parameter_read_var_request.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_parameter_read_var_request.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_parameter_read_var_request.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_s7_parameter_read_var_request_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter_read_var_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_s7_parameter_read_var_request* msg = malloc(sizeof(plc4c_s7_read_write_s7_parameter_read_var_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_parameter_read_var_response.c b/sandbox/plc4c/generated-sources/s7/src/s7_parameter_read_var_response.c
index 578900f..1e8eff7 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_parameter_read_var_response.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_parameter_read_var_response.c
@@ -21,18 +21,20 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_parameter_read_var_response.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_s7_parameter_read_var_response_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter_read_var_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_s7_parameter_read_var_response* msg = malloc(sizeof(plc4c_s7_read_write_s7_parameter_read_var_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (numItems)
uint8_t numItems = plc4c_spi_read_unsigned_short(buf, 8);
- msg->num_items = numItems;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_parameter_setup_communication.c b/sandbox/plc4c/generated-sources/s7/src/s7_parameter_setup_communication.c
index d749d50..e8ddba7 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_parameter_setup_communication.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_parameter_setup_communication.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_parameter_setup_communication.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_s7_parameter_setup_communication_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter_setup_communication** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_s7_parameter_setup_communication* msg = malloc(sizeof(plc4c_s7_read_write_s7_parameter_setup_communication));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Reserved Field (Compartmentalized so the "reserved" variable can't leak)
{
@@ -40,15 +43,12 @@ plc4c_return_code plc4c_s7_read_write_s7_parameter_setup_communication_parse(plc
// Simple Field (maxAmqCaller)
uint16_t maxAmqCaller = plc4c_spi_read_unsigned_int(buf, 16);
- msg->max_amq_caller = maxAmqCaller;
// Simple Field (maxAmqCallee)
uint16_t maxAmqCallee = plc4c_spi_read_unsigned_int(buf, 16);
- msg->max_amq_callee = maxAmqCallee;
// Simple Field (pduLength)
uint16_t pduLength = plc4c_spi_read_unsigned_int(buf, 16);
- msg->pdu_length = pduLength;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_parameter_user_data.c b/sandbox/plc4c/generated-sources/s7/src/s7_parameter_user_data.c
index 07694c2..367a408 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_parameter_user_data.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_parameter_user_data.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_parameter_user_data.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_s7_parameter_user_data_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter_user_data** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_s7_parameter_user_data* msg = malloc(sizeof(plc4c_s7_read_write_s7_parameter_user_data));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
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 f809229..e902130 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
@@ -22,21 +22,37 @@
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
#include "s7_parameter_user_data_item_cpu_functions.h"
-
#include "s7_parameter_user_data_item.h"
+// Array of discriminator values that match the enum type constants.
+// (The order is identical to the enum constants so we can use the
+// enum constant to directly access a given types discriminator values)
+const plc4c_s7_read_write_s7_parameter_user_data_item_discriminator plc4c_s7_read_write_s7_parameter_user_data_item_discriminators[] = {
+ {/* s7_read_write_s7_parameter_user_data_item_cpu_functions */
+ .itemType = 0x12}
+};
+
+// Function returning the discriminator values for a given type constant.
+plc4c_s7_read_write_s7_parameter_user_data_item_discriminator plc4c_s7_read_write_s7_parameter_user_data_item_get_discriminator(plc4c_s7_read_write_s7_parameter_user_data_item_type type) {
+ return plc4c_s7_read_write_s7_parameter_user_data_item_discriminators[type];
+}
+
+// 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);
uint16_t curPos;
- plc4c_s7_read_write_s7_parameter_user_data_item* msg = malloc(sizeof(plc4c_s7_read_write_s7_parameter_user_data_item));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Discriminator Field (itemType) (Used as input to a switch field)
uint8_t itemType = plc4c_spi_read_unsigned_short(buf, 8);
// Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
- if(plc4c_spi_evaluation_helper_equals(itemType, 0x12)) {
- plc4c_s7_read_write_s7_parameter_user_data_item_cpu_functions_parse(buf, NULL/* Disabled for now */);
+ if(itemType == 0x12) {
+ plc4c_s7_read_write_s7_parameter_user_data_item_cpu_functions_parse(buf, &msg);
}
return OK;
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_parameter_user_data_item_cpu_functions.c b/sandbox/plc4c/generated-sources/s7/src/s7_parameter_user_data_item_cpu_functions.c
index f705103..fe43648 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_parameter_user_data_item_cpu_functions.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_parameter_user_data_item_cpu_functions.c
@@ -21,37 +21,35 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_parameter_user_data_item_cpu_functions.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_s7_parameter_user_data_item_cpu_functions_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_s7_parameter_user_data_item_cpu_functions** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_s7_parameter_user_data_item_cpu_functions* msg = malloc(sizeof(plc4c_s7_read_write_s7_parameter_user_data_item_cpu_functions));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
// Simple Field (method)
uint8_t method = plc4c_spi_read_unsigned_short(buf, 8);
- msg->method = method;
// Simple Field (cpuFunctionType)
unsigned int cpuFunctionType = plc4c_spi_read_unsigned_byte(buf, 4);
- msg->cpu_function_type = cpuFunctionType;
// Simple Field (cpuFunctionGroup)
unsigned int cpuFunctionGroup = plc4c_spi_read_unsigned_byte(buf, 4);
- msg->cpu_function_group = cpuFunctionGroup;
// Simple Field (cpuSubfunction)
uint8_t cpuSubfunction = plc4c_spi_read_unsigned_short(buf, 8);
- msg->cpu_subfunction = cpuSubfunction;
// Simple Field (sequenceNumber)
uint8_t sequenceNumber = plc4c_spi_read_unsigned_short(buf, 8);
- msg->sequence_number = sequenceNumber;
// Optional Field (dataUnitReferenceNumber) (Can be skipped, if a given expression evaluates to false)
uint8_t dataUnitReferenceNumber = 0;
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_parameter_write_var_request.c b/sandbox/plc4c/generated-sources/s7/src/s7_parameter_write_var_request.c
index d3768a3..e4260c1 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_parameter_write_var_request.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_parameter_write_var_request.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_parameter_write_var_request.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_s7_parameter_write_var_request_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter_write_var_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_s7_parameter_write_var_request* msg = malloc(sizeof(plc4c_s7_read_write_s7_parameter_write_var_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_parameter_write_var_response.c b/sandbox/plc4c/generated-sources/s7/src/s7_parameter_write_var_response.c
index 98bc37d..fc5db96 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_parameter_write_var_response.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_parameter_write_var_response.c
@@ -21,18 +21,20 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_parameter_write_var_response.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_s7_parameter_write_var_response_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter_write_var_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_s7_parameter_write_var_response* msg = malloc(sizeof(plc4c_s7_read_write_s7_parameter_write_var_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (numItems)
uint8_t numItems = plc4c_spi_read_unsigned_short(buf, 8);
- msg->num_items = numItems;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_payload.c b/sandbox/plc4c/generated-sources/s7/src/s7_payload.c
index a374f6a..68bb1c5 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_payload.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_payload.c
@@ -25,27 +25,49 @@
#include "s7_payload_write_var_request.h"
#include "s7_payload_write_var_response.h"
#include "s7_payload_user_data.h"
-
#include "s7_payload.h"
-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) {
+// Array of discriminator values that match the enum type constants.
+// (The order is identical to the enum constants so we can use the
+// enum constant to directly access a given types discriminator values)
+const plc4c_s7_read_write_s7_payload_discriminator plc4c_s7_read_write_s7_payload_discriminators[] = {
+ {/* s7_read_write_s7_payload_read_var_response */
+ .messageType = 0x03, .parameter_parameterType = 0x04},
+ {/* s7_read_write_s7_payload_user_data */
+ .messageType = 0x07, .parameter_parameterType = 0x00},
+ {/* s7_read_write_s7_payload_write_var_request */
+ .messageType = 0x01, .parameter_parameterType = 0x05},
+ {/* s7_read_write_s7_payload_write_var_response */
+ .messageType = 0x03, .parameter_parameterType = 0x05}
+};
+
+// Function returning the discriminator values for a given type constant.
+plc4c_s7_read_write_s7_payload_discriminator plc4c_s7_read_write_s7_payload_get_discriminator(plc4c_s7_read_write_s7_payload_type type) {
+ return plc4c_s7_read_write_s7_payload_discriminators[type];
+}
+
+// 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);
uint16_t curPos;
- plc4c_s7_read_write_s7_payload* msg = malloc(sizeof(plc4c_s7_read_write_s7_payload));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
- if(plc4c_spi_evaluation_helper_equals(parameter.getDiscriminatorValues()[0], 0x04) && plc4c_spi_evaluation_helper_equals(messageType, 0x03)) {
- plc4c_s7_read_write_s7_payload_read_var_response_parse(buf, messageType, parameter, NULL/* Disabled for now */);
+ if((parameter.getParameterType() == 0x04) && (messageType == 0x03)) {
+ plc4c_s7_read_write_s7_payload_read_var_response_parse(buf, messageType, parameter, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(parameter.getDiscriminatorValues()[0], 0x05) && plc4c_spi_evaluation_helper_equals(messageType, 0x01)) {
- plc4c_s7_read_write_s7_payload_write_var_request_parse(buf, messageType, parameter, NULL/* Disabled for now */);
+ if((parameter.getParameterType() == 0x05) && (messageType == 0x01)) {
+ plc4c_s7_read_write_s7_payload_write_var_request_parse(buf, messageType, parameter, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(parameter.getDiscriminatorValues()[0], 0x05) && plc4c_spi_evaluation_helper_equals(messageType, 0x03)) {
- plc4c_s7_read_write_s7_payload_write_var_response_parse(buf, messageType, parameter, NULL/* Disabled for now */);
+ if((parameter.getParameterType() == 0x05) && (messageType == 0x03)) {
+ plc4c_s7_read_write_s7_payload_write_var_response_parse(buf, messageType, parameter, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(parameter.getDiscriminatorValues()[0], 0x00) && plc4c_spi_evaluation_helper_equals(messageType, 0x07)) {
- plc4c_s7_read_write_s7_payload_user_data_parse(buf, messageType, parameter, NULL/* Disabled for now */);
+ if((parameter.getParameterType() == 0x00) && (messageType == 0x07)) {
+ plc4c_s7_read_write_s7_payload_user_data_parse(buf, messageType, parameter, &msg);
}
return OK;
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_payload_read_var_response.c b/sandbox/plc4c/generated-sources/s7/src/s7_payload_read_var_response.c
index 22ba8f8..107f52d 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_payload_read_var_response.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_payload_read_var_response.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_payload_read_var_response.h"
-plc4c_return_code plc4c_s7_read_write_s7_payload_read_var_response_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter parameter, plc4c_s7_read_write_s7_payload_read_var_response** message) {
+// Parse function.
+plc4c_return_code plc4c_s7_read_write_s7_payload_read_var_response_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter* parameter, plc4c_s7_read_write_s7_payload_read_var_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_s7_payload_read_var_response* msg = malloc(sizeof(plc4c_s7_read_write_s7_payload_read_var_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data.c b/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data.c
index 18379a9..df926f2 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_payload_user_data.h"
-plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter parameter, plc4c_s7_read_write_s7_payload_user_data** message) {
+// Parse function.
+plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter* parameter, plc4c_s7_read_write_s7_payload_user_data** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_s7_payload_user_data* msg = malloc(sizeof(plc4c_s7_read_write_s7_payload_user_data));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
return OK;
}
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 ddad501..1402c57 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
@@ -23,14 +23,32 @@
#include <plc4c/spi/evaluation_helper.h>
#include "s7_payload_user_data_item_cpu_function_read_szl_request.h"
#include "s7_payload_user_data_item_cpu_function_read_szl_response.h"
-
#include "s7_payload_user_data_item.h"
+// Array of discriminator values that match the enum type constants.
+// (The order is identical to the enum constants so we can use the
+// enum constant to directly access a given types discriminator values)
+const plc4c_s7_read_write_s7_payload_user_data_item_discriminator plc4c_s7_read_write_s7_payload_user_data_item_discriminators[] = {
+ {/* s7_read_write_s7_payload_user_data_item_cpu_function_read_szl_request */
+ .cpuFunctionType = 0x04},
+ {/* s7_read_write_s7_payload_user_data_item_cpu_function_read_szl_response */
+ .cpuFunctionType = 0x08}
+};
+
+// Function returning the discriminator values for a given type constant.
+plc4c_s7_read_write_s7_payload_user_data_item_discriminator plc4c_s7_read_write_s7_payload_user_data_item_get_discriminator(plc4c_s7_read_write_s7_payload_user_data_item_type type) {
+ return plc4c_s7_read_write_s7_payload_user_data_item_discriminators[type];
+}
+
+// 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);
uint16_t curPos;
- plc4c_s7_read_write_s7_payload_user_data_item* msg = malloc(sizeof(plc4c_s7_read_write_s7_payload_user_data_item));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Enum field (returnCode)
plc4c_s7_read_write_data_transport_error_code returnCode = plc4c_spi_read_byte(buf, 8);
@@ -44,18 +62,16 @@ plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_item_parse(plc4c_spi_
// Simple Field (szlId)
plc4c_s7_read_write_szl_id* szlId = NULL;
plc4c_s7_read_write_szl_id_parse(buf, &szlId);
- msg->szl_id = szlId;
// Simple Field (szlIndex)
uint16_t szlIndex = plc4c_spi_read_unsigned_int(buf, 16);
- msg->szl_index = szlIndex;
// Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
- if(plc4c_spi_evaluation_helper_equals(cpuFunctionType, 0x04)) {
- plc4c_s7_read_write_s7_payload_user_data_item_cpu_function_read_szl_request_parse(buf, cpuFunctionType, NULL/* Disabled for now */);
+ if(cpuFunctionType == 0x04) {
+ plc4c_s7_read_write_s7_payload_user_data_item_cpu_function_read_szl_request_parse(buf, cpuFunctionType, &msg);
} else
- if(plc4c_spi_evaluation_helper_equals(cpuFunctionType, 0x08)) {
- plc4c_s7_read_write_s7_payload_user_data_item_cpu_function_read_szl_response_parse(buf, cpuFunctionType, NULL/* Disabled for now */);
+ if(cpuFunctionType == 0x08) {
+ plc4c_s7_read_write_s7_payload_user_data_item_cpu_function_read_szl_response_parse(buf, cpuFunctionType, &msg);
}
return OK;
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data_item_cpu_function_read_szl_request.c b/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data_item_cpu_function_read_szl_request.c
index f54b29c..1a41a2e 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data_item_cpu_function_read_szl_request.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data_item_cpu_function_read_szl_request.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_payload_user_data_item_cpu_function_read_szl_request.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_item_cpu_function_read_szl_request_parse(plc4c_spi_read_buffer* buf, unsigned int cpuFunctionType, plc4c_s7_read_write_s7_payload_user_data_item_cpu_function_read_szl_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_s7_payload_user_data_item_cpu_function_read_szl_request* msg = malloc(sizeof(plc4c_s7_read_write_s7_payload_user_data_item_cpu_function_read_szl_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data_item_cpu_function_read_szl_response.c b/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data_item_cpu_function_read_szl_response.c
index 89842cb..28d1997 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data_item_cpu_function_read_szl_response.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data_item_cpu_function_read_szl_response.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_payload_user_data_item_cpu_function_read_szl_response.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_item_cpu_function_read_szl_response_parse(plc4c_spi_read_buffer* buf, unsigned int cpuFunctionType, plc4c_s7_read_write_s7_payload_user_data_item_cpu_function_read_szl_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_s7_payload_user_data_item_cpu_function_read_szl_response* msg = malloc(sizeof(plc4c_s7_read_write_s7_payload_user_data_item_cpu_function_read_szl_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Const Field (szlItemLength)
uint16_t szlItemLength = plc4c_spi_read_unsigned_int(buf, 16);
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_payload_write_var_request.c b/sandbox/plc4c/generated-sources/s7/src/s7_payload_write_var_request.c
index eadcbc2..d1a25c6 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_payload_write_var_request.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_payload_write_var_request.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_payload_write_var_request.h"
-plc4c_return_code plc4c_s7_read_write_s7_payload_write_var_request_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter parameter, plc4c_s7_read_write_s7_payload_write_var_request** message) {
+// Parse function.
+plc4c_return_code plc4c_s7_read_write_s7_payload_write_var_request_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter* parameter, plc4c_s7_read_write_s7_payload_write_var_request** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_s7_payload_write_var_request* msg = malloc(sizeof(plc4c_s7_read_write_s7_payload_write_var_request));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_payload_write_var_response.c b/sandbox/plc4c/generated-sources/s7/src/s7_payload_write_var_response.c
index 737bceb..91208d0 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_payload_write_var_response.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_payload_write_var_response.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_payload_write_var_response.h"
-plc4c_return_code plc4c_s7_read_write_s7_payload_write_var_response_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter parameter, plc4c_s7_read_write_s7_payload_write_var_response** message) {
+// Parse function.
+plc4c_return_code plc4c_s7_read_write_s7_payload_write_var_response_parse(plc4c_spi_read_buffer* buf, uint8_t messageType, plc4c_s7_read_write_s7_parameter* parameter, plc4c_s7_read_write_s7_payload_write_var_response** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_s7_payload_write_var_response* msg = malloc(sizeof(plc4c_s7_read_write_s7_payload_write_var_response));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
return OK;
}
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 83357cb..c2b0594 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
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_var_payload_data_item.h"
+// 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);
uint16_t curPos;
- plc4c_s7_read_write_s7_var_payload_data_item* msg = malloc(sizeof(plc4c_s7_read_write_s7_var_payload_data_item));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Enum field (returnCode)
plc4c_s7_read_write_data_transport_error_code returnCode = plc4c_spi_read_byte(buf, 8);
@@ -38,7 +41,6 @@ plc4c_return_code plc4c_s7_read_write_s7_var_payload_data_item_parse(plc4c_spi_r
// Simple Field (dataLength)
uint16_t dataLength = plc4c_spi_read_unsigned_int(buf, 16);
- msg->data_length = dataLength;
// Padding Field (pad)
bool _padNeedsPadding = (bool) ((plc4c_spi_read_has_more(buf, 8)) && ((!(lastItem)) && (((((COUNT(data)) % (2))) == (1)))));
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 ee64e7f..9fe8311 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
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_var_payload_status_item.h"
+// 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);
uint16_t curPos;
- plc4c_s7_read_write_s7_var_payload_status_item* msg = malloc(sizeof(plc4c_s7_read_write_s7_var_payload_status_item));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Enum field (returnCode)
plc4c_s7_read_write_data_transport_error_code returnCode = plc4c_spi_read_byte(buf, 8);
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 36a3449..414e105 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
@@ -22,21 +22,37 @@
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
#include "s7_var_request_parameter_item_address.h"
-
#include "s7_var_request_parameter_item.h"
+// Array of discriminator values that match the enum type constants.
+// (The order is identical to the enum constants so we can use the
+// enum constant to directly access a given types discriminator values)
+const plc4c_s7_read_write_s7_var_request_parameter_item_discriminator plc4c_s7_read_write_s7_var_request_parameter_item_discriminators[] = {
+ {/* s7_read_write_s7_var_request_parameter_item_address */
+ .itemType = 0x12}
+};
+
+// Function returning the discriminator values for a given type constant.
+plc4c_s7_read_write_s7_var_request_parameter_item_discriminator plc4c_s7_read_write_s7_var_request_parameter_item_get_discriminator(plc4c_s7_read_write_s7_var_request_parameter_item_type type) {
+ return plc4c_s7_read_write_s7_var_request_parameter_item_discriminators[type];
+}
+
+// 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);
uint16_t curPos;
- plc4c_s7_read_write_s7_var_request_parameter_item* msg = malloc(sizeof(plc4c_s7_read_write_s7_var_request_parameter_item));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Discriminator Field (itemType) (Used as input to a switch field)
uint8_t itemType = plc4c_spi_read_unsigned_short(buf, 8);
// Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
- if(plc4c_spi_evaluation_helper_equals(itemType, 0x12)) {
- plc4c_s7_read_write_s7_var_request_parameter_item_address_parse(buf, NULL/* Disabled for now */);
+ if(itemType == 0x12) {
+ plc4c_s7_read_write_s7_var_request_parameter_item_address_parse(buf, &msg);
}
return OK;
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_var_request_parameter_item_address.c b/sandbox/plc4c/generated-sources/s7/src/s7_var_request_parameter_item_address.c
index b84587b..abb8674 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_var_request_parameter_item_address.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_var_request_parameter_item_address.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "s7_var_request_parameter_item_address.h"
+// Parse function.
plc4c_return_code plc4c_s7_read_write_s7_var_request_parameter_item_address_parse(plc4c_spi_read_buffer* buf, plc4c_s7_read_write_s7_var_request_parameter_item_address** message) {
uint16_t startPos = plc4c_spi_read_get_pos(buf);
uint16_t curPos;
- plc4c_s7_read_write_s7_var_request_parameter_item_address* msg = malloc(sizeof(plc4c_s7_read_write_s7_var_request_parameter_item_address));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// 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 = plc4c_spi_read_unsigned_short(buf, 8);
@@ -36,7 +39,6 @@ plc4c_return_code plc4c_s7_read_write_s7_var_request_parameter_item_address_pars
// Simple Field (address)
plc4c_s7_read_write_s7_address* address = NULL;
plc4c_s7_read_write_s7_address_parse(buf, &address);
- msg->address = address;
return OK;
}
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 37b373b..fb0790d 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
@@ -21,30 +21,29 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "szl_data_tree_item.h"
+// 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);
uint16_t curPos;
- plc4c_s7_read_write_szl_data_tree_item* msg = malloc(sizeof(plc4c_s7_read_write_szl_data_tree_item));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Simple Field (itemIndex)
uint16_t itemIndex = plc4c_spi_read_unsigned_int(buf, 16);
- msg->item_index = itemIndex;
// Simple Field (moduleTypeId)
uint16_t moduleTypeId = plc4c_spi_read_unsigned_int(buf, 16);
- msg->module_type_id = moduleTypeId;
// Simple Field (ausbg)
uint16_t ausbg = plc4c_spi_read_unsigned_int(buf, 16);
- msg->ausbg = ausbg;
// Simple Field (ausbe)
uint16_t ausbe = plc4c_spi_read_unsigned_int(buf, 16);
- msg->ausbe = ausbe;
return OK;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/szl_id.c b/sandbox/plc4c/generated-sources/s7/src/szl_id.c
index a327a8f..6093721 100644
--- a/sandbox/plc4c/generated-sources/s7/src/szl_id.c
+++ b/sandbox/plc4c/generated-sources/s7/src/szl_id.c
@@ -21,21 +21,23 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "szl_id.h"
+// 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);
uint16_t curPos;
- plc4c_s7_read_write_szl_id* msg = malloc(sizeof(plc4c_s7_read_write_szl_id));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Enum field (typeClass)
plc4c_s7_read_write_szl_module_type_class typeClass = plc4c_spi_read_byte(buf, 4);
// Simple Field (sublistExtract)
unsigned int sublistExtract = plc4c_spi_read_unsigned_byte(buf, 4);
- msg->sublist_extract = sublistExtract;
// Enum field (sublistList)
plc4c_s7_read_write_szl_sublist sublistList = plc4c_spi_read_byte(buf, 8);
diff --git a/sandbox/plc4c/generated-sources/s7/src/tpkt_packet.c b/sandbox/plc4c/generated-sources/s7/src/tpkt_packet.c
index 24f2f82..703ac7f 100644
--- a/sandbox/plc4c/generated-sources/s7/src/tpkt_packet.c
+++ b/sandbox/plc4c/generated-sources/s7/src/tpkt_packet.c
@@ -21,14 +21,17 @@
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/spi/evaluation_helper.h>
-
#include "tpkt_packet.h"
+// 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);
uint16_t curPos;
- plc4c_s7_read_write_tpkt_packet* msg = malloc(sizeof(plc4c_s7_read_write_tpkt_packet));
+ // Pointer to the parsed datastructure.
+ void* msg = NULL;
+ // Factory function that allows filling the properties of this type
+ void (*factory_ptr)()
// Const Field (protocolId)
uint8_t protocolId = plc4c_spi_read_unsigned_short(buf, 8);
@@ -51,7 +54,6 @@ plc4c_return_code plc4c_s7_read_write_tpkt_packet_parse(plc4c_spi_read_buffer* b
// Simple Field (payload)
plc4c_s7_read_write_cotp_packet* payload = NULL;
plc4c_s7_read_write_cotp_packet_parse(buf, (len) - (4), &payload);
- msg->payload = payload;
return OK;
}