Added beremiz.h header file for extensions
authorEdouard Tisserant
Tue, 26 Mar 2013 09:31:20 +0900
changeset 1001 3f966bbb3fba
parent 1000 d19af9341d28
child 1002 15c05ba95df4
Added beremiz.h header file for extensions
ProjectController.py
targets/__init__.py
targets/beremiz.h
targets/plc_main_head.c
targets/plc_main_tail.c
--- a/ProjectController.py	Tue Mar 26 00:35:52 2013 +0100
+++ b/ProjectController.py	Tue Mar 26 09:31:20 2013 +0900
@@ -894,6 +894,9 @@
         # Now we can forget ExtraFiles (will close files object)
         del ExtraFiles
         
+        # Header file for extensions
+        open(os.path.join(buildpath,"beremiz.h"), "w").write(targets.GetHeader())
+
         # Template based part of C code generation
         # files are stacked at the beginning, as files of confnode tree root
         for generator, filename, name in [
--- a/targets/__init__.py	Tue Mar 26 00:35:52 2013 +0100
+++ b/targets/__init__.py	Tue Mar 26 09:31:20 2013 +0900
@@ -70,6 +70,10 @@
 def GetTargetCode(targetname):
     return open(targets[targetname]["code"]).read()
 
+def GetHeader():
+    filename = path.join(path.split(__file__)[0],"beremiz.h")
+    return open(filename).read()
+
 def GetCode(name):
     filename = path.join(path.split(__file__)[0],name + ".c")
     return open(filename).read()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/targets/beremiz.h	Tue Mar 26 09:31:20 2013 +0900
@@ -0,0 +1,13 @@
+/* Beremiz' header file for use by extensions */
+
+#include "iec_types.h"
+
+#define LOG_LEVELS 4
+#define LOG_CRITICAL 0
+#define LOG_WARNING 1
+#define LOG_INFO 2
+#define LOG_DEBUG 3
+
+extern unsigned long long common_ticktime__;
+int LogMessage(uint8_t level, uint8_t* buf, uint32_t size);
+
--- a/targets/plc_main_head.c	Tue Mar 26 00:35:52 2013 +0100
+++ b/targets/plc_main_head.c	Tue Mar 26 09:31:20 2013 +0900
@@ -2,7 +2,7 @@
  * Head of code common to all C targets
  **/
 
-#include "iec_types.h"
+#include "beremiz.h"
 /*
  * Prototypes of functions provided by generated C softPLC
  **/
@@ -28,8 +28,6 @@
  *  Variable generated by C softPLC and plugins
  **/
 extern unsigned long greatest_tick_count__;
-/* Tick time provided by POUS.C */
-extern unsigned long long common_ticktime__;
 
 /* Effective tick time with 1ms default value */
 static long long Ttick = 1000000;
--- a/targets/plc_main_tail.c	Tue Mar 26 00:35:52 2013 +0100
+++ b/targets/plc_main_tail.c	Tue Mar 26 09:31:20 2013 +0900
@@ -6,12 +6,6 @@
  * LOGGING
  **/
 
-#define LOG_LEVELS 4
-#define LOG_CRITICAL 0
-#define LOG_WARNING 1
-#define LOG_INFO 2
-#define LOG_DEBUG 3
-
 #ifndef LOG_BUFFER_SIZE
 #define LOG_BUFFER_SIZE (1<<14) /*16Ko*/
 #endif