Skip to content

Commit

Permalink
refactor: Moved the examples, integrations and other extra stuff into…
Browse files Browse the repository at this point in the history
… the new plc4x-extras repository (#1483)

* refactor: Moved the examples, integrations and other extra stuff into the new plc4x-extras repository

* refactor: Cleaned up some of the managed dependencies.

* refactor: Updated some of the go-tools used in the build

* fix: Fixed the issues causing problems building PLC4C

* fix: A compilation error.

* fix: Fixed an error in the code-generation for C which only appeared in the code-gen testsuite.

* fix: Fixed an error in the code-generation for C which only appeared in the code-gen testsuite.

* fix: Disabling "CodeQL analysis" step as it's failing and I can't see from the output why.
  • Loading branch information
chrisdutz authored Apr 5, 2024
1 parent 27700c2 commit 4ff3d20
Show file tree
Hide file tree
Showing 539 changed files with 5,019 additions and 33,485 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/java-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,5 @@ jobs:
**/surefire-reports/TEST-*.xml
**/failsafe-reports/TEST-*.xml
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
# - name: Perform CodeQL Analysis
# uses: github/codeql-action/analyze@v3
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ public String getWriteBufferWriteMethodCall(SimpleTypeReference simpleTypeRefere
String encoding = ((StringLiteral) encodingTerm).getValue();
String length = Integer.toString(simpleTypeReference.getSizeInBits());
return "plc4c_spi_write_string(writeBuffer, " + length + ", \"" +
encoding + "\", " + fieldName + ")";
encoding + "\", (char*) " + fieldName + ")";
}
case VSTRING: {
final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,20 @@ plc4c_return_code ${helper.getCTypeName(type.name)}_parse(plc4x_spi_context ctx,
plc4c_utils_list_create(&${arrayField.name});
int itemCount = (int) ${helper.toParseExpression(type, arrayField, arrayField.loopExpression, parserArguments)};
for(int curItem = 0; curItem < itemCount; curItem++) {
<#-- Commenting out this code as we really need to figgure out how to handle strings -->
<#if helper.getLanguageTypeNameForTypeReference(elementTypeReference) == "char*">
/*
</#if>
${helper.getLanguageTypeNameForTypeReference(elementTypeReference)}* _val = malloc(sizeof(${helper.getLanguageTypeNameForTypeReference(elementTypeReference)}) * 1);
_res = <#if elementTypeReference.isSimpleTypeReference()>${helper.getReadBufferReadMethodCall(elementTypeReference.asSimpleTypeReference().orElseThrow(), "_val", arrayField)}<#else>${elementTypeReference.asNonSimpleTypeReference().orElseThrow().name}IO.staticParse(readBuffer<#if arrayField.params.isPresent()>, <#list arrayField.params.orElseThrow() as parserArgument>(${helper.getLanguageTypeNameForTypeReference(helper.getArgumentType(elementTypeReference, parserArgument?index))}) (${helper.toParseExpression(type, arrayField, parserArgument, parserArguments)})<#sep>, </#sep></#list></#if>)</#if>;
if(_res != OK) {
return _res;
}
plc4c_data* _item = plc4c_data_create_${helper.getDataIoTypeNameForTypeReference(elementTypeReference)}_data(*_val);
plc4c_utils_list_insert_head_value(${arrayField.name}, _item);
<#if helper.getLanguageTypeNameForTypeReference(elementTypeReference) == "char*">
*/
</#if>
}
<#-- In all other cases do we have to work with a list, that is later converted to an array -->
<#else>
Expand Down Expand Up @@ -229,6 +236,10 @@ plc4c_return_code ${helper.getCTypeName(type.name)}_parse(plc4x_spi_context ctx,
<#else>
*data_item = plc4c_data_create_string_data(${simpleField.type.asStringTypeReference().orElseThrow().sizeInBits}, ${simpleField.name});
</#if>
<#elseif case.name == "CHAR">
*data_item = plc4c_data_create_${case.name?lower_case}_data(*${simpleField.name});
<#elseif case.name == "WCHAR">
*data_item = plc4c_data_create_${case.name?lower_case}_data(*${simpleField.name});
<#else>
*data_item = plc4c_data_create_${case.name?lower_case}_data(${simpleField.name});
</#if>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
int8_t plc4c_test_read_write_crc_int8();
uint8_t plc4c_test_read_write_crc_uint8();
uint8_t plc4c_test_read_write_read_manual_field(plc4c_spi_read_buffer* readBuffer, uint8_t value);
plc4c_return_code plc4c_test_read_write_write_manual_field(plc4c_spi_write_buffer* writeBuffer, void* value);
plc4c_return_code plc4c_test_read_write_write_manual_field(plc4c_spi_write_buffer* writeBuffer, uint8_t value);

#ifdef __cplusplus
}
Expand Down
2 changes: 0 additions & 2 deletions plc4c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,3 @@ add_subdirectory(spi)
add_subdirectory(transports)
add_subdirectory(drivers)
add_subdirectory(tools)
#add_subdirectory(integrations)
add_subdirectory(examples)
21 changes: 11 additions & 10 deletions plc4c/drivers/simulated/src/driver_simulated.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ plc4c_return_code plc4c_driver_simulated_write_machine_function(
return OK;
}

plc4c_item *plc4c_driver_simulated_parse_address(char *address_string) {
plc4c_return_code plc4c_driver_simulated_encode_address(char *address_string, void** item) {
plc4c_driver_simulated_tag_type type = RANDOM;
char *name = NULL;
plc4c_data_type data_type = -1;
Expand All @@ -252,7 +252,7 @@ plc4c_item *plc4c_driver_simulated_parse_address(char *address_string) {
type = STDOUT;
} else {
free(type_str);
return NULL;
return INVALID_ADDRESS;
}
free(type_str);
start_segment = address_string + i + 1;
Expand Down Expand Up @@ -280,7 +280,7 @@ plc4c_item *plc4c_driver_simulated_parse_address(char *address_string) {
} else {
free(datatype_name);
free(name);
return NULL;
return INVALID_ADDRESS;
}
free(datatype_name);

Expand All @@ -304,14 +304,15 @@ plc4c_item *plc4c_driver_simulated_parse_address(char *address_string) {
}

// Create a new driver specific item.
plc4c_driver_simulated_item *item = (plc4c_driver_simulated_item *)malloc(
plc4c_driver_simulated_item *curItem = (plc4c_driver_simulated_item *)malloc(
sizeof(plc4c_driver_simulated_item));
item->type = type;
item->name = name;
item->data_type = data_type;
item->num_elements = num_elements;
curItem->type = type;
curItem->name = name;
curItem->data_type = data_type;
curItem->num_elements = num_elements;

return (plc4c_item *)item;
*item = curItem;
return OK;
}

plc4c_return_code plc4c_driver_simulated_connect_function(
Expand Down Expand Up @@ -412,7 +413,7 @@ plc4c_driver *plc4c_driver_simulated_create() {
driver->protocol_code = "simulated";
driver->protocol_name = "Simulated PLC4X Datasource";
driver->default_transport_code = "dummy";
driver->parse_address_function = &plc4c_driver_simulated_parse_address;
driver->parse_address_function = &plc4c_driver_simulated_encode_address;
driver->connect_function = &plc4c_driver_simulated_connect_function;
driver->disconnect_function = &plc4c_driver_simulated_disconnect_function;
driver->read_function = &plc4c_driver_simulated_read_function;
Expand Down
22 changes: 0 additions & 22 deletions plc4c/examples/CMakeLists.txt

This file was deleted.

41 changes: 0 additions & 41 deletions plc4c/examples/hello-subscriptions/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit 4ff3d20

Please sign in to comment.