--- a/etherlab/runtime_etherlab.py Thu Apr 04 14:32:02 2013 +0900
+++ b/etherlab/runtime_etherlab.py Thu Apr 04 17:50:43 2013 +0900
@@ -1,5 +1,6 @@
import subprocess,sys,ctypes
from threading import Thread
SDOAnswered = PLCBinary.SDOAnswered
SDOAnswered.restype = None
@@ -48,3 +49,44 @@
+def KMSGPollThreadProc(): + Logs Kernel messages starting with EtherCAT + Uses GLibc wrapper to Linux syscall "klogctl" + Last 4 KB are polled, and lines compared to last + captured line to detect new lines + libc=ctypes.CDLL("libc.so.6") + klog.argtypes = [ctypes.c_int, ctypes.c_char_p, ctypes.c_int] + klog.restype = ctypes.c_int + s=ctypes.create_string_buffer(4*1024) + while not StopKMSGThread: + log = log.rpartition(last)[2] + last = log.rpartition('\n')[2] + for msg in re.findall(r'<\d>\[\s*\d*\.\d*\]\s*(EtherCAT\s*.*)$', + PLCObject.LogMessage(msg) +def _runtime_etherlab_init(): + global KMSGPollThread, StopKMSGThread + KMSGPollThread = Thread(target = KMSGPollThreadProc) +def _runtime_etherlab_cleanup(): + global KMSGPollThread, StopKMSGThread