Made declaration from beremiz.h available to C pragmas in POUs. Added AtomicCompareExchange to beremiz.h
authorEdouard Tisserant
Wed, 24 Apr 2013 12:24:12 +0900
changeset 1050 56bef276055e
parent 1049 ebf53b5f0777
child 1051 847d68c3e7ff
Made declaration from beremiz.h available to C pragmas in POUs. Added AtomicCompareExchange to beremiz.h
NativeLib.xml
ProjectController.py
targets/beremiz.h
--- a/NativeLib.xml	Tue Apr 23 20:01:56 2013 +0900
+++ b/NativeLib.xml	Wed Apr 24 12:24:12 2013 +0900
@@ -74,8 +74,7 @@
           <ST>
 <![CDATA[IF TRIG AND NOT TRIG0 THEN
 {{
- extern int LogMessage(uint8_t, uint8_t*, uint32_t);
- LogMessage(GetFbVar(LEVEL),GetFbVar(MSG, .body),GetFbVar(MSG, .len));
+ LogMessage(GetFbVar(LEVEL),(char*)GetFbVar(MSG, .body),GetFbVar(MSG, .len));
 }}
 END_IF;
 TRIG0:=TRIG;
--- a/ProjectController.py	Tue Apr 23 20:01:56 2013 +0900
+++ b/ProjectController.py	Wed Apr 24 12:24:12 2013 +0900
@@ -602,6 +602,15 @@
             return False
         # transform those base names to full names with path
         C_files = map(lambda filename:os.path.join(buildpath, filename), C_files)
+
+        # prepend beremiz include to configuration header
+        H_files = [ fname for fname in result.splitlines() if fname[-2:]==".h" or fname[-2:]==".H" ]
+        H_files.remove("LOCATED_VARIABLES.h")
+        H_files = map(lambda filename:os.path.join(buildpath, filename), H_files)
+        for H_file in H_files:
+            with file(H_file, 'r') as original: data = original.read()
+            with file(H_file, 'w') as modified: modified.write('#include "beremiz.h"\n' + data)
+
         self.logger.write(_("Extracting Located Variables...\n"))
         # Keep track of generated located variables for later use by self._Generate_C
         self.PLCGeneratedLocatedVars = self.GetLocations()
--- a/targets/beremiz.h	Tue Apr 23 20:01:56 2013 +0900
+++ b/targets/beremiz.h	Wed Apr 24 12:24:12 2013 +0900
@@ -10,4 +10,5 @@
 
 extern unsigned long long common_ticktime__;
 int LogMessage(uint8_t level, char* buf, uint32_t size);
+long AtomicCompareExchange(long* atomicvar,long compared, long exchange);