etherlab/runtime_etherlab.py
changeset 2365 bc07b9910cdb
parent 2363 9c7da6ff6a34
child 2366 d635680e4c2c
equal deleted inserted replaced
2364:4ea781f30555 2365:bc07b9910cdb
    64 
    64 
    65 def GetResult():
    65 def GetResult():
    66     global Result
    66     global Result
    67     return Result
    67     return Result
    68 
    68 
    69 KMSGPollThread=None
    69 KMSGPollThread = None
    70 StopKMSGThread=False
    70 StopKMSGThread = False
    71 
    71 
    72 
    72 
    73 def KMSGPollThreadProc():
    73 def KMSGPollThreadProc():
    74     """
    74     """
    75     Logs Kernel messages starting with EtherCAT
    75     Logs Kernel messages starting with EtherCAT
    76     Uses GLibc wrapper to Linux syscall "klogctl"
    76     Uses GLibc wrapper to Linux syscall "klogctl"
    77     Last 4 KB are polled, and lines compared to last
    77     Last 4 KB are polled, and lines compared to last
    78     captured line to detect new lines
    78     captured line to detect new lines
    79     """
    79     """
    80     global StopKMSGThread
    80     global StopKMSGThread
    81     libc=ctypes.CDLL("libc.so.6")
    81     libc = ctypes.CDLL("libc.so.6")
    82     klog = libc.klogctl
    82     klog = libc.klogctl
    83     klog.argtypes = [ctypes.c_int, ctypes.c_char_p, ctypes.c_int]
    83     klog.argtypes = [ctypes.c_int, ctypes.c_char_p, ctypes.c_int]
    84     klog.restype = ctypes.c_int
    84     klog.restype = ctypes.c_int
    85     s=ctypes.create_string_buffer(4*1024)
    85     s = ctypes.create_string_buffer(4*1024)
    86     last = None
    86     last = None
    87     while not StopKMSGThread:
    87     while not StopKMSGThread:
    88         l = klog(3, s, len(s)-1)
    88         l = klog(3, s, len(s)-1)
    89         log = s.value[:l-1]
    89         log = s.value[:l-1]
    90         if last :
    90         if last :