# HG changeset patch # User Edouard Tisserant # Date 1523543490 -7200 # Node ID d0718654d9b06d87729723740f412bc03582b830 # Parent 28a369bb26767caa083b64827ab205f219e7a6f9 Added logging in Xenomai init phase. diff -r 28a369bb2676 -r d0718654d9b0 targets/Xenomai/plc_Xenomai_main.c --- a/targets/Xenomai/plc_Xenomai_main.c Thu Apr 12 16:29:43 2018 +0200 +++ b/targets/Xenomai/plc_Xenomai_main.c Thu Apr 12 16:31:30 2018 +0200 @@ -159,6 +159,15 @@ exit(0); } +#define _startPLCLog(text) \ + {\ + char mstr[] = text;\ + LogMessage(LOG_CRITICAL, mstr, sizeof(mstr));\ + goto error;\ + } + +#define FO "Failed opening " + #define max_val(a,b) ((a>b)?a:b) int startPLC(int argc,char **argv) { @@ -171,49 +180,55 @@ /*** RT Pipes creation and opening ***/ /* create Debug_pipe */ - goto error; if(rt_pipe_create(&Debug_pipe, "Debug_pipe", DEBUG_PIPE_MINOR, PIPE_SIZE) < 0) + _startPLCLog(FO "Debug_pipe real-time end"); PLC_state |= PLC_STATE_DEBUG_PIPE_CREATED; /* open Debug_pipe*/ - if((Debug_pipe_fd = open(DEBUG_PIPE_DEVICE, O_RDWR)) == -1) goto error; + if((Debug_pipe_fd = open(DEBUG_PIPE_DEVICE, O_RDWR)) == -1) + _startPLCLog(FO DEBUG_PIPE_DEVICE); PLC_state |= PLC_STATE_DEBUG_FILE_OPENED; /* create Python_pipe */ - goto error; if(rt_pipe_create(&Python_pipe, "Python_pipe", PYTHON_PIPE_MINOR, PIPE_SIZE) < 0) + _startPLCLog(FO "Python_pipe real-time end"); PLC_state |= PLC_STATE_PYTHON_PIPE_CREATED; /* open Python_pipe*/ - if((Python_pipe_fd = open(PYTHON_PIPE_DEVICE, O_RDWR)) == -1) goto error; + if((Python_pipe_fd = open(PYTHON_PIPE_DEVICE, O_RDWR)) == -1) + _startPLCLog(FO PYTHON_PIPE_DEVICE); PLC_state |= PLC_STATE_PYTHON_FILE_OPENED; /* create WaitDebug_pipe */ - goto error; if(rt_pipe_create(&WaitDebug_pipe, "WaitDebug_pipe", WAITDEBUG_PIPE_MINOR, PIPE_SIZE) < 0) + _startPLCLog(FO "WaitDebug_pipe real-time end"); PLC_state |= PLC_STATE_WAITDEBUG_PIPE_CREATED; /* open WaitDebug_pipe*/ - if((WaitDebug_pipe_fd = open(WAITDEBUG_PIPE_DEVICE, O_RDWR)) == -1) goto error; + if((WaitDebug_pipe_fd = open(WAITDEBUG_PIPE_DEVICE, O_RDWR)) == -1) + _startPLCLog(FO WAITDEBUG_PIPE_DEVICE); PLC_state |= PLC_STATE_WAITDEBUG_FILE_OPENED; /* create WaitPython_pipe */ - goto error; if(rt_pipe_create(&WaitPython_pipe, "WaitPython_pipe", WAITPYTHON_PIPE_MINOR, PIPE_SIZE) < 0) + _startPLCLog(FO "WaitPython_pipe real-time end"); PLC_state |= PLC_STATE_WAITPYTHON_PIPE_CREATED; /* open WaitPython_pipe*/ - if((WaitPython_pipe_fd = open(WAITPYTHON_PIPE_DEVICE, O_RDWR)) == -1) goto error; + if((WaitPython_pipe_fd = open(WAITPYTHON_PIPE_DEVICE, O_RDWR)) == -1) + _startPLCLog(FO WAITPYTHON_PIPE_DEVICE); PLC_state |= PLC_STATE_WAITPYTHON_FILE_OPENED; /*** create PLC task ***/ - if(rt_task_create(&PLC_task, "PLC_task", 0, 50, T_JOINABLE)) goto error; + if(rt_task_create(&PLC_task, "PLC_task", 0, 50, T_JOINABLE)) + _startPLCLog("Failed creating PLC task"); PLC_state |= PLC_STATE_TASK_CREATED; if(__init(argc,argv)) goto error; /* start PLC task */ - if(rt_task_start(&PLC_task, &PLC_task_proc, NULL)) goto error; + if(rt_task_start(&PLC_task, &PLC_task_proc, NULL)) + _startPLCLog("Failed starting PLC task"); return 0; diff -r 28a369bb2676 -r d0718654d9b0 targets/plc_main_head.c --- a/targets/plc_main_head.c Thu Apr 12 16:29:43 2018 +0200 +++ b/targets/plc_main_head.c Thu Apr 12 16:31:30 2018 +0200 @@ -35,6 +35,9 @@ /* Help to quit cleanly when init fail at a certain level */ static int init_level = 0; +/* Prototype for Logging to help spotting errors at init */ +int LogMessage(uint8_t level, char* buf, uint32_t size); + /* * Prototypes of functions exported by plugins **/