Hi,Cheng
Thank you so much for your reply.
>As I know from Xenomai documentation, the trank folder is for
>compatibility with Xenomai 2.
>And if you really want to write in Xenomai2 manner, you should
>include <native/alarm.h> maybe.
I have followed your advice and have tried it.I find that the interface
of
*rt_alarm_create *is not same bettween xenomai 2 and xenomai 3.
>> I complied source code with xenomai *native skin* for months.
>> I did not notice any complie error indeed and the
>> * final binary programs could run well*.
>> But, i encoutered some problems this time while the source
>> code had called *rt_alarm_create*(still complie the source code with
>> xenomai native skin).Though i have include the corresponding header
>> file(#include <alchemy/timer.h>),gcc complier still complained,
>> "*warning: implicit declaration of function ‘rt_alarm_create’*".
>> (For g++ complier, i got another kind of complie error:
>> " error: ‘rt_alarm_create’ was not declared in this scope".)
>> Ignore of the warning aforementioned,
>>
>>
>> I could complie the source code successfully with gcc indeed.The the
>> binary program could be started up.But you could not see any output
>> produced by the routine started by rt_alarm_create in the terminal.
* I still hope to dig deep. I wanna find out why the code
aforementioned *
*in the first email could be compiled successfully with gcc indeed (and
why *
*the **binary program **could be started up).*
* Do you have a interest in it?*
Best regards.
Look forward to hearing from you.
gbcwbz <[email protected]> 于2020年5月20日周三 上午11:58写道:
> Hi,
> As I know from Xenomai documentation, the trank folder is for
> compatibility with Xenomai 2.
> And if you really want to write in Xenomai2 manner, you should include
> <native/alarm.h> maybe.
>
> xeno-config --native --cflags
> -I/opt/xenomai-3.1/include/trank -D__XENO_COMPAT__
> -I/opt/xenomai-3.1/include/cobalt -I/opt/xenomai-3.1/include
> -D_GNU_SOURCE -D_REENTRANT -fasynchronous-unwind-tables -D__COBALT__
> -I/opt/xenomai-3.1/include/alchemy
>
> You wan to use Xenomai2 API, and included header <alchemy/alarm.h> for
> Xenomai3
>
> Regards
> Bryan Cheng
>
> 孙世龙 <[email protected]> 于2020年5月20日周三 上午11:19写道:
> >
> > Thank you for the reply.
> > >> I complied source code with xenomai *native skin* for months.
> > >> I did not notice any complie error indeed and the
> > >> * final binary programs could run well*.
> > >> But, i encoutered some problems this time while the source
> > >> code had called *rt_alarm_create*(still complie the source code with
> > >> xenomai native skin).Though i have include the corresponding header
> > >> file(#include <alchemy/timer.h>),gcc complier still complained,
> > >> "*warning: implicit declaration of function ‘rt_alarm_create’*".
> > >> (For g++ complier, i got another kind of complie error:
> > >> " error: ‘rt_alarm_create’ was not declared in this scope".)
> > >> Ignore of the warning aforementioned,
> > >>
> > >>
> > >> I could complie the source code successfully with gcc indeed.The the
> > >> binary program could be started up.But you could not see any output
> > >> produced by the routine started by rt_alarm_create in the terminal.
> >
> > > The compatibility wrappers are not very complete.
> >
> > But, there are wrappers for rt_alarm_create and rt_alarm_start
> indeed.
> > You are able to see the related source code on
> >
> https://gitlab.denx.de/Xenomai/xenomai/-/blob/v3.1/include/trank/native/alarm.h
> > and
> https://gitlab.denx.de/Xenomai/xenomai/-/blob/v3.1/lib/trank/native.c .
> >
> > Thank you for your attention to this question.
> > I would be thankful for any hint on it.
> >
> >
> >
> > gbcwbz <[email protected]> 于2020年5月20日周三 上午9:48写道:
> >>
> >> Hi,
> >> According to
> >>
> https://xenomai.org/documentation/xenomai-3/html/man1/xeno-config/index.html
> >>
> >> > --native and --skin=native are accepted for backward compatibility
> purpose. They are stricly equivalent to passing --alchemy --compat.
> >>
> >> You should not use --native in new xenomai3 programs, use --alchemy
> instead.
> >>
> >>
> >> > --compat
> >> > Enable the Xenomai 2.x compatibility mode for the API/skin
> selected. This switch affects the Alchemy and POSIX APIs, turning on a set
> of source-level compatibility wrappers when present.
> >>
> >> The compatibility wrappers are not very complete.
> >>
> >> Regards
> >> Bryan Cheng
> >>
> >> 孙世龙 via Xenomai <[email protected]> 于2020年5月19日周二 下午1:35写道:
> >> >
> >> > Hi,
> >> > I am using xenomai-3.1.
> >> > I complied source code with xenomai *native skin* for months.
> >> > I did not notice any complie error indeed and the
> >> > * final binary programs could run well*.
> >> > But, i encoutered some problems this time while the source
> >> > code had called *rt_alarm_create*(still complie the source code with
> >> > xenomai native skin).Though i have include the corresponding header
> >> > file(#include <alchemy/timer.h>),gcc complier still complained,
> >> > "*warning: implicit declaration of function ‘rt_alarm_create’*".
> >> > (For g++ complier, i got another kind of complie error:
> >> > " error: ‘rt_alarm_create’ was not declared in this scope".)
> >> > Ignore of the warning aforementioned,
> >> >
> >> >
> >> > *I could complie the source code successfully with gcc indeed.The the
> >> > binary program could be started up.But you could not see any output
> >> > produced by the routine started by rt_alarm_create in the terminal.*
> >> >
> >> >
> >> > *The source code, retated cmakelist and the complie error are listed
> at the
> >> > end of this email.*
> >> >
> >> > In addition, I noticed that the *usage Options of xeno-config*
> >> > shows it supports these skins:
> >> > posix|vxworks|psos|alchemy|rtdm|smokey|cobalt(*no native skin
> indeed*).
> >> > But,if you* pass "--skin=native" to xeno-config, it is ok*(no error
> >> > message outputs) and the final complied binary program could run
> >> > normally in the most cases.
> >> >
> >> >
> >> > * I have sloved this problem by use alchemy skin instead.I have
> thought
> >> > over and over, but i still could not understand.*
> >> > My heart would be full of thanks if you could do me a favor.
> >> >
> >> >
> >> > //source code
> >> > //filename: rt_alarmtest.c
> >> > #include <unistd.h>
> >> > #include <stdio.h>
> >> > #include <stdlib.h>
> >> > #include <alchemy/task.h>
> >> > #include <alchemy/timer.h>
> >> > #include <alchemy/alarm.h>
> >> >
> >> > static void alarm_handler(void *arg)
> >> > {
> >> > printf("enter alarm_routine\n");
> >> > }
> >> >
> >> > int main(int argc, char* argv[])
> >> > {
> >> > RT_TASK rtMainTask;
> >> > int ret = 0;
> >> > RT_ALARM alrm;
> >> >
> >> > rt_task_shadow(&rtMainTask, "main", 1, 0);
> >> > ret = rt_alarm_create(&alrm, "ALARM", alarm_handler, NULL);
> >> > if(ret != 0)
> >> > {
> >> > printf("rt_alarm_create returned error, ret=%d\n", ret);
> >> > }
> >> >
> >> > ret = rt_alarm_start(&alrm, 200000000ULL, 200000000ULL);
> >> > if(ret != 0)
> >> > {
> >> > printf("rt_alarm_start returned error, ret=%d\n", ret);
> >> > }
> >> >
> >> > printf("loop begin\n");
> >> > while(1)
> >> > {
> >> > // rt_printf("loop ");
> >> > sleep(1);
> >> > }
> >> > }
> >> >
> >> > //CMakeList.txt
> >> > cmake_minimum_required(VERSION 3.6)
> >> >
> >> > project(rt_alarmtest)
> >> >
> >> > set(SRCS rt_alarmtest.c)
> >> >
> >> > set(XENO_CONFIG /usr/xenomai/bin/xeno-config)
> >> > set(XENO_SKIN native)
> >> >
> >> > execute_process(COMMAND ${XENO_CONFIG} --${XENO_SKIN} --cflags
> >> > OUTPUT_VARIABLE XENO_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
> >> > execute_process(COMMAND ${XENO_CONFIG} --${XENO_SKIN} --ldflags
> >> > OUTPUT_VARIABLE XENO_LDFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
> >> >
> >> > message(STATUS "Xeno Skin: ${XENO_SKIN}")
> >> > message(STATUS "Xeno cflags: ${XENO_CFLAGS}")
> >> > message(STATUS "Xeno ldflags: ${XENO_LDFLAGS}")
> >> >
> >> > message(STATUS "Xeno source files: ${SRCS}")
> >> >
> >> > set(CMAKE_C_FLAGS "-g")
> >> >
> >> > set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${XENO_CFLAGS}")
> >> > message(STATUS "C_FLAGS: ${CMAKE_C_FLAGS}")
> >> > set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}
> ${XENO_LDFLAGS}")
> >> > add_executable(rt_alarm_test ${SRCS})
> >> >
> >> > //log of compiling the source code
> >> > #make
> >> > [ 50%] Building C object CMakeFiles/rt_alarm_test.dir/rt_alarm.c.o
> >> > /home/joy/xenomai/rt_alarm/rt_alarm.c: In function ‘main’:
> >> > /home/joy/xenomai/rt_alarm/rt_alarm.c:23:11: warning: implicit
> declaration
> >> > of function ‘rt_alarm_create’ [-Wimplicit-function-declaration]
> >> > ret = rt_alarm_create(&alrm, "ALARM", alarm_handler, NULL);
> >> > ^
> >> > [100%] Linking C executable rt_alarm_test
> >> > [100%] Built target rt_alarm_test
> >> >
> >> > //running log
> >> > $ ./rt_alarm_test
> >> > loop begin
> >> > #No more log, though the program is still running.
> >> > #No output could be seen from the routine which started by the
> >> > rt_alarm_create
> >> > #And you case see the increasement of XSC and CSW indeed.Why?
> >> >
> >> >
> >> > //some related information
> >> > joy@ubt-16-04-wk:~/xenomai$ cat /proc/xenomai/sched/stat
> >> > CPU PID MSW CSW XSC PF STAT %CPU
> NAME
> >> > 0 44552 38 40 121 0 000480c0 0.0
> main
> >> > 0 44554 2 52 58 0 00048042 0.0
> >> > timer-internal
> >> >
> >> > joy@ubt-16-04-wk:~/xenomai$ cat /proc/xenomai/sched/stat
> >> > CPU PID MSW CSW XSC PF STAT %CPU
> NAME
> >> > 0 44552 38 40 121 0 000480c0 0.0
> main
> >> > 0 44554 2 106 112 0 00048042 0.0
> >> > timer-internal
>