tests/python/c_code@c_ext/cfile.xml
changeset 1463 de311ffe3961
parent 1457 ff7cfce737ca
equal deleted inserted replaced
1462:9ee3a2dea7e8 1463:de311ffe3961
    12     <xhtml:p><![CDATA[
    12     <xhtml:p><![CDATA[
    13 volatile long Lock=0;
    13 volatile long Lock=0;
    14 volatile char PtoC=1,CtoP=2;
    14 volatile char PtoC=1,CtoP=2;
    15 
    15 
    16 extern long AtomicCompareExchange(long*,long, long);
    16 extern long AtomicCompareExchange(long*,long, long);
    17 extern char *PLCID;
    17 extern char *PLC_ID;
    18 
    18 
    19 int Simple_C_Call(int val){
    19 int Simple_C_Call(int val){
    20   return val+1;
    20   return val+1;
    21 }
    21 }
    22 
    22 
    33     *fromC=CtoP;
    33     *fromC=CtoP;
    34     AtomicCompareExchange((long*)&Lock, 1, 0);
    34     AtomicCompareExchange((long*)&Lock, 1, 0);
    35     res=1;
    35     res=1;
    36   }
    36   }
    37   printf("C code called by Python: toC %d fromC %d\n",toC,*fromC);
    37   printf("C code called by Python: toC %d fromC %d\n",toC,*fromC);
    38   printf("PLCID id %s\n",PLCID);
    38   printf("PLC_ID id %s\n",PLC_ID);
    39   return res;
    39   return res;
    40 }
    40 }
    41 
    41 
    42 int PLC_C_Call(char fromPLC, char *toPLC){
    42 int PLC_C_Call(char fromPLC, char *toPLC){
    43   /* PLC also have to be realy carefull not to 
    43   /* PLC also have to be realy carefull not to