targets/Win32/plc_Win32_main.c
changeset 276 0d7426f26c6f
parent 247 655d5fef0204
child 280 f2ef79f3dba0
equal deleted inserted replaced
275:ff7c8eb3f362 276:0d7426f26c6f
    63 }
    63 }
    64 
    64 
    65 HANDLE PLC_thread;
    65 HANDLE PLC_thread;
    66 HANDLE debug_sem;
    66 HANDLE debug_sem;
    67 HANDLE wait_sem; 
    67 HANDLE wait_sem; 
    68 #define MAX_SEM_COUNT 10
    68 #define MAX_SEM_COUNT 1
    69 
    69 
    70 int startPLC(int argc,char **argv)
    70 int startPLC(int argc,char **argv)
    71 {
    71 {
    72 	unsigned long thread_id = 0;
    72 	unsigned long thread_id = 0;
    73 	/* Translate PLC's microseconds to Ttick nanoseconds */
    73 	/* Translate PLC's microseconds to Ttick nanoseconds */
   145 {
   145 {
   146 	WaitForSingleObject(wait_sem, INFINITE);
   146 	WaitForSingleObject(wait_sem, INFINITE);
   147 	return __debug_tick;
   147 	return __debug_tick;
   148 }
   148 }
   149  
   149  
   150 /* Called by PLC thread when debug_publish finished
   150 /* Called by PLC thread when debug_pu//blish finished
   151  * This is supposed to unlock debugger thread in WaitDebugData*/
   151  * This is supposed to unlock debugger thread in WaitDebugData*/
   152 void InitiateDebugTransfer()
   152 void InitiateDebugTransfer()
   153 {
   153 {
   154 	/* Leave debugger section */
       
   155 	ReleaseSemaphore(debug_sem, 1, NULL);
       
   156     /* remember tick */
   154     /* remember tick */
   157     __debug_tick = __tick;
   155     __debug_tick = __tick;
   158     /* signal debugger thread it can read data */
   156     /* signal debugger thread it can read data */
   159     ReleaseSemaphore(wait_sem, 1, NULL);
   157     ReleaseSemaphore(wait_sem, 1, NULL);
   160 }
   158 }