--- a/ProjectController.py Wed Sep 14 14:55:13 2022 +0200
+++ b/ProjectController.py Wed Sep 14 14:56:25 2022 +0200
@@ -1226,6 +1226,13 @@
self.logger.write_error(traceback.format_exc())
+ # Extensions also need plcCFLAGS in case they include beremiz.h + CTNLocationCFilesAndCFLAGS = [ + (code, self.plcCFLAGS+" "+cflags) + for code,cflags in code_and_cflags], do_calls) + for loc, code_and_cflags, do_calls in CTNLocationCFilesAndCFLAGS] self.LocationCFilesAndCFLAGS = LibCFilesAndCFLAGS + \
CTNLocationCFilesAndCFLAGS
self.LDFLAGS = CTNLDFLAGS + LibLDFLAGS
--- a/opc_ua/client.py Wed Sep 14 14:55:13 2022 +0200
+++ b/opc_ua/client.py Wed Sep 14 14:56:25 2022 +0200
@@ -130,7 +130,8 @@
locstr = "_".join(map(str, current_location))
c_path = os.path.join(buildpath, "opcua_client__%s.c" % locstr)
- c_code = self.modeldata.GenerateC(c_path, locstr, self.GetConfig())
+ c_code = '#include "beremiz.h"\n' + c_code += self.modeldata.GenerateC(c_path, locstr, self.GetConfig()) with open(c_path, 'wb') as c_file:
--- a/opc_ua/opcua_client_maker.py Wed Sep 14 14:55:13 2022 +0200
+++ b/opc_ua/opcua_client_maker.py Wed Sep 14 14:56:25 2022 +0200
@@ -552,7 +552,19 @@
+#define _Log(level, ...) \\ + snprintf(mstr, 255, __VA_ARGS__); \\ + LogMessage(level, mstr, strlen(mstr)); \\ +#define LogInfo(...) _Log(LOG_INFO, __VA_ARGS__); +#define LogError(...) _Log(LOG_CRITICAL, __VA_ARGS__); +#define LogWarning(...) _Log(LOG_WARNING, __VA_ARGS__); + LogInfo("OPC-UA Init no auth\\n"); \\ UA_ClientConfig_setDefault(cc); \\
retval = UA_Client_connect(client, uri);
@@ -562,7 +574,7 @@
UA_ByteString certificate = loadFile(Certificate); \\
UA_ByteString privateKey = loadFile(PrivateKey); \\
- printf("INIT_x509 %s,%s,%s,%s\\n", #Policy, #UpperCaseMode, PrivateKey, Certificate); \\
+ LogInfo("OPC-UA Init x509 %s,%s,%s,%s\\n", #Policy, #UpperCaseMode, PrivateKey, Certificate); \\ cc->securityMode = UA_MESSAGESECURITYMODE_##UpperCaseMode; \\
UA_ClientConfig_setDefaultEncryption(cc, certificate, privateKey, NULL, 0, NULL, 0); \\
@@ -572,7 +584,8 @@
UA_ByteString_clear(&privateKey);
#define INIT_UserPassword(User, Password) \\
- printf("TODO INIT_UserPassword %s,%s\\n", User, Password); \\
+ LogInfo("OPC-UA Init UserPassword %s,%s\\n", User, Password); \\ + UA_ClientConfig_setDefault(cc); \\ retval = UA_Client_connectUsername(client, uri, User, Password);
#define INIT_READ_VARIANT(ua_type, c_loc_name) \\
@@ -590,9 +603,11 @@
if(retval != UA_STATUSCODE_GOOD) {{
+ LogError("OPC-UA Init Failed %d\\n", retval); \\ UA_Client_delete(client);
#define READ_VALUE(ua_type, ua_type_enum, c_loc_name, ua_nodeid_type, ua_nsidx, ua_node_id) \\
@@ -725,6 +740,10 @@
"""%(path, path[:-2]) + modeldata.GenerateC(path, "test", config) + """
+int LogMessage(uint8_t level, char* buf, uint32_t size){ + printf("log level:%d message:'%.*s'", level, size, buf); int main(int argc, char *argv[]) {