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/05/07 13:50:36 UTC
[plc4x] branch feature/c-api updated: - Reformatted the code
according to the google c style
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch feature/c-api
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/feature/c-api by this push:
new ed057e6 - Reformatted the code according to the google c style
ed057e6 is described below
commit ed057e6efc769a1946a8194a394ed083c5e6ea78
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Thu May 7 15:50:26 2020 +0200
- Reformatted the code according to the google c style
---
sandbox/plc4c/api/include/plc4c/data.h | 23 +-
sandbox/plc4c/api/include/plc4c/plc4c.h | 11 +-
sandbox/plc4c/api/include/plc4c/system.h | 3 +-
sandbox/plc4c/api/include/plc4c/types.h | 86 ++--
sandbox/plc4c/api/include/plc4c/utils/queue.h | 10 +-
.../drivers/modbus/include/plc4c/driver_modbus.h | 2 +-
sandbox/plc4c/drivers/modbus/src/driver_modbus.c | 29 +-
sandbox/plc4c/drivers/s7/include/plc4c/driver_s7.h | 2 +-
sandbox/plc4c/drivers/s7/src/driver_s7.c | 29 +-
.../simulated/include/plc4c/driver_simulated.h | 2 +-
.../plc4c/examples/hello-world/src/hello_world.c | 542 +++++++++++----------
.../plc4c/spi/include/plc4c/spi/system_private.h | 4 +-
sandbox/plc4c/spi/src/data.c | 230 ++++-----
sandbox/plc4c/spi/src/types.c | 223 +++++----
sandbox/plc4c/spi/src/utils/list.c | 225 ++++-----
sandbox/plc4c/spi/src/utils/queue.c | 64 ++-
sandbox/plc4c/spi/test/system_test.c | 108 ++--
.../dummy/include/plc4c/transport_dummy.h | 2 +-
.../plc4c/transports/dummy/src/transport_dummy.c | 10 +-
.../serial/include/plc4c/transport_serial.h | 2 +-
.../plc4c/transports/serial/src/transport_serial.c | 10 +-
.../transports/tcp/include/plc4c/transport_tcp.h | 2 +-
sandbox/plc4c/transports/tcp/src/transport_tcp.c | 10 +-
23 files changed, 829 insertions(+), 800 deletions(-)
diff --git a/sandbox/plc4c/api/include/plc4c/data.h b/sandbox/plc4c/api/include/plc4c/data.h
index 020ebfc..8b408d4 100644
--- a/sandbox/plc4c/api/include/plc4c/data.h
+++ b/sandbox/plc4c/api/include/plc4c/data.h
@@ -24,8 +24,8 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
-#include "plc4c/types.h"
+#include "plc4c/types.h"
typedef void (*plc4c_data_custom_destroy)(plc4c_data *data);
@@ -115,31 +115,34 @@ plc4c_data *plc4c_data_create_string_data(unsigned int size, char *s);
plc4c_data *plc4c_data_create_constant_string_data(unsigned int size, char *s);
/**
- * Set a custom function to call when destroying this data. Typically when the type is
- * a PLC4C_VOID_POINTER
+ * Set a custom function to call when destroying this data. Typically when the
+ * type is a PLC4C_VOID_POINTER
* @param data pointer to plc4c_data
* @param data_custom_destroy the function to call
*/
-void plc4c_data_set_custom_destroy(plc4c_data *data, plc4c_data_custom_destroy data_custom_destroy);
+void plc4c_data_set_custom_destroy(
+ plc4c_data *data, plc4c_data_custom_destroy data_custom_destroy);
/**
* Set a custom function to call when plc4c_data_printf is called.
* @param data pointer to plc4c_data
* @param data_custom_printf the function to call
*/
-void plc4c_data_set_custom_printf(plc4c_data *data, plc4c_data_custom_printf data_custom_printf);
+void plc4c_data_set_custom_printf(plc4c_data *data,
+ plc4c_data_custom_printf data_custom_printf);
/**
- * Print the value of the plc4c_data to std out as printf does, formatted by the type.
- * If plc4c_data_set_custom_printf has been called and set, then that function will print the value.
+ * Print the value of the plc4c_data to std out as printf does, formatted by the
+ * type. If plc4c_data_set_custom_printf has been called and set, then that
+ * function will print the value.
* @param data
*/
void plc4c_data_printf(plc4c_data *data);
/**
* Delete the plc4c_data correctly accounting for the type.
- * If plc4c_data_set_custom_destroy has been called and set, then that function will handle the destruction
- * of the data.
+ * If plc4c_data_set_custom_destroy has been called and set, then that function
+ * will handle the destruction of the data.
* @param data pointer to plc4c_data
*/
void plc4c_data_delete(plc4c_data *data);
@@ -148,4 +151,4 @@ void plc4c_data_delete(plc4c_data *data);
}
#endif
-#endif //PLC4C_API_INCLUDE_PLC4C_DATA_H_
+#endif // PLC4C_API_INCLUDE_PLC4C_DATA_H_
diff --git a/sandbox/plc4c/api/include/plc4c/plc4c.h b/sandbox/plc4c/api/include/plc4c/plc4c.h
index 4ed2fbc..b84a10b 100644
--- a/sandbox/plc4c/api/include/plc4c/plc4c.h
+++ b/sandbox/plc4c/api/include/plc4c/plc4c.h
@@ -22,16 +22,17 @@
extern "C" {
#endif
-/* Convenience header file that just imports all the different parts of the API */
+/* Convenience header file that just imports all the different parts of the API
+ */
-#include "plc4c/types.h"
-#include "plc4c/system.h"
#include "plc4c/connection.h"
+#include "plc4c/data.h"
#include "plc4c/read.h"
+#include "plc4c/system.h"
+#include "plc4c/types.h"
#include "plc4c/write.h"
-#include "plc4c/data.h"
#ifdef __cplusplus
}
#endif
-#endif //PLC4C_H_
\ No newline at end of file
+#endif // PLC4C_H_
\ No newline at end of file
diff --git a/sandbox/plc4c/api/include/plc4c/system.h b/sandbox/plc4c/api/include/plc4c/system.h
index 9c12b05..79a501e 100644
--- a/sandbox/plc4c/api/include/plc4c/system.h
+++ b/sandbox/plc4c/api/include/plc4c/system.h
@@ -140,7 +140,8 @@ plc4c_list *plc4c_system_get_task_list(plc4c_system *system);
*/
void plc4c_system_set_task_list(plc4c_system *system, plc4c_list *task_list);
-void plc4c_system_remove_connection(plc4c_system *system, plc4c_connection *connection);
+void plc4c_system_remove_connection(plc4c_system *system,
+ plc4c_connection *connection);
/**
* Function to set the on_driver_loaded callback for the plc4c system.
diff --git a/sandbox/plc4c/api/include/plc4c/types.h b/sandbox/plc4c/api/include/plc4c/types.h
index bc674db..5040616 100644
--- a/sandbox/plc4c/api/include/plc4c/types.h
+++ b/sandbox/plc4c/api/include/plc4c/types.h
@@ -27,57 +27,58 @@ extern "C" {
/**
* PLC4C error codes
-*/
+ */
typedef enum plc4c_return_code {
- UNFINISHED,
- OK,
- NO_MEMORY,
- INVALID_CONNECTION_STRING,
- NON_MATCHING_LISTS,
- INVALID_LIST_SIZE,
- NOT_REACHABLE,
- PERMISSION_DENIED,
-
- NO_DRIVER_AVAILABLE,
- UNKNOWN_DRIVER,
-
- UNSPECIFIED_TRANSPORT,
- NO_TRANSPORT_AVAILABLE,
- UNKNOWN_TRANSPORT,
-
- UNKNOWN_ERROR,
- INTERNAL_ERROR
+ UNFINISHED,
+ OK,
+ NO_MEMORY,
+ INVALID_CONNECTION_STRING,
+ NON_MATCHING_LISTS,
+ INVALID_LIST_SIZE,
+ NOT_REACHABLE,
+ PERMISSION_DENIED,
+
+ NO_DRIVER_AVAILABLE,
+ UNKNOWN_DRIVER,
+
+ UNSPECIFIED_TRANSPORT,
+ NO_TRANSPORT_AVAILABLE,
+ UNKNOWN_TRANSPORT,
+
+ UNKNOWN_ERROR,
+ INTERNAL_ERROR
} plc4c_return_code;
typedef enum plc4c_response_code {
- PLC4C_RESPONSE_CODE_OK,
- PLC4C_RESPONSE_CODE_NOT_FOUND,
- PLC4C_RESPONSE_CODE_ACCESS_DENIED,
- PLC4C_RESPONSE_CODE_INVALID_ADDRESS,
- PLC4C_RESPONSE_CODE_INVALID_DATATYPE,
- PLC4C_RESPONSE_CODE_INTERNAL_ERROR,
- PLC4C_RESPONSE_CODE_RESPONSE_PENDING
+ PLC4C_RESPONSE_CODE_OK,
+ PLC4C_RESPONSE_CODE_NOT_FOUND,
+ PLC4C_RESPONSE_CODE_ACCESS_DENIED,
+ PLC4C_RESPONSE_CODE_INVALID_ADDRESS,
+ PLC4C_RESPONSE_CODE_INVALID_DATATYPE,
+ PLC4C_RESPONSE_CODE_INTERNAL_ERROR,
+ PLC4C_RESPONSE_CODE_RESPONSE_PENDING
} plc4c_response_code;
/**
* PLC4C data types
*/
typedef enum plc4c_data_type {
- PLC4C_BOOL,
- PLC4C_CHAR,
- PLC4C_UCHAR,
- PLC4C_SHORT,
- PLC4C_USHORT,
- PLC4C_INT,
- PLC4C_UINT,
- PLC4C_FLOAT,
- PLC4C_STRING_POINTER,
- PLC4C_CONSTANT_STRING,
- PLC4C_VOID_POINTER
+ PLC4C_BOOL,
+ PLC4C_CHAR,
+ PLC4C_UCHAR,
+ PLC4C_SHORT,
+ PLC4C_USHORT,
+ PLC4C_INT,
+ PLC4C_UINT,
+ PLC4C_FLOAT,
+ PLC4C_STRING_POINTER,
+ PLC4C_CONSTANT_STRING,
+ PLC4C_VOID_POINTER
} plc4c_data_type;
/**
- * Helper that translates from a return_code enum value to something a human can work with.
+ * Helper that translates from a return_code enum value to something a human can
+ * work with.
*
* @param err return code.
* @return A human readable description.
@@ -85,7 +86,8 @@ typedef enum plc4c_data_type {
char *plc4c_return_code_to_message(plc4c_return_code err);
/**
- * Helper that translates from a plc4c_response_code enum value to something a human can work with.
+ * Helper that translates from a plc4c_response_code enum value to something a
+ * human can work with.
*
* @param response_code plc4c_response_code.
* @return A human readable description.
@@ -93,7 +95,8 @@ char *plc4c_return_code_to_message(plc4c_return_code err);
char *plc4c_response_code_to_message(plc4c_response_code response_code);
/**
- * Helper function translates from a plc4c_data_type enum value to something a human can work with.
+ * Helper function translates from a plc4c_data_type enum value to something a
+ * human can work with.
* @param data_type plc4c_data_type
* @return string representation
*/
@@ -149,10 +152,9 @@ typedef struct plc4c_write_request_execution_t plc4c_write_request_execution;
*/
typedef struct plc4c_write_response_t plc4c_write_response;
-
typedef struct plc4c_data_t plc4c_data;
#ifdef __cplusplus
}
#endif
-#endif //PLC4C_TYPES_H_
\ No newline at end of file
+#endif // PLC4C_TYPES_H_
\ No newline at end of file
diff --git a/sandbox/plc4c/api/include/plc4c/utils/queue.h b/sandbox/plc4c/api/include/plc4c/utils/queue.h
index db8533c..cc1bc89 100644
--- a/sandbox/plc4c/api/include/plc4c/utils/queue.h
+++ b/sandbox/plc4c/api/include/plc4c/utils/queue.h
@@ -29,13 +29,13 @@ typedef struct plc4c_queue plc4c_queue;
typedef struct plc4c_queue_element plc4c_queue_element;
struct plc4c_queue {
- plc4c_queue_element *head;
- plc4c_queue_element *tail;
+ plc4c_queue_element *head;
+ plc4c_queue_element *tail;
};
struct plc4c_queue_element {
- plc4c_queue_element *next;
- void *value;
+ plc4c_queue_element *next;
+ void *value;
};
void plc4c_utils_queue_create(plc4c_queue **queue);
@@ -57,4 +57,4 @@ plc4c_queue_element *plc4c_utils_queue_tail(plc4c_queue *queue);
#ifdef __cplusplus
}
#endif
-#endif //PLC4C_UTILS_QUEUE_H_
+#endif // PLC4C_UTILS_QUEUE_H_
diff --git a/sandbox/plc4c/drivers/modbus/include/plc4c/driver_modbus.h b/sandbox/plc4c/drivers/modbus/include/plc4c/driver_modbus.h
index 2235dd5..5fa584c 100644
--- a/sandbox/plc4c/drivers/modbus/include/plc4c/driver_modbus.h
+++ b/sandbox/plc4c/drivers/modbus/include/plc4c/driver_modbus.h
@@ -29,4 +29,4 @@ plc4c_driver *plc4c_driver_modbus_create();
#ifdef __cplusplus
}
#endif
-#endif //PLC4C_DRIVER_S7_H_
\ No newline at end of file
+#endif // PLC4C_DRIVER_S7_H_
\ No newline at end of file
diff --git a/sandbox/plc4c/drivers/modbus/src/driver_modbus.c b/sandbox/plc4c/drivers/modbus/src/driver_modbus.c
index 9edaf20..a8e5388 100644
--- a/sandbox/plc4c/drivers/modbus/src/driver_modbus.c
+++ b/sandbox/plc4c/drivers/modbus/src/driver_modbus.c
@@ -17,22 +17,21 @@
under the License.
*/
-#include <stdlib.h>
-#include <plc4c/spi/types_private.h>
#include <plc4c/driver_modbus.h>
+#include <plc4c/spi/types_private.h>
+#include <stdlib.h>
plc4c_driver *plc4c_driver_modbus_create() {
- plc4c_driver *driver = (plc4c_driver *) malloc(sizeof(plc4c_driver));
- driver->protocol_code = "modbus";
- driver->protocol_name = "Modbus";
- driver->default_transport_code = "tcp";
- driver->parse_address_function = NULL;
- driver->connect_function = NULL;
- driver->disconnect_function = NULL;
- driver->read_function = NULL;
- driver->write_function = NULL;
- driver->free_read_response_function = NULL;
- driver->free_write_response_function = NULL;
- return driver;
+ plc4c_driver *driver = (plc4c_driver *)malloc(sizeof(plc4c_driver));
+ driver->protocol_code = "modbus";
+ driver->protocol_name = "Modbus";
+ driver->default_transport_code = "tcp";
+ driver->parse_address_function = NULL;
+ driver->connect_function = NULL;
+ driver->disconnect_function = NULL;
+ driver->read_function = NULL;
+ driver->write_function = NULL;
+ driver->free_read_response_function = NULL;
+ driver->free_write_response_function = NULL;
+ return driver;
}
-
diff --git a/sandbox/plc4c/drivers/s7/include/plc4c/driver_s7.h b/sandbox/plc4c/drivers/s7/include/plc4c/driver_s7.h
index 82cbff2..e4c32f3 100644
--- a/sandbox/plc4c/drivers/s7/include/plc4c/driver_s7.h
+++ b/sandbox/plc4c/drivers/s7/include/plc4c/driver_s7.h
@@ -29,4 +29,4 @@ plc4c_driver *plc4c_driver_s7_create();
#ifdef __cplusplus
}
#endif
-#endif //PLC4C_DRIVER_S7_H_
\ No newline at end of file
+#endif // PLC4C_DRIVER_S7_H_
\ No newline at end of file
diff --git a/sandbox/plc4c/drivers/s7/src/driver_s7.c b/sandbox/plc4c/drivers/s7/src/driver_s7.c
index 8119f14..9dacc9b 100644
--- a/sandbox/plc4c/drivers/s7/src/driver_s7.c
+++ b/sandbox/plc4c/drivers/s7/src/driver_s7.c
@@ -17,22 +17,21 @@
under the License.
*/
-#include <stdlib.h>
-#include <plc4c/spi/types_private.h>
#include <plc4c/driver_s7.h>
+#include <plc4c/spi/types_private.h>
+#include <stdlib.h>
plc4c_driver *plc4c_driver_s7_create() {
- plc4c_driver *driver = (plc4c_driver *) malloc(sizeof(plc4c_driver));
- driver->protocol_code = "s7";
- driver->protocol_name = "Siemens S7 (Basic)";
- driver->default_transport_code = "tcp";
- driver->parse_address_function = NULL;
- driver->connect_function = NULL;
- driver->disconnect_function = NULL;
- driver->read_function = NULL;
- driver->write_function = NULL;
- driver->free_read_response_function = NULL;
- driver->free_write_response_function = NULL;
- return driver;
+ plc4c_driver *driver = (plc4c_driver *)malloc(sizeof(plc4c_driver));
+ driver->protocol_code = "s7";
+ driver->protocol_name = "Siemens S7 (Basic)";
+ driver->default_transport_code = "tcp";
+ driver->parse_address_function = NULL;
+ driver->connect_function = NULL;
+ driver->disconnect_function = NULL;
+ driver->read_function = NULL;
+ driver->write_function = NULL;
+ driver->free_read_response_function = NULL;
+ driver->free_write_response_function = NULL;
+ return driver;
}
-
diff --git a/sandbox/plc4c/drivers/simulated/include/plc4c/driver_simulated.h b/sandbox/plc4c/drivers/simulated/include/plc4c/driver_simulated.h
index 7077551..cc77d59 100644
--- a/sandbox/plc4c/drivers/simulated/include/plc4c/driver_simulated.h
+++ b/sandbox/plc4c/drivers/simulated/include/plc4c/driver_simulated.h
@@ -29,4 +29,4 @@ plc4c_driver *plc4c_driver_simulated_create();
#ifdef __cplusplus
}
#endif
-#endif //PLC4C_DRIVER_S7_H_
\ No newline at end of file
+#endif // PLC4C_DRIVER_S7_H_
\ No newline at end of file
diff --git a/sandbox/plc4c/examples/hello-world/src/hello_world.c b/sandbox/plc4c/examples/hello-world/src/hello_world.c
index 8bc0233..68df39e 100644
--- a/sandbox/plc4c/examples/hello-world/src/hello_world.c
+++ b/sandbox/plc4c/examples/hello-world/src/hello_world.c
@@ -16,14 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-#include <stdio.h>
-#include <string.h>
-#include <plc4c/plc4c.h>
#include <plc4c/driver_simulated.h>
+#include <plc4c/plc4c.h>
#include <plc4c/transport_dummy.h>
#include <plc4c/utils/list.h>
-#include "../../../spi/include/plc4c/spi/types_private.h"
+#include <stdio.h>
+#include <string.h>
+#include "../../../spi/include/plc4c/spi/types_private.h"
int numOpenConnections = 0;
@@ -35,37 +35,38 @@ int numOpenConnections = 0;
* @param connection the connection that was just established
*/
void onGlobalConnect(plc4c_connection *cur_connection) {
- printf("Connected to %s", plc4c_connection_get_connection_string(cur_connection));
- numOpenConnections++;
+ printf("Connected to %s",
+ plc4c_connection_get_connection_string(cur_connection));
+ numOpenConnections++;
}
void onGlobalDisconnect(plc4c_connection *cur_connection) {
- printf("Disconnected from %s", plc4c_connection_get_connection_string(cur_connection));
- numOpenConnections--;
+ printf("Disconnected from %s",
+ plc4c_connection_get_connection_string(cur_connection));
+ numOpenConnections--;
}
void delete_address(plc4c_list_element *address_data_element) {
- // these are not malloc'd, no need to free
- address_data_element->value = NULL;
+ // these are not malloc'd, no need to free
+ address_data_element->value = NULL;
}
void delete_read_response_item(plc4c_list_element *response_read_item_element) {
}
-void delete_write_response_item(plc4c_list_element *response_write_item_element) {
-
-}
+void delete_write_response_item(
+ plc4c_list_element *response_write_item_element) {}
enum plc4c_connection_state_t {
- CONNECTING,
- CONNECTED,
- READ_REQUEST_SENT,
- READ_RESPONSE_RECEIVED,
- WRITE_REQUEST_SENT,
- WRITE_RESPONSE_RECEIVED,
- DISCONNECTING,
- DISCONNECTED
+ CONNECTING,
+ CONNECTED,
+ READ_REQUEST_SENT,
+ READ_RESPONSE_RECEIVED,
+ WRITE_REQUEST_SENT,
+ WRITE_RESPONSE_RECEIVED,
+ DISCONNECTING,
+ DISCONNECTED
};
typedef enum plc4c_connection_state_t plc4c_connection_state;
@@ -73,259 +74,274 @@ typedef enum plc4c_connection_state_t plc4c_connection_state;
#pragma ide diagnostic ignored "hicpp-multiway-paths-covered"
int main() {
- bool loop = true;
- plc4c_system *system = NULL;
- plc4c_connection *connection = NULL;
- plc4c_read_request *read_request = NULL;
- plc4c_write_request *write_request = NULL;
- plc4c_read_request_execution *read_request_execution = NULL;
- plc4c_write_request_execution *write_request_execution = NULL;
-
- // Create a new uninitialized plc4c_system
- printf("Creating new PLC4C System (Initializing inner data-structures) ... ");
- plc4c_return_code result = plc4c_system_create(&system);
- if (result != OK) {
- printf("FAILED\n");
- return -1;
- }
- printf("SUCCESS\n");
-
- // Manually register the "simulated" driver with the system.
- printf("Registering driver for the 'simulated' protocol ... ");
- plc4c_driver *simulated_driver = plc4c_driver_simulated_create();
- result = plc4c_system_add_driver(system, simulated_driver);
- if (result != OK) {
- printf("FAILED\n");
- return -1;
- }
- printf("SUCCESS\n");
-
- printf("Registering transport for the 'dummy' transport ... ");
- plc4c_transport *dummy_transport = plc4c_transport_dummy_create();
- result = plc4c_system_add_transport(system, dummy_transport);
- if (result != OK) {
- printf("FAILED\n");
- return -1;
- }
- printf("SUCCESS\n");
-
- // Initialize the plc4c_system (loading of drivers, setting up other stuff, ...)
- printf("Initializing the PLC4C system (Loading of drivers and transports) ... ");
- result = plc4c_system_init(system);
- if (result != OK) {
- printf("FAILED\n");
- return -1;
- }
- printf("SUCCESS\n");
-
- // Register the global callbacks.
- plc4c_system_set_on_connect_success_callback(system, &onGlobalConnect);
- plc4c_system_set_on_disconnect_success_callback(system, &onGlobalDisconnect);
-
- // Establish connections to remote devices
- // you may or may not care about the connection handle
- printf("Connecting to 'simulated://foo' ... ");
- result = plc4c_system_connect(system, "simulated://foo", &connection);
- if (result != OK) {
- printf("FAILED\n");
- return -1;
+ bool loop = true;
+ plc4c_system *system = NULL;
+ plc4c_connection *connection = NULL;
+ plc4c_read_request *read_request = NULL;
+ plc4c_write_request *write_request = NULL;
+ plc4c_read_request_execution *read_request_execution = NULL;
+ plc4c_write_request_execution *write_request_execution = NULL;
+
+ // Create a new uninitialized plc4c_system
+ printf("Creating new PLC4C System (Initializing inner data-structures) ... ");
+ plc4c_return_code result = plc4c_system_create(&system);
+ if (result != OK) {
+ printf("FAILED\n");
+ return -1;
+ }
+ printf("SUCCESS\n");
+
+ // Manually register the "simulated" driver with the system.
+ printf("Registering driver for the 'simulated' protocol ... ");
+ plc4c_driver *simulated_driver = plc4c_driver_simulated_create();
+ result = plc4c_system_add_driver(system, simulated_driver);
+ if (result != OK) {
+ printf("FAILED\n");
+ return -1;
+ }
+ printf("SUCCESS\n");
+
+ printf("Registering transport for the 'dummy' transport ... ");
+ plc4c_transport *dummy_transport = plc4c_transport_dummy_create();
+ result = plc4c_system_add_transport(system, dummy_transport);
+ if (result != OK) {
+ printf("FAILED\n");
+ return -1;
+ }
+ printf("SUCCESS\n");
+
+ // Initialize the plc4c_system (loading of drivers, setting up other stuff,
+ // ...)
+ printf(
+ "Initializing the PLC4C system (Loading of drivers and transports) ... ");
+ result = plc4c_system_init(system);
+ if (result != OK) {
+ printf("FAILED\n");
+ return -1;
+ }
+ printf("SUCCESS\n");
+
+ // Register the global callbacks.
+ plc4c_system_set_on_connect_success_callback(system, &onGlobalConnect);
+ plc4c_system_set_on_disconnect_success_callback(system, &onGlobalDisconnect);
+
+ // Establish connections to remote devices
+ // you may or may not care about the connection handle
+ printf("Connecting to 'simulated://foo' ... ");
+ result = plc4c_system_connect(system, "simulated://foo", &connection);
+ if (result != OK) {
+ printf("FAILED\n");
+ return -1;
+ }
+
+ // Central program loop ...
+ plc4c_connection_state state = CONNECTING;
+ while (loop) {
+ printf("* ");
+
+ // Give plc4c a chance to do something.
+ // This is where all I/O is being done.
+ if (plc4c_system_loop(system) != OK) {
+ printf("ERROR in the system loop\n");
+ break;
}
- // Central program loop ...
- plc4c_connection_state state = CONNECTING;
- while (loop) {
+ // Depending on the current state, implement some logic.
+ switch (state) {
+ case CONNECTING: {
+ // Check if the connection is established:
+ if (plc4c_connection_is_connected(connection)) {
+ printf("SUCCESS\n");
+ state = CONNECTED;
+ } else if (plc4c_connection_has_error(connection)) {
+ printf("FAILED\n");
+ return -1;
+ }
+ break;
+ }
+ case CONNECTED: {
+ // Create a new read-request.
+ printf("Preparing a read-request for 'RANDOM/foo:INTEGER' ... ");
+
+ plc4c_list *address_list = NULL;
+ plc4c_utils_list_create(&address_list);
+ plc4c_utils_list_insert_head_value(address_list,
+ (void *)"RANDOM/foo:INTEGER");
+ result = plc4c_connection_create_read_request(connection, address_list,
+ &read_request);
+ if (result != OK) {
+ printf("FAILED\n");
+ return -1;
+ }
+ printf("SUCCESS\n");
+
+ // Execute the read-request.
+ printf("Executing a read-request ... ");
+ result =
+ plc4c_read_request_execute(read_request, &read_request_execution);
+
+ // As we only used these to create the request, they can now be released
+ // again.
+ plc4c_utils_list_delete_elements(address_list, &delete_address);
+ free(address_list);
+
+ if (result != OK) {
+ printf("FAILED\n");
+ return -1;
+ } else {
+ state = READ_REQUEST_SENT;
+ }
+ break;
+ }
+ // Wait until the read-request execution is finished.
+ case READ_REQUEST_SENT: {
+ if (plc4c_read_request_finished_successfully(read_request_execution)) {
+ printf("SUCCESS\n");
+ state = READ_RESPONSE_RECEIVED;
+ } else if (plc4c_read_request_has_error(read_request_execution)) {
+ printf("FAILED\n");
+ return -1;
+ }
+ break;
+ }
+ case READ_RESPONSE_RECEIVED: {
+ // Get the response for the given read-request.
+ plc4c_read_response *read_response =
+ plc4c_read_request_get_response(read_request_execution);
+ if (read_response == NULL) {
+ printf("FAILED (No Response)\n");
+ return -1;
+ }
+
+ // Iterate over all returned items.
+ plc4c_list_element *cur_element =
+ plc4c_utils_list_head(read_response->items);
+ while (cur_element != NULL) {
+ plc4c_response_value_item *value_item = cur_element->value;
- printf("* ");
+ printf("Value %s (%s):", value_item->item->name,
+ plc4c_response_code_to_message(value_item->response_code));
+ plc4c_data_printf(value_item->value);
+ printf("\n");
- // Give plc4c a chance to do something.
- // This is where all I/O is being done.
- if (plc4c_system_loop(system) != OK) {
- printf("ERROR in the system loop\n");
- break;
+ cur_element = cur_element->next;
}
- // Depending on the current state, implement some logic.
- switch (state) {
- case CONNECTING: {
- // Check if the connection is established:
- if (plc4c_connection_is_connected(connection)) {
- printf("SUCCESS\n");
- state = CONNECTED;
- } else if (plc4c_connection_has_error(connection)) {
- printf("FAILED\n");
- return -1;
- }
- break;
- }
- case CONNECTED: {
- // Create a new read-request.
- printf("Preparing a read-request for 'RANDOM/foo:INTEGER' ... ");
-
- plc4c_list *address_list = NULL;
- plc4c_utils_list_create(&address_list);
- plc4c_utils_list_insert_head_value(address_list, (void *) "RANDOM/foo:INTEGER");
- result = plc4c_connection_create_read_request(connection, address_list, &read_request);
- if (result != OK) {
- printf("FAILED\n");
- return -1;
- }
- printf("SUCCESS\n");
-
- // Execute the read-request.
- printf("Executing a read-request ... ");
- result = plc4c_read_request_execute(read_request, &read_request_execution);
-
- // As we only used these to create the request, they can now be released again.
- plc4c_utils_list_delete_elements(address_list, &delete_address);
- free(address_list);
-
- if (result != OK) {
- printf("FAILED\n");
- return -1;
- } else {
- state = READ_REQUEST_SENT;
- }
- break;
- }
- // Wait until the read-request execution is finished.
- case READ_REQUEST_SENT: {
- if (plc4c_read_request_finished_successfully(read_request_execution)) {
- printf("SUCCESS\n");
- state = READ_RESPONSE_RECEIVED;
- } else if (plc4c_read_request_has_error(read_request_execution)) {
- printf("FAILED\n");
- return -1;
- }
- break;
- }
- case READ_RESPONSE_RECEIVED: {
- // Get the response for the given read-request.
- plc4c_read_response *read_response = plc4c_read_request_get_response(read_request_execution);
- if (read_response == NULL) {
- printf("FAILED (No Response)\n");
- return -1;
- }
-
- // Iterate over all returned items.
- plc4c_list_element *cur_element = plc4c_utils_list_head(read_response->items);
- while (cur_element != NULL) {
- plc4c_response_value_item *value_item = cur_element->value;
-
- printf("Value %s (%s):", value_item->item->name,
- plc4c_response_code_to_message(value_item->response_code));
- plc4c_data_printf(value_item->value);
- printf("\n");
-
- cur_element = cur_element->next;
- }
-
- // Clean up.
- plc4c_connection_read_response_destroy(read_response);
- plc4c_read_request_execution_destroy(read_request_execution);
- plc4c_read_request_destroy(read_request);
-
- // Create a new write-request.
- printf("Preparing a write-request for 'STDOUT/foo:INTEGER' ... ");
- plc4c_list *address_list = NULL;
- plc4c_utils_list_create(&address_list);
- plc4c_utils_list_insert_head_value(address_list, (void *) "STDOUT/foo:STRING");
- plc4c_list *value_list = NULL;
- plc4c_utils_list_create(&value_list);
- char value[] = "bar";
- plc4c_utils_list_insert_head_value(value_list,
- plc4c_data_create_constant_string_data(strlen(value), value));
- result = plc4c_connection_create_write_request(connection, address_list, value_list, &write_request);
-
- // As we only used these to create the request, they can now be released again.
- plc4c_utils_list_delete_elements(address_list, &delete_address);
- plc4c_utils_list_delete_elements(value_list, &delete_address);
- free(address_list);
- free(value_list);
-
- if (result != OK) {
- printf("FAILED\n");
- return -1;
- }
- printf("SUCCESS\n");
-
- // Execute the write-request.
- printf("Executing a write-request ... \n");
- result = plc4c_write_request_execute(write_request, &write_request_execution);
- if (result != OK) {
- printf("FAILED\n");
- return -1;
- } else {
- state = WRITE_REQUEST_SENT;
- }
- break;
- }
- // Wait until the write-request execution is finished.
- case WRITE_REQUEST_SENT: {
- if (plc4c_write_request_finished_successfully(write_request_execution)) {
- printf("SUCCESS\n");
- state = WRITE_RESPONSE_RECEIVED;
- } else if (plc4c_write_request_has_error(write_request_execution)) {
- printf("FAILED\n");
- return -1;
- }
- break;
- }
- case WRITE_RESPONSE_RECEIVED: {
- plc4c_write_response *write_response = plc4c_write_request_get_response(write_request_execution);
-
- // Iterate over the responses ...
- plc4c_list_element *cur_element = plc4c_utils_list_head(write_response->response_items);
- while (cur_element != NULL) {
- plc4c_response_item *response_item = cur_element->value;
- printf(" - Write Value %s (%s)\n", response_item->item->name,
- plc4c_response_code_to_message(response_item->response_code));
- cur_element = cur_element->next;
- }
-
- // Clean up.
- plc4c_connection_write_response_destroy(write_response);
- plc4c_write_request_execution_destroy(write_request_execution);
-
- // Disconnect.
- printf("Disconnecting ... ");
- result = plc4c_connection_disconnect(connection);
- if (result != OK) {
- printf("FAILED");
- return -1;
- }
- state = DISCONNECTING;
- break;
- }
- // Wait until the connection is disconnected
- case DISCONNECTING: {
- if (!plc4c_connection_is_connected(connection)) {
- printf("SUCCESS\n");
- // we could let the system shut this down,
- // or do it ourselves
- plc4c_system_remove_connection(system, connection);
- plc4c_connection_destroy(connection);
- state = DISCONNECTED;
-
- // Terminate the main program loop.
- loop = false;
- }
- break;
- }
- case DISCONNECTED: {
- // End the loop.
- loop = false;
- break;
- }
+ // Clean up.
+ plc4c_connection_read_response_destroy(read_response);
+ plc4c_read_request_execution_destroy(read_request_execution);
+ plc4c_read_request_destroy(read_request);
+
+ // Create a new write-request.
+ printf("Preparing a write-request for 'STDOUT/foo:INTEGER' ... ");
+ plc4c_list *address_list = NULL;
+ plc4c_utils_list_create(&address_list);
+ plc4c_utils_list_insert_head_value(address_list,
+ (void *)"STDOUT/foo:STRING");
+ plc4c_list *value_list = NULL;
+ plc4c_utils_list_create(&value_list);
+ char value[] = "bar";
+ plc4c_utils_list_insert_head_value(
+ value_list,
+ plc4c_data_create_constant_string_data(strlen(value), value));
+ result = plc4c_connection_create_write_request(
+ connection, address_list, value_list, &write_request);
+
+ // As we only used these to create the request, they can now be released
+ // again.
+ plc4c_utils_list_delete_elements(address_list, &delete_address);
+ plc4c_utils_list_delete_elements(value_list, &delete_address);
+ free(address_list);
+ free(value_list);
+
+ if (result != OK) {
+ printf("FAILED\n");
+ return -1;
+ }
+ printf("SUCCESS\n");
+
+ // Execute the write-request.
+ printf("Executing a write-request ... \n");
+ result = plc4c_write_request_execute(write_request,
+ &write_request_execution);
+ if (result != OK) {
+ printf("FAILED\n");
+ return -1;
+ } else {
+ state = WRITE_REQUEST_SENT;
+ }
+ break;
+ }
+ // Wait until the write-request execution is finished.
+ case WRITE_REQUEST_SENT: {
+ if (plc4c_write_request_finished_successfully(
+ write_request_execution)) {
+ printf("SUCCESS\n");
+ state = WRITE_RESPONSE_RECEIVED;
+ } else if (plc4c_write_request_has_error(write_request_execution)) {
+ printf("FAILED\n");
+ return -1;
+ }
+ break;
+ }
+ case WRITE_RESPONSE_RECEIVED: {
+ plc4c_write_response *write_response =
+ plc4c_write_request_get_response(write_request_execution);
+
+ // Iterate over the responses ...
+ plc4c_list_element *cur_element =
+ plc4c_utils_list_head(write_response->response_items);
+ while (cur_element != NULL) {
+ plc4c_response_item *response_item = cur_element->value;
+ printf(" - Write Value %s (%s)\n", response_item->item->name,
+ plc4c_response_code_to_message(response_item->response_code));
+ cur_element = cur_element->next;
+ }
+
+ // Clean up.
+ plc4c_connection_write_response_destroy(write_response);
+ plc4c_write_request_execution_destroy(write_request_execution);
+
+ // Disconnect.
+ printf("Disconnecting ... ");
+ result = plc4c_connection_disconnect(connection);
+ if (result != OK) {
+ printf("FAILED");
+ return -1;
+ }
+ state = DISCONNECTING;
+ break;
+ }
+ // Wait until the connection is disconnected
+ case DISCONNECTING: {
+ if (!plc4c_connection_is_connected(connection)) {
+ printf("SUCCESS\n");
+ // we could let the system shut this down,
+ // or do it ourselves
+ plc4c_system_remove_connection(system, connection);
+ plc4c_connection_destroy(connection);
+ state = DISCONNECTED;
+
+ // Terminate the main program loop.
+ loop = false;
}
+ break;
+ }
+ case DISCONNECTED: {
+ // End the loop.
+ loop = false;
+ break;
+ }
}
+ }
- // Make sure everything is cleaned up correctly.
- plc4c_system_shutdown(system);
+ // Make sure everything is cleaned up correctly.
+ plc4c_system_shutdown(system);
- // Finally destroy the plc4c_system, freeing up all memory allocated by plc4c.
- plc4c_system_destroy(system);
+ // Finally destroy the plc4c_system, freeing up all memory allocated by plc4c.
+ plc4c_system_destroy(system);
- return 0;
+ return 0;
}
#pragma clang diagnostic pop
diff --git a/sandbox/plc4c/spi/include/plc4c/spi/system_private.h b/sandbox/plc4c/spi/include/plc4c/spi/system_private.h
index 3f4f49c..aeefbdb 100644
--- a/sandbox/plc4c/spi/include/plc4c/spi/system_private.h
+++ b/sandbox/plc4c/spi/include/plc4c/spi/system_private.h
@@ -19,10 +19,10 @@
#ifndef PLC4C_SPI_SYSTEM_PRIVATE_H_
#define PLC4C_SPI_SYSTEM_PRIVATE_H_
-#include <plc4c/types.h>
#include <plc4c/system.h>
+#include <plc4c/types.h>
plc4c_return_code plc4c_system_create_connection(char *connection_string,
plc4c_connection **connection);
-#endif //PLC4C_SPI_SYSTEM_PRIVATE_H_
+#endif // PLC4C_SPI_SYSTEM_PRIVATE_H_
diff --git a/sandbox/plc4c/spi/src/data.c b/sandbox/plc4c/spi/src/data.c
index 2a59d9a..88345f2 100644
--- a/sandbox/plc4c/spi/src/data.c
+++ b/sandbox/plc4c/spi/src/data.c
@@ -1,164 +1,164 @@
#include <assert.h>
+#include <plc4c/data.h>
+#include <plc4c/spi/types_private.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
-#include <plc4c/data.h>
-#include <plc4c/spi/types_private.h>
plc4c_data *plc4c_data_create_boolean_data(bool b) {
- plc4c_data *data = malloc(sizeof(plc4c_data));
- data->data_type = PLC4C_BOOL;
- data->size = sizeof(bool);
- data->data.boolean_value = b;
- return data;
+ plc4c_data *data = malloc(sizeof(plc4c_data));
+ data->data_type = PLC4C_BOOL;
+ data->size = sizeof(bool);
+ data->data.boolean_value = b;
+ return data;
}
plc4c_data *plc4c_data_create_char_data(char c) {
- plc4c_data *data = malloc(sizeof(plc4c_data));
- data->data_type = PLC4C_CHAR;
- data->size = sizeof(char);
- data->data.char_value = c;
- return data;
+ plc4c_data *data = malloc(sizeof(plc4c_data));
+ data->data_type = PLC4C_CHAR;
+ data->size = sizeof(char);
+ data->data.char_value = c;
+ return data;
}
plc4c_data *plc4c_data_create_uchar_data(unsigned char uc) {
- plc4c_data *data = malloc(sizeof(plc4c_data));
- data->data_type = PLC4C_UCHAR;
- data->size = sizeof(unsigned char);
- data->data.uchar_value = uc;
- return data;
+ plc4c_data *data = malloc(sizeof(plc4c_data));
+ data->data_type = PLC4C_UCHAR;
+ data->size = sizeof(unsigned char);
+ data->data.uchar_value = uc;
+ return data;
}
plc4c_data *plc4c_data_create_short_data(short s) {
- plc4c_data *data = malloc(sizeof(plc4c_data));
- data->data_type = PLC4C_SHORT;
- data->size = sizeof(short);
- data->data.short_value = s;
- return data;
+ plc4c_data *data = malloc(sizeof(plc4c_data));
+ data->data_type = PLC4C_SHORT;
+ data->size = sizeof(short);
+ data->data.short_value = s;
+ return data;
}
plc4c_data *plc4c_data_create_ushort_data(unsigned short us) {
- plc4c_data *data = malloc(sizeof(plc4c_data));
- data->data_type = PLC4C_USHORT;
- data->size = sizeof(unsigned short);
- data->data.ushort_value = us;
- return data;
+ plc4c_data *data = malloc(sizeof(plc4c_data));
+ data->data_type = PLC4C_USHORT;
+ data->size = sizeof(unsigned short);
+ data->data.ushort_value = us;
+ return data;
}
plc4c_data *plc4c_data_create_int_data(int i) {
- plc4c_data *data = malloc(sizeof(plc4c_data));
- data->data_type = PLC4C_INT;
- data->size = sizeof(int);
- data->data.int_value = i;
- return data;
+ plc4c_data *data = malloc(sizeof(plc4c_data));
+ data->data_type = PLC4C_INT;
+ data->size = sizeof(int);
+ data->data.int_value = i;
+ return data;
}
plc4c_data *plc4c_data_create_uint_data(unsigned int ui) {
- plc4c_data *data = malloc(sizeof(plc4c_data));
- data->data_type = PLC4C_UINT;
- data->size = sizeof(unsigned int);
- data->data.uint_value = ui;
- return data;
+ plc4c_data *data = malloc(sizeof(plc4c_data));
+ data->data_type = PLC4C_UINT;
+ data->size = sizeof(unsigned int);
+ data->data.uint_value = ui;
+ return data;
}
plc4c_data *plc4c_data_create_string_data(unsigned int size, char *s) {
- plc4c_data *data = malloc(sizeof(plc4c_data));
- data->data_type = PLC4C_STRING_POINTER;
- data->size = size;
- data->data.pstring_value = s;
- return data;
+ plc4c_data *data = malloc(sizeof(plc4c_data));
+ data->data_type = PLC4C_STRING_POINTER;
+ data->size = size;
+ data->data.pstring_value = s;
+ return data;
}
plc4c_data *plc4c_data_create_constant_string_data(unsigned int size, char *s) {
- plc4c_data *data = malloc(sizeof(plc4c_data));
- data->data_type = PLC4C_CONSTANT_STRING;
- data->size = size;
- data->data.const_string_value = s;
- return data;
+ plc4c_data *data = malloc(sizeof(plc4c_data));
+ data->data_type = PLC4C_CONSTANT_STRING;
+ data->size = size;
+ data->data.const_string_value = s;
+ return data;
}
plc4c_data *plc4c_data_create_void_pointer_data(void *v) {
- plc4c_data *data = malloc(sizeof(plc4c_data));
- data->data_type = PLC4C_VOID_POINTER;
- data->size = 0;
- data->data.pvoid_value = v;
- return data;
+ plc4c_data *data = malloc(sizeof(plc4c_data));
+ data->data_type = PLC4C_VOID_POINTER;
+ data->size = 0;
+ data->data.pvoid_value = v;
+ return data;
}
plc4c_data *plc4c_data_create_float_data(float f) {
- plc4c_data *data = malloc(sizeof(plc4c_data));
- data->data_type = PLC4C_FLOAT;
- data->size = sizeof(float);
- data->data.float_value = f;
+ plc4c_data *data = malloc(sizeof(plc4c_data));
+ data->data_type = PLC4C_FLOAT;
+ data->size = sizeof(float);
+ data->data.float_value = f;
}
void plc4c_data_printf(plc4c_data *data) {
- switch (data->data_type) {
- case PLC4C_CHAR:
- printf("%c", data->data.char_value);
- break;
- case PLC4C_UCHAR:
- printf("%c", data->data.uchar_value);
- break;
- case PLC4C_SHORT:
- printf("%d", data->data.short_value);
- break;
- case PLC4C_USHORT:
- printf("%d", data->data.ushort_value);
- break;
- case PLC4C_INT:
- printf("%d", data->data.int_value);
- break;
- case PLC4C_UINT:
- printf("%iu", data->data.uint_value);
- break;
- case PLC4C_FLOAT:
- printf("%f", data->data.float_value);
- break;
- case PLC4C_STRING_POINTER:
- printf("%s", data->data.pstring_value);
- break;
- case PLC4C_CONSTANT_STRING:
- printf("%s", data->data.const_string_value);
- break;
- case PLC4C_VOID_POINTER:
- if (data->custom_printf != NULL) {
- data->custom_printf(data);
- } else {
- printf("%p", data->data.pvoid_value);
- }
- break;
- default:
- break;
- }
+ switch (data->data_type) {
+ case PLC4C_CHAR:
+ printf("%c", data->data.char_value);
+ break;
+ case PLC4C_UCHAR:
+ printf("%c", data->data.uchar_value);
+ break;
+ case PLC4C_SHORT:
+ printf("%d", data->data.short_value);
+ break;
+ case PLC4C_USHORT:
+ printf("%d", data->data.ushort_value);
+ break;
+ case PLC4C_INT:
+ printf("%d", data->data.int_value);
+ break;
+ case PLC4C_UINT:
+ printf("%iu", data->data.uint_value);
+ break;
+ case PLC4C_FLOAT:
+ printf("%f", data->data.float_value);
+ break;
+ case PLC4C_STRING_POINTER:
+ printf("%s", data->data.pstring_value);
+ break;
+ case PLC4C_CONSTANT_STRING:
+ printf("%s", data->data.const_string_value);
+ break;
+ case PLC4C_VOID_POINTER:
+ if (data->custom_printf != NULL) {
+ data->custom_printf(data);
+ } else {
+ printf("%p", data->data.pvoid_value);
+ }
+ break;
+ default:
+ break;
+ }
}
-
-void plc4c_data_set_custom_destroy(plc4c_data *data, plc4c_data_custom_destroy data_custom_destroy) {
- data->custom_destroy = data_custom_destroy;
+void plc4c_data_set_custom_destroy(
+ plc4c_data *data, plc4c_data_custom_destroy data_custom_destroy) {
+ data->custom_destroy = data_custom_destroy;
}
-void plc4c_data_set_custom_printf(plc4c_data *data, plc4c_data_custom_printf data_custom_printf) {
- data->custom_printf = data_custom_printf;
+void plc4c_data_set_custom_printf(plc4c_data *data,
+ plc4c_data_custom_printf data_custom_printf) {
+ data->custom_printf = data_custom_printf;
}
void plc4c_data_delete(plc4c_data *data) {
- assert(data != NULL);
- if (data->custom_destroy != NULL) {
- data->custom_destroy(data);
- } else {
- switch (data->data_type) {
- case PLC4C_VOID_POINTER:
- free(data->data.pvoid_value);
- break;
- case PLC4C_STRING_POINTER:
- free(data->data.pstring_value);
- break;
- default:
- break;
- }
+ assert(data != NULL);
+ if (data->custom_destroy != NULL) {
+ data->custom_destroy(data);
+ } else {
+ switch (data->data_type) {
+ case PLC4C_VOID_POINTER:
+ free(data->data.pvoid_value);
+ break;
+ case PLC4C_STRING_POINTER:
+ free(data->data.pstring_value);
+ break;
+ default:
+ break;
}
- free(data);
+ }
+ free(data);
}
-
diff --git a/sandbox/plc4c/spi/src/types.c b/sandbox/plc4c/spi/src/types.c
index 892c6bd..88c25bc 100644
--- a/sandbox/plc4c/spi/src/types.c
+++ b/sandbox/plc4c/spi/src/types.c
@@ -20,129 +20,128 @@
#include <plc4c/types.h>
char *plc4c_return_code_to_message(plc4c_return_code return_code) {
- switch (return_code) {
- case UNFINISHED: {
- return "UNFINISHED";
- }
- case OK: {
- return "OK";
- }
- case NO_MEMORY: {
- return "OUT_OF_MEMORY";
- }
- case INVALID_CONNECTION_STRING: {
- return "INVALID CONNECTION STRING";
- }
- case NON_MATCHING_LISTS: {
- return "ITEM AND VALUE LISTS HAVE DIFFERENT SIZES";
- }
- case INVALID_LIST_SIZE: {
- return "INVALID LIST SIZE";
- }
- case NOT_REACHABLE: {
- return "DEVICE NOT REACHABLE";
- }
- case PERMISSION_DENIED: {
- return "PERMISSION DENIED";
- }
+ switch (return_code) {
+ case UNFINISHED: {
+ return "UNFINISHED";
+ }
+ case OK: {
+ return "OK";
+ }
+ case NO_MEMORY: {
+ return "OUT_OF_MEMORY";
+ }
+ case INVALID_CONNECTION_STRING: {
+ return "INVALID CONNECTION STRING";
+ }
+ case NON_MATCHING_LISTS: {
+ return "ITEM AND VALUE LISTS HAVE DIFFERENT SIZES";
+ }
+ case INVALID_LIST_SIZE: {
+ return "INVALID LIST SIZE";
+ }
+ case NOT_REACHABLE: {
+ return "DEVICE NOT REACHABLE";
+ }
+ case PERMISSION_DENIED: {
+ return "PERMISSION DENIED";
+ }
- case NO_DRIVER_AVAILABLE: {
- return "NO DRIVER FOUND";
- }
- case UNKNOWN_DRIVER: {
- return "UNKNOWN DRIVER";
- }
+ case NO_DRIVER_AVAILABLE: {
+ return "NO DRIVER FOUND";
+ }
+ case UNKNOWN_DRIVER: {
+ return "UNKNOWN DRIVER";
+ }
- case UNSPECIFIED_TRANSPORT: {
- return "TRANSPORT NOT SPECIFIED";
- }
- case NO_TRANSPORT_AVAILABLE: {
- return "NO TRANSPORT FOUND";
- }
- case UNKNOWN_TRANSPORT: {
- return "UNKNOWN TRANSPORT";
- }
+ case UNSPECIFIED_TRANSPORT: {
+ return "TRANSPORT NOT SPECIFIED";
+ }
+ case NO_TRANSPORT_AVAILABLE: {
+ return "NO TRANSPORT FOUND";
+ }
+ case UNKNOWN_TRANSPORT: {
+ return "UNKNOWN TRANSPORT";
+ }
- case UNKNOWN_ERROR: {
- return "UNKNOWN ERROR";
- }
- case INTERNAL_ERROR: {
- return "INTERNAL ERROR";
- }
+ case UNKNOWN_ERROR: {
+ return "UNKNOWN ERROR";
+ }
+ case INTERNAL_ERROR: {
+ return "INTERNAL ERROR";
+ }
- default: {
- return "UNKNOWN RETURN CODE";
- }
+ default: {
+ return "UNKNOWN RETURN CODE";
}
+ }
}
char *plc4c_response_code_to_message(plc4c_response_code response_code) {
- switch (response_code) {
- case PLC4C_RESPONSE_CODE_OK: {
- return "OK";
- }
- case PLC4C_RESPONSE_CODE_NOT_FOUND: {
- return "NOT FOUND";
- }
- case PLC4C_RESPONSE_CODE_ACCESS_DENIED: {
- return "ACCESS DENIED";
- }
- case PLC4C_RESPONSE_CODE_INVALID_ADDRESS: {
- return "INVALID ADDRESS";
- }
- case PLC4C_RESPONSE_CODE_INVALID_DATATYPE: {
- return "INVALID_DATATYPE";
- }
- case PLC4C_RESPONSE_CODE_INTERNAL_ERROR: {
- return "INTERNAL ERROR";
- }
- case PLC4C_RESPONSE_CODE_RESPONSE_PENDING: {
- return "RESPONSE PENDING";
- }
- default: {
- return "UNKNOWN RESPONSE CODE";
- }
+ switch (response_code) {
+ case PLC4C_RESPONSE_CODE_OK: {
+ return "OK";
+ }
+ case PLC4C_RESPONSE_CODE_NOT_FOUND: {
+ return "NOT FOUND";
+ }
+ case PLC4C_RESPONSE_CODE_ACCESS_DENIED: {
+ return "ACCESS DENIED";
}
+ case PLC4C_RESPONSE_CODE_INVALID_ADDRESS: {
+ return "INVALID ADDRESS";
+ }
+ case PLC4C_RESPONSE_CODE_INVALID_DATATYPE: {
+ return "INVALID_DATATYPE";
+ }
+ case PLC4C_RESPONSE_CODE_INTERNAL_ERROR: {
+ return "INTERNAL ERROR";
+ }
+ case PLC4C_RESPONSE_CODE_RESPONSE_PENDING: {
+ return "RESPONSE PENDING";
+ }
+ default: {
+ return "UNKNOWN RESPONSE CODE";
+ }
+ }
}
char *plc4c_data_type_name(plc4c_data_type data_type) {
- switch (data_type) {
- case PLC4C_CHAR: {
- return "PLC4C_CHAR";
- }
- case PLC4C_UCHAR: {
- return "PLC4C_UCHAR";
- }
- case PLC4C_SHORT: {
- return "PLC4C_SHORT";
- }
- case PLC4C_USHORT: {
- return "PLC4C_USHORT";
- }
- case PLC4C_BOOL: {
- return "PLC4C_BOOL";
- }
- case PLC4C_INT: {
- return "PLC4C_INT";
- }
- case PLC4C_UINT: {
- return "PLC4C_UINT";
- }
- case PLC4C_FLOAT: {
- return "PLC4C_FLOAT";
- }
- case PLC4C_STRING_POINTER: {
- return "PLC4C_STRING_POINTER";
- }
- case PLC4C_CONSTANT_STRING: {
- return "PLC4C_CONSTANT_STRING";
- }
- case PLC4C_VOID_POINTER: {
- return "PLC4C_VOID_POINTER";
- }
- default: {
- return "UNKNOWN";
- }
+ switch (data_type) {
+ case PLC4C_CHAR: {
+ return "PLC4C_CHAR";
+ }
+ case PLC4C_UCHAR: {
+ return "PLC4C_UCHAR";
+ }
+ case PLC4C_SHORT: {
+ return "PLC4C_SHORT";
+ }
+ case PLC4C_USHORT: {
+ return "PLC4C_USHORT";
+ }
+ case PLC4C_BOOL: {
+ return "PLC4C_BOOL";
}
+ case PLC4C_INT: {
+ return "PLC4C_INT";
+ }
+ case PLC4C_UINT: {
+ return "PLC4C_UINT";
+ }
+ case PLC4C_FLOAT: {
+ return "PLC4C_FLOAT";
+ }
+ case PLC4C_STRING_POINTER: {
+ return "PLC4C_STRING_POINTER";
+ }
+ case PLC4C_CONSTANT_STRING: {
+ return "PLC4C_CONSTANT_STRING";
+ }
+ case PLC4C_VOID_POINTER: {
+ return "PLC4C_VOID_POINTER";
+ }
+ default: {
+ return "UNKNOWN";
+ }
+ }
}
-
diff --git a/sandbox/plc4c/spi/src/utils/list.c b/sandbox/plc4c/spi/src/utils/list.c
index 79d1f2c..7d9c1d8 100644
--- a/sandbox/plc4c/spi/src/utils/list.c
+++ b/sandbox/plc4c/spi/src/utils/list.c
@@ -20,161 +20,164 @@
#include <plc4c/utils/list.h>
void plc4c_utils_list_create(plc4c_list **list) {
- plc4c_list *new_list = malloc(sizeof(plc4c_list));
- new_list->head = NULL;
- new_list->tail = NULL;
- *list = new_list;
+ plc4c_list *new_list = malloc(sizeof(plc4c_list));
+ new_list->head = NULL;
+ new_list->tail = NULL;
+ *list = new_list;
}
size_t plc4c_utils_list_size(plc4c_list *list) {
- if (list->head == NULL) {
- return 0;
- }
- plc4c_list_element *cur_element = list->head;
- int count = 1;
- while (cur_element->next != NULL) {
- count++;
- cur_element = cur_element->next;
- }
- return count;
+ if (list->head == NULL) {
+ return 0;
+ }
+ plc4c_list_element *cur_element = list->head;
+ int count = 1;
+ while (cur_element->next != NULL) {
+ count++;
+ cur_element = cur_element->next;
+ }
+ return count;
}
-bool plc4c_utils_list_empty(plc4c_list *list) {
- return list->head == NULL;
-}
+bool plc4c_utils_list_empty(plc4c_list *list) { return list->head == NULL; }
bool plc4c_utils_list_contains(plc4c_list *list, plc4c_list_element *element) {
- if ((list == NULL) || (element == NULL)) {
- return false;
- }
- plc4c_list_element *cur_element = list->head;
- do {
- if (cur_element == element) {
- return true;
- }
- cur_element = cur_element->next;
- } while (cur_element != NULL);
+ if ((list == NULL) || (element == NULL)) {
return false;
+ }
+ plc4c_list_element *cur_element = list->head;
+ do {
+ if (cur_element == element) {
+ return true;
+ }
+ cur_element = cur_element->next;
+ } while (cur_element != NULL);
+ return false;
}
-void plc4c_utils_list_insert_head(plc4c_list *list, plc4c_list_element *element) {
- if (list->head == NULL) {
- list->head = element;
- return;
- }
- list->head->next = element;
- element->previous = list->head;
+void plc4c_utils_list_insert_head(plc4c_list *list,
+ plc4c_list_element *element) {
+ if (list->head == NULL) {
list->head = element;
+ return;
+ }
+ list->head->next = element;
+ element->previous = list->head;
+ list->head = element;
}
void plc4c_utils_list_insert_head_value(plc4c_list *list, void *value) {
- plc4c_list_element *new_element = malloc(sizeof(plc4c_list_element));
- new_element->value = value;
- new_element->next = NULL;
- new_element->previous = NULL;
- plc4c_utils_list_insert_head(list, new_element);
+ plc4c_list_element *new_element = malloc(sizeof(plc4c_list_element));
+ new_element->value = value;
+ new_element->next = NULL;
+ new_element->previous = NULL;
+ plc4c_utils_list_insert_head(list, new_element);
}
-void plc4c_utils_list_insert_tail(plc4c_list *list, plc4c_list_element *element) {
- if (list->tail != NULL) {
- list->tail->previous = element;
- element->next = list->tail;
- } else {
- list->head = element;
- }
- list->tail = element;
+void plc4c_utils_list_insert_tail(plc4c_list *list,
+ plc4c_list_element *element) {
+ if (list->tail != NULL) {
+ list->tail->previous = element;
+ element->next = list->tail;
+ } else {
+ list->head = element;
+ }
+ list->tail = element;
}
void plc4c_utils_list_insert_tail_value(plc4c_list *list, void *value) {
- plc4c_list_element *new_element = malloc(sizeof(plc4c_list_element));
- new_element->value = value;
- new_element->next = NULL;
- new_element->previous = NULL;
- plc4c_utils_list_insert_tail(list, new_element);
+ plc4c_list_element *new_element = malloc(sizeof(plc4c_list_element));
+ new_element->value = value;
+ new_element->next = NULL;
+ new_element->previous = NULL;
+ plc4c_utils_list_insert_tail(list, new_element);
}
void plc4c_utils_list_remove(plc4c_list *list, plc4c_list_element *element) {
- // If the list doesn't contain this element, no need to do anything.
- if (!plc4c_utils_list_contains(list, element)) {
- return;
- }
+ // If the list doesn't contain this element, no need to do anything.
+ if (!plc4c_utils_list_contains(list, element)) {
+ return;
+ }
- // Remember the next and previous elements.
- plc4c_list_element *previous_element = element->previous;
- plc4c_list_element *next_element = element->next;
+ // Remember the next and previous elements.
+ plc4c_list_element *previous_element = element->previous;
+ plc4c_list_element *next_element = element->next;
- // Link the previous and next elements (taking the current element out of the list).
- if (previous_element != NULL) {
- previous_element->next = next_element;
- }
- if (next_element != NULL) {
- next_element->previous = previous_element;
- }
+ // Link the previous and next elements (taking the current element out of the
+ // list).
+ if (previous_element != NULL) {
+ previous_element->next = next_element;
+ }
+ if (next_element != NULL) {
+ next_element->previous = previous_element;
+ }
- // Update head and tail (if required)
- if (list->head == element) {
- list->head = next_element;
- }
- if (list->tail == element) {
- list->tail = previous_element;
- }
+ // Update head and tail (if required)
+ if (list->head == element) {
+ list->head = next_element;
+ }
+ if (list->tail == element) {
+ list->tail = previous_element;
+ }
- // Reset the pointers to the neighboring elements.
- element->next = NULL;
- element->previous = NULL;
+ // Reset the pointers to the neighboring elements.
+ element->next = NULL;
+ element->previous = NULL;
}
plc4c_list_element *plc4c_utils_list_remove_head(plc4c_list *list) {
- plc4c_list_element *removed_element = list->head;
- if (removed_element != NULL) {
- if (list->head->next != NULL) {
- list->head = list->head->next;
- list->head->previous = NULL;
- } else {
- list->head = NULL;
- }
- removed_element->previous = NULL;
- removed_element->next = NULL;
+ plc4c_list_element *removed_element = list->head;
+ if (removed_element != NULL) {
+ if (list->head->next != NULL) {
+ list->head = list->head->next;
+ list->head->previous = NULL;
+ } else {
+ list->head = NULL;
}
- return removed_element;
+ removed_element->previous = NULL;
+ removed_element->next = NULL;
+ }
+ return removed_element;
}
plc4c_list_element *plc4c_utils_list_remove_tail(plc4c_list *list) {
- plc4c_list_element *removed_element = list->tail;
- if (removed_element != NULL) {
- if (list->tail->previous != NULL) {
- list->tail = list->tail->previous;
- list->tail->next = NULL;
- } else {
- list->tail = NULL;
- list->head = NULL;
- }
- removed_element->next = NULL;
- removed_element->previous = NULL;
+ plc4c_list_element *removed_element = list->tail;
+ if (removed_element != NULL) {
+ if (list->tail->previous != NULL) {
+ list->tail = list->tail->previous;
+ list->tail->next = NULL;
+ } else {
+ list->tail = NULL;
+ list->head = NULL;
}
- return removed_element;
+ removed_element->next = NULL;
+ removed_element->previous = NULL;
+ }
+ return removed_element;
}
plc4c_list_element *plc4c_utils_list_head(plc4c_list *list) {
- return list->head;
+ return list->head;
}
plc4c_list_element *plc4c_utils_list_tail(plc4c_list *list) {
- return list->tail;
+ return list->tail;
}
-void plc4c_utils_list_delete_elements(plc4c_list *list, plc4c_list_delete_element_callback callback) {
- // for each of our elements, call the delete callback
- plc4c_list_element *head = plc4c_utils_list_remove_head(list);
- while (head != NULL) {
- callback(head);
- free(head);
- head = plc4c_utils_list_remove_head(list);
- }
- // at this point the list is empty
+void plc4c_utils_list_delete_elements(
+ plc4c_list *list, plc4c_list_delete_element_callback callback) {
+ // for each of our elements, call the delete callback
+ plc4c_list_element *head = plc4c_utils_list_remove_head(list);
+ while (head != NULL) {
+ callback(head);
+ free(head);
+ head = plc4c_utils_list_remove_head(list);
+ }
+ // at this point the list is empty
}
-plc4c_list_element *plc4c_utils_list_find_element_by_item(plc4c_list *list, void *item){
+plc4c_list_element *plc4c_utils_list_find_element_by_item(plc4c_list *list,
+ void *item) {
plc4c_list_element *head = plc4c_utils_list_head(list);
while (head != NULL) {
if (head->value == item) {
diff --git a/sandbox/plc4c/spi/src/utils/queue.c b/sandbox/plc4c/spi/src/utils/queue.c
index 842fb35..0b35897 100644
--- a/sandbox/plc4c/spi/src/utils/queue.c
+++ b/sandbox/plc4c/spi/src/utils/queue.c
@@ -20,56 +20,54 @@
#include <plc4c/utils/queue.h>
void plc4c_utils_queue_create(plc4c_queue **queue) {
- plc4c_queue *new_queue = malloc(sizeof(plc4c_queue));
- new_queue->head = NULL;
- new_queue->tail = NULL;
- *queue = new_queue;
+ plc4c_queue *new_queue = malloc(sizeof(plc4c_queue));
+ new_queue->head = NULL;
+ new_queue->tail = NULL;
+ *queue = new_queue;
}
size_t plc4c_utils_queue_size(plc4c_queue *queue) {
- if (queue->head == NULL) {
- return 0;
- }
- plc4c_queue_element *cur_element = queue->head;
- int count = 1;
- while (cur_element->next != NULL) {
- count++;
- cur_element = cur_element->next;
- }
- return count;
+ if (queue->head == NULL) {
+ return 0;
+ }
+ plc4c_queue_element *cur_element = queue->head;
+ int count = 1;
+ while (cur_element->next != NULL) {
+ count++;
+ cur_element = cur_element->next;
+ }
+ return count;
}
-bool plc4c_utils_queue_empty(plc4c_queue *queue) {
- return queue->head == NULL;
-}
+bool plc4c_utils_queue_empty(plc4c_queue *queue) { return queue->head == NULL; }
void plc4c_utils_queue_push(plc4c_queue *queue, plc4c_queue_element *element) {
- if (queue->tail != NULL) {
- queue->tail->next = element;
- } else {
- queue->head = element;
- }
- queue->tail = element;
+ if (queue->tail != NULL) {
+ queue->tail->next = element;
+ } else {
+ queue->head = element;
+ }
+ queue->tail = element;
}
void plc4c_utils_queue_push_value(plc4c_queue *queue, void *value) {
- plc4c_queue_element *new_element = malloc(sizeof(plc4c_queue_element));
- new_element->value = value;
- new_element->next = NULL;
- plc4c_utils_queue_push(queue, new_element);
+ plc4c_queue_element *new_element = malloc(sizeof(plc4c_queue_element));
+ new_element->value = value;
+ new_element->next = NULL;
+ plc4c_utils_queue_push(queue, new_element);
}
plc4c_queue_element *plc4c_utils_queue_pop(plc4c_queue *queue) {
- plc4c_queue_element *head_element = queue->head;
- queue->head = queue->head->next;
- head_element->next = NULL;
- return head_element;
+ plc4c_queue_element *head_element = queue->head;
+ queue->head = queue->head->next;
+ head_element->next = NULL;
+ return head_element;
}
plc4c_queue_element *plc4c_utils_queue_head(plc4c_queue *queue) {
- return queue->head;
+ return queue->head;
}
plc4c_queue_element *plc4c_utils_queue_tail(plc4c_queue *queue) {
- return queue->tail;
+ return queue->tail;
}
diff --git a/sandbox/plc4c/spi/test/system_test.c b/sandbox/plc4c/spi/test/system_test.c
index fb2d4a2..b973fe4 100644
--- a/sandbox/plc4c/spi/test/system_test.c
+++ b/sandbox/plc4c/spi/test/system_test.c
@@ -16,70 +16,78 @@
* specific language governing permissions and limitations
* under the License.
*/
-#include <unity.h>
-#include <stdlib.h>
#include <plc4c/spi/types_private.h>
+#include <stdlib.h>
+#include <unity.h>
+
#include "plc4c/spi/system_private.h"
-void setUp(void) {
-}
+void setUp(void) {}
-void tearDown(void) {
-}
+void tearDown(void) {}
-void test_system_plc4c_system_create_connection_args(char *connection_string,
- plc4c_return_code expected_return_code,
- char *expected_connection_string,
- char *expected_protocol_code,
- char *expected_transport_code,
- char *expected_transport_connect_information,
- char *expected_parameters) {
- plc4c_connection *connection = NULL;
- plc4c_return_code result = plc4c_system_create_connection(connection_string, &connection);
- TEST_ASSERT_EQUAL(expected_return_code, result);
- if (expected_return_code != OK) {
- TEST_ASSERT_NULL(connection);
- } else {
- TEST_ASSERT_EQUAL_STRING(expected_connection_string, connection->connection_string);
- TEST_ASSERT_EQUAL_STRING(expected_protocol_code, connection->protocol_code);
- TEST_ASSERT_EQUAL_STRING(expected_transport_code, connection->transport_code);
- TEST_ASSERT_EQUAL_STRING(expected_transport_connect_information, connection->transport_connect_information);
- TEST_ASSERT_EQUAL_STRING(expected_parameters, connection->parameters);
- free(connection);
- }
+void test_system_plc4c_system_create_connection_args(
+ char *connection_string, plc4c_return_code expected_return_code,
+ char *expected_connection_string, char *expected_protocol_code,
+ char *expected_transport_code, char *expected_transport_connect_information,
+ char *expected_parameters) {
+ plc4c_connection *connection = NULL;
+ plc4c_return_code result =
+ plc4c_system_create_connection(connection_string, &connection);
+ TEST_ASSERT_EQUAL(expected_return_code, result);
+ if (expected_return_code != OK) {
+ TEST_ASSERT_NULL(connection);
+ } else {
+ TEST_ASSERT_EQUAL_STRING(expected_connection_string,
+ connection->connection_string);
+ TEST_ASSERT_EQUAL_STRING(expected_protocol_code, connection->protocol_code);
+ TEST_ASSERT_EQUAL_STRING(expected_transport_code,
+ connection->transport_code);
+ TEST_ASSERT_EQUAL_STRING(expected_transport_connect_information,
+ connection->transport_connect_information);
+ TEST_ASSERT_EQUAL_STRING(expected_parameters, connection->parameters);
+ free(connection);
+ }
}
void test_system_plc4c_system_create_connection(void) {
- test_system_plc4c_system_create_connection_args("s7://1.2.3.4", OK, "s7://1.2.3.4", "s7", NULL, "1.2.3.4", NULL);
- test_system_plc4c_system_create_connection_args("s7:tcp://1.2.3.4", OK, "s7:tcp://1.2.3.4", "s7", "tcp", "1.2.3.4",
- NULL);
- test_system_plc4c_system_create_connection_args("s7://1.2.3.4?params", OK, "s7://1.2.3.4?params", "s7", NULL,
- "1.2.3.4", "params");
- test_system_plc4c_system_create_connection_args("s7:tcp://1.2.3.4?params", OK, "s7:tcp://1.2.3.4?params", "s7",
- "tcp", "1.2.3.4", "params");
+ test_system_plc4c_system_create_connection_args(
+ "s7://1.2.3.4", OK, "s7://1.2.3.4", "s7", NULL, "1.2.3.4", NULL);
+ test_system_plc4c_system_create_connection_args(
+ "s7:tcp://1.2.3.4", OK, "s7:tcp://1.2.3.4", "s7", "tcp", "1.2.3.4", NULL);
+ test_system_plc4c_system_create_connection_args("s7://1.2.3.4?params", OK,
+ "s7://1.2.3.4?params", "s7",
+ NULL, "1.2.3.4", "params");
+ test_system_plc4c_system_create_connection_args(
+ "s7:tcp://1.2.3.4?params", OK, "s7:tcp://1.2.3.4?params", "s7", "tcp",
+ "1.2.3.4", "params");
- // A colon after the "://" shouldn't matter ...
- test_system_plc4c_system_create_connection_args("s7://1.2.3.4:42", OK, "s7://1.2.3.4:42", "s7", NULL, "1.2.3.4:42",
- NULL);
- test_system_plc4c_system_create_connection_args("s7://1.2.3.4?param=a:42", OK, "s7://1.2.3.4?param=a:42", "s7",
- NULL, "1.2.3.4", "param=a:42");
+ // A colon after the "://" shouldn't matter ...
+ test_system_plc4c_system_create_connection_args(
+ "s7://1.2.3.4:42", OK, "s7://1.2.3.4:42", "s7", NULL, "1.2.3.4:42", NULL);
+ test_system_plc4c_system_create_connection_args(
+ "s7://1.2.3.4?param=a:42", OK, "s7://1.2.3.4?param=a:42", "s7", NULL,
+ "1.2.3.4", "param=a:42");
- // Well obviously the parser shouldn't be able to find anything here ...
- test_system_plc4c_system_create_connection_args("hurz", INVALID_CONNECTION_STRING, NULL, NULL, NULL, NULL, NULL);
- // In these cases the parser expects a "//" after the second colon, which isn't there ...
- test_system_plc4c_system_create_connection_args("a:b:c://d", INVALID_CONNECTION_STRING, NULL, NULL, NULL, NULL,
- NULL);
- test_system_plc4c_system_create_connection_args("a:b:d", INVALID_CONNECTION_STRING, NULL, NULL, NULL, NULL, NULL);
+ // Well obviously the parser shouldn't be able to find anything here ...
+ test_system_plc4c_system_create_connection_args(
+ "hurz", INVALID_CONNECTION_STRING, NULL, NULL, NULL, NULL, NULL);
+ // In these cases the parser expects a "//" after the second colon, which
+ // isn't there ...
+ test_system_plc4c_system_create_connection_args(
+ "a:b:c://d", INVALID_CONNECTION_STRING, NULL, NULL, NULL, NULL, NULL);
+ test_system_plc4c_system_create_connection_args(
+ "a:b:d", INVALID_CONNECTION_STRING, NULL, NULL, NULL, NULL, NULL);
- // There should only be one question-mark ...
- test_system_plc4c_system_create_connection_args("a://a?b?c", INVALID_CONNECTION_STRING, NULL, NULL, NULL, NULL,
- NULL);
+ // There should only be one question-mark ...
+ test_system_plc4c_system_create_connection_args(
+ "a://a?b?c", INVALID_CONNECTION_STRING, NULL, NULL, NULL, NULL, NULL);
}
int main(void) {
- UNITY_BEGIN();
+ UNITY_BEGIN();
- RUN_TEST(test_system_plc4c_system_create_connection);
+ RUN_TEST(test_system_plc4c_system_create_connection);
- return UNITY_END();
+ return UNITY_END();
}
\ No newline at end of file
diff --git a/sandbox/plc4c/transports/dummy/include/plc4c/transport_dummy.h b/sandbox/plc4c/transports/dummy/include/plc4c/transport_dummy.h
index f770b4d..26e14bb 100644
--- a/sandbox/plc4c/transports/dummy/include/plc4c/transport_dummy.h
+++ b/sandbox/plc4c/transports/dummy/include/plc4c/transport_dummy.h
@@ -29,4 +29,4 @@ plc4c_transport *plc4c_transport_dummy_create();
#ifdef __cplusplus
}
#endif
-#endif //PLC4C_TRANSPORT_DUMMY_H_
\ No newline at end of file
+#endif // PLC4C_TRANSPORT_DUMMY_H_
\ No newline at end of file
diff --git a/sandbox/plc4c/transports/dummy/src/transport_dummy.c b/sandbox/plc4c/transports/dummy/src/transport_dummy.c
index 57291c7..2c35eb2 100644
--- a/sandbox/plc4c/transports/dummy/src/transport_dummy.c
+++ b/sandbox/plc4c/transports/dummy/src/transport_dummy.c
@@ -17,13 +17,13 @@
under the License.
*/
-#include <stdlib.h>
#include <plc4c/spi/types_private.h>
#include <plc4c/transport_dummy.h>
+#include <stdlib.h>
plc4c_transport *plc4c_transport_dummy_create() {
- plc4c_transport *transport = (plc4c_transport *) malloc(sizeof(plc4c_transport));
- transport->transport_code = "dummy";
- return transport;
+ plc4c_transport *transport =
+ (plc4c_transport *)malloc(sizeof(plc4c_transport));
+ transport->transport_code = "dummy";
+ return transport;
}
-
diff --git a/sandbox/plc4c/transports/serial/include/plc4c/transport_serial.h b/sandbox/plc4c/transports/serial/include/plc4c/transport_serial.h
index f32d204..d1a02ef 100644
--- a/sandbox/plc4c/transports/serial/include/plc4c/transport_serial.h
+++ b/sandbox/plc4c/transports/serial/include/plc4c/transport_serial.h
@@ -29,4 +29,4 @@ plc4c_transport *plc4c_transport_serial_create();
#ifdef __cplusplus
}
#endif
-#endif //PLC4C_TRANSPORT_SERIAL_H_
\ No newline at end of file
+#endif // PLC4C_TRANSPORT_SERIAL_H_
\ No newline at end of file
diff --git a/sandbox/plc4c/transports/serial/src/transport_serial.c b/sandbox/plc4c/transports/serial/src/transport_serial.c
index 2a7ba02..adf0996 100644
--- a/sandbox/plc4c/transports/serial/src/transport_serial.c
+++ b/sandbox/plc4c/transports/serial/src/transport_serial.c
@@ -17,13 +17,13 @@
under the License.
*/
-#include <stdlib.h>
#include <plc4c/spi/types_private.h>
#include <plc4c/transport_serial.h>
+#include <stdlib.h>
plc4c_transport *plc4c_transport_serial_create() {
- plc4c_transport *transport = (plc4c_transport *) malloc(sizeof(plc4c_transport));
- transport->transport_code = "serial";
- return transport;
+ plc4c_transport *transport =
+ (plc4c_transport *)malloc(sizeof(plc4c_transport));
+ transport->transport_code = "serial";
+ return transport;
}
-
diff --git a/sandbox/plc4c/transports/tcp/include/plc4c/transport_tcp.h b/sandbox/plc4c/transports/tcp/include/plc4c/transport_tcp.h
index b0dd2bc..fb57734 100644
--- a/sandbox/plc4c/transports/tcp/include/plc4c/transport_tcp.h
+++ b/sandbox/plc4c/transports/tcp/include/plc4c/transport_tcp.h
@@ -29,4 +29,4 @@ plc4c_transport *plc4c_transport_tcp_create();
#ifdef __cplusplus
}
#endif
-#endif //PLC4C_TRANSPORT_TCP_H_
\ No newline at end of file
+#endif // PLC4C_TRANSPORT_TCP_H_
\ No newline at end of file
diff --git a/sandbox/plc4c/transports/tcp/src/transport_tcp.c b/sandbox/plc4c/transports/tcp/src/transport_tcp.c
index 2875891..6836ad5 100644
--- a/sandbox/plc4c/transports/tcp/src/transport_tcp.c
+++ b/sandbox/plc4c/transports/tcp/src/transport_tcp.c
@@ -17,13 +17,13 @@
under the License.
*/
-#include <stdlib.h>
#include <plc4c/spi/types_private.h>
#include <plc4c/transport_tcp.h>
+#include <stdlib.h>
plc4c_transport *plc4c_transport_tcp_create() {
- plc4c_transport *transport = (plc4c_transport *) malloc(sizeof(plc4c_transport));
- transport->transport_code = "tcp";
- return transport;
+ plc4c_transport *transport =
+ (plc4c_transport *)malloc(sizeof(plc4c_transport));
+ transport->transport_code = "tcp";
+ return transport;
}
-