netrpc
Hello all,
I'm currently trying to port xrtai-lab to xenomai, inside of it
there's the netrpc interface used to make communication between tasks. However, there is no equivalent for Xenomai, which makes the port quite impossible ! So is there any chance to fulfill that, and with/or without RTNet ? To do that, it should have something to do with socket programming. Any experience encountered it is welcomed.
Thanks.
Quoted 6 lines · Michel He
Hello all,
I'm currently trying to port xrtai-lab to xenomai, inside of it
there's the netrpc interface used to make communication between tasks. However, there is no equivalent for Xenomai, which makes the port quite impossible !
Nothing is impossible. :)
Quoted 3 lines
So is there any chance to fulfill that, and with/or
without RTNet ? To do that, it should have something to do with socket programming. Any experience encountered it is welcomed.
Well, you could start with mapping the existing RTAI API calls in xrtai-lab on local Native calls. That will already give you a non-distributed port.
But there is also no magic behind netrpc. It just uses RTnet for remote calls, and that works for Xenomai at least equally well. You could simply write a RPC API extension for libnative (a pure user space job). That lib would do the routing, encapsulate and forward non-local calls to some sockets provided via the RTDM API.
BTW, the same should be feasible for a POSIX-based API extension, which would have the advantage of making the result easier portable to plain Linux.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Hello Jan,
Thank you for your answer so quickly. The last time, I find out
that the IPC (Xenomai) has strong correlation to the rpc implementation but it lacks the network addressing. If we look into the codes, we can not specifiy the remote destination in a variable like the sipc_address(not existing). So I imagine that AF_IPC is something purely local like the shared memory or the queues. Is it possible to make a remote connection in xenomai with the ipc protocols?
thanks
Jan Kiszka <[email protected]> a écrit :
Quoted 34 lines
Quoted 6 lines · Michel He
Hello all,
I'm currently trying to port xrtai-lab to xenomai, inside of it
there's the netrpc interface used to make communication between tasks. However, there is no equivalent for Xenomai, which makes the port quite impossible !Nothing is impossible. :)
Quoted 3 lines
So is there any chance to fulfill that, and with/or
without RTNet ? To do that, it should have something to do with socket programming. Any experience encountered it is welcomed.Well, you could start with mapping the existing RTAI API calls in xrtai-lab on local Native calls. That will already give you a non-distributed port.
But there is also no magic behind netrpc. It just uses RTnet for remote calls, and that works for Xenomai at least equally well. You could simply write a RPC API extension for libnative (a pure user space job). That lib would do the routing, encapsulate and forward non-local calls to some sockets provided via the RTDM API.
BTW, the same should be feasible for a POSIX-based API extension, which would have the advantage of making the result easier portable to plain Linux.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
Quoted 9 lines · Michel He
Hello Jan,
Thank you for your answer so quickly. The last time, I find out
that the IPC (Xenomai) has strong correlation to the rpc implementation but it lacks the network addressing. If we look into the codes, we can not specifiy the remote destination in a variable like thesipc_address(not existing). So I imagine thatAF_IPCis something purely local like the shared memory or the queues. Is it possible to make a remote connection in xenomai with the ipc protocols?
PF_RTIPC is primarily targeting local communication channels. If you think that this programming model is already sufficient to distribute xrtai-lab, it should also be possible to map it on other socket types like UDP (provided by RTnet) - and then you have node addressability.
Jan
Quoted 37 lines
thanks
Quoted 32 lines · Jan Kiszka
Quoted 6 lines · Michel He
Hello all,
I'm currently trying to port xrtai-lab to xenomai, inside of it
there's the netrpc interface used to make communication between tasks. However, there is no equivalent for Xenomai, which makes the port quite impossible !Nothing is impossible. :)
Quoted 3 lines
So is there any chance to fulfill that, and with/or
without RTNet ? To do that, it should have something to do with socket programming. Any experience encountered it is welcomed.Well, you could start with mapping the existing RTAI API calls in xrtai-lab on local Native calls. That will already give you a non-distributed port.
But there is also no magic behind netrpc. It just uses RTnet for remote calls, and that works for Xenomai at least equally well. You could simply write a RPC API extension for libnative (a pure user space job). That lib would do the routing, encapsulate and forward non-local calls to some sockets provided via the RTDM API.
BTW, the same should be feasible for a POSIX-based API extension, which would have the advantage of making the result easier portable to plain Linux.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
For message passing from task to task, I use the 3 available procedures rt_task_send(), rt_task_reply(), rt_task_receive().
The job is when one message emitted from the source to one destination, however the message can be catched by an other task (not the good correspondant). In Xenomai, when the message is NOT for a task, it couldn't be passed to a next task. Tasks can receive any message but not being able to relay it to the destination. (there's no such function mentionned inside the API doc).
I build an example. (cf code sample)
any help is welcome
code sample :
/*
*
* Created on: 15 avr. 2010
* Author: hemichel
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/io.h>
#include <sys/mman.h>
#include <native/task.h>
#include <native/queue.h>
#include <native/intr.h>
#define STACK_SIZE 8192
#define STD_PRIO 1
RT_TASK test_task_ptr,test_task2_ptr,test_task3_ptr; int int_count = 0;
int end = 0;
#define PEER_RATE_NS 10000000
// --s-ms-us-ns
RTIME task_period_ns = 1000000000llu;
void testtask(void *cookie) {
RT_TASK_MCB mcb_send, mcb_reply;
int flowid, i, rv;
unsigned char datasend[16];
unsigned char datareply[16];
int count = 0;
int ret;
unsigned long overrun;
ret = rt_task_set_periodic(NULL, TM_NOW, rt_timer_ns2ticks(task_period_ns));
if (ret) {
printf("error while set periodic, code %d\n",ret);
return;
}
mcb_send.opcode = 0x03;
datasend[0]='a';
mcb_send.data = datasend;
mcb_send.size = sizeof(datasend);
mcb_reply.size = sizeof(datareply);
mcb_reply.data = datareply;
while(!end){
ret = rt_task_set_mode(0, T_PRIMARY, NULL);
if (ret) {
printf("error while rt_task_set_mode, code %d\n",ret);
return;
}
ret = rt_task_wait_period(&overrun);
if (ret) {
printf("error while rt_task_wait_period, code %d\n",ret);
return;
}
count++;
printf("message from testtask: count=%d\n", count);
rv = rt_task_send(&test_task2_ptr,&mcb_send,&mcb_reply,PEER_RATE_NS);
if (rv < 0) printf("rt_task_send error\n");
else rt_printf("response mcb_reply=%d\n",mcb_reply.data[0]);
fflush(NULL);
}
}void testtask2(void *cookie) {
RT_TASK_MCB mcb_rcv, mcb_reply;
int flowid, i, rv;
unsigned char datareply[16];
int count = 12;
int ret;
unsigned long overrun;
ret = rt_task_set_periodic(NULL, TM_NOW, rt_timer_ns2ticks(task_period_ns));
if (ret) {
printf("error while set periodic, code %d\n",ret);
return;
}
while(!end){
ret = rt_task_set_mode(0, T_PRIMARY, NULL);
if (ret) {
printf("error while rt_task_set_mode, code %d\n",ret);
return;
}
ret = rt_task_wait_period(&overrun);
if (ret) {
printf("error while rt_task_wait_period, code %d\n",ret);
return;
}
mcb_rcv.data = (caddr_t)datareply;
mcb_rcv.size = sizeof(datareply);
flowid = rt_task_receive(&mcb_rcv,PEER_RATE_NS);
rt_printf("task 2: flowid=%d rcv.size=%d bytes to receive buf,
opcode=%d\n",\
flowid,mcb_rcv.size,mcb_rcv.opcode);
if(flowid >= 0)
{
if (mcb_rcv.opcode == 2) {
//this is mine
mcb_reply.opcode = 0x2;
mcb_reply.size = 1;
datareply[0]=count;
mcb_reply.data = datareply;
rt_task_reply(flowid, &mcb_reply);
rt_printf("replied from task2 to flowid=%d\n",flowid);
}
else {
rt_printf("task2 : not mined\n");
//how to relay the catched msg to next ?
}
}
fflush(NULL);
}
}void testtask3(void *cookie) {
RT_TASK_MCB mcb_rcv, mcb_reply;
int flowid, i, rv;
unsigned char datareply[16];
int count = 13;
int ret;
unsigned long overrun;
ret = rt_task_set_periodic(NULL, TM_NOW, rt_timer_ns2ticks(task_period_ns));
if (ret) {
printf("error while set periodic, code %d\n",ret);
return;
}
while(!end){
ret = rt_task_set_mode(0, T_PRIMARY, NULL);
if (ret) {
printf("error while rt_task_set_mode, code %d\n",ret);
return;
}
ret = rt_task_wait_period(&overrun);
if (ret) {
printf("error while rt_task_wait_period, code %d\n",ret);
return;
}
mcb_rcv.data = (caddr_t)datareply;
mcb_rcv.size = sizeof(datareply);
flowid = rt_task_receive(&mcb_rcv,PEER_RATE_NS);
rt_printf("task 3 : flowid=%d rcv.size=%d bytes to receive buf,
opcode=%d\n",\
flowid,mcb_rcv.size,mcb_rcv.opcode);
if(flowid >= 0)
{
if (mcb_rcv.opcode == 3) {
//this is mine
mcb_reply.opcode = 0x3;
mcb_reply.size = 1;
datareply[0]=count;
mcb_reply.data = datareply;
rt_task_reply(flowid, &mcb_reply);
rt_printf("replied from task3 to flowid=%d\n",flowid);
}
else {
rt_printf("task3 : not mined\n");
//how to relay the catched msg to next ?
}
}
fflush(NULL);
}
}Jan Kiszka <[email protected]> a écrit :
Quoted 3 lines
Well, you could start with mapping the existing RTAI API calls in xrtai-lab on local Native calls. That will already give you a non-distributed port.
Quoted 9 lines · Michel He
For message passing from task to task, I use the 3 available procedures
rt_task_send(),rt_task_reply(),rt_task_receive().The job is when one message emitted from the source to one destination, however the message can be catched by an other task (not the good correspondant). In Xenomai, when the message is NOT for a task, it couldn't be passed to a next task. Tasks can receive any message but not being able to relay it to the destination. (there's no such function mentionned inside the API doc).
Well, actually, no, there is none. Those services are aimed at being plain simple client/server primitives, which assume that you do know which server wants to receive your traffic. Providing a service to re-queue the request for others to pick it, does not seem the right approach, since there is no way you can tell whether the-other-guy will schedule in before the current server goes back to its receive point, unless you synchronize both servers, which would end up being quite silly. However, your application can emulate this behavior much more sanely, you don't need kernel support for that.
Btw, you should really remove rt_task_set_mode(...T_PRIMARY...) from your code, because this is unfortunately totally useless overhead. Not really your fault, T_PRIMARY should not have been provided this way.
Quoted 204 lines
I build an example. (cf code sample)
any help is welcome
code sample :
/*
*
* Created on: 15 avr. 2010
* Author: hemichel
*/#include <
stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/io.h>
#include <sys/mman.h>
#include <native/task.h>
#include <native/queue.h>
#include <native/intr.h>#define
STACK_SIZE8192
#defineSTD_PRIO1
RT_TASKtest_task_ptr,test_task2_ptr,test_task3_ptr; intint_count= 0;
int end = 0;#define
PEER_RATE_NS10000000
// --s-ms-us-ns
RTIMEtask_period_ns= 1000000000llu;void testtask(void *cookie) { RT_TASK_MCB mcb_send, mcb_reply; int flowid, i, rv; unsigned char datasend[16]; unsigned char datareply[16]; int count = 0; int ret; unsigned long overrun; ret = rt_task_set_periodic(NULL, TM_NOW, rt_timer_ns2ticks(task_period_ns)); if (ret) { printf("error while set periodic, code %d\n",ret); return; } mcb_send.opcode = 0x03; datasend[0]='a'; mcb_send.data = datasend; mcb_send.size = sizeof(datasend); mcb_reply.size = sizeof(datareply); mcb_reply.data = datareply; while(!end){ ret = rt_task_set_mode(0, T_PRIMARY, NULL); if (ret) { printf("error while rt_task_set_mode, code %d\n",ret); return; } ret = rt_task_wait_period(&overrun); if (ret) { printf("error while rt_task_wait_period, code %d\n",ret); return; } count++; printf("message from testtask: count=%d\n", count); rv = rt_task_send(&test_task2_ptr,&mcb_send,&mcb_reply,PEER_RATE_NS); if (rv < 0) printf("rt_task_send error\n"); else rt_printf("response mcb_reply=%d\n",mcb_reply.data[0]); fflush(NULL); } }void testtask2(void *cookie) { RT_TASK_MCB mcb_rcv, mcb_reply; int flowid, i, rv; unsigned char datareply[16]; int count = 12; int ret; unsigned long overrun; ret = rt_task_set_periodic(NULL, TM_NOW, rt_timer_ns2ticks(task_period_ns)); if (ret) { printf("error while set periodic, code %d\n",ret); return; } while(!end){ ret = rt_task_set_mode(0, T_PRIMARY, NULL); if (ret) { printf("error while rt_task_set_mode, code %d\n",ret); return; } ret = rt_task_wait_period(&overrun); if (ret) { printf("error while rt_task_wait_period, code %d\n",ret); return; } mcb_rcv.data = (caddr_t)datareply; mcb_rcv.size = sizeof(datareply); flowid = rt_task_receive(&mcb_rcv,PEER_RATE_NS); rt_printf("task 2: flowid=%d rcv.size=%d bytes to receive buf, opcode=%d\n",\ flowid,mcb_rcv.size,mcb_rcv.opcode); if(flowid >= 0) { if (mcb_rcv.opcode == 2) { //this is mine mcb_reply.opcode = 0x2; mcb_reply.size = 1; datareply[0]=count; mcb_reply.data = datareply; rt_task_reply(flowid, &mcb_reply); rt_printf("replied from task2 to flowid=%d\n",flowid); } else { rt_printf("task2 : not mined\n"); //how to relay the catched msg to next ? } } fflush(NULL); } }void testtask3(void *cookie) { RT_TASK_MCB mcb_rcv, mcb_reply; int flowid, i, rv; unsigned char datareply[16]; int count = 13; int ret; unsigned long overrun; ret = rt_task_set_periodic(NULL, TM_NOW, rt_timer_ns2ticks(task_period_ns)); if (ret) { printf("error while set periodic, code %d\n",ret); return; } while(!end){ ret = rt_task_set_mode(0, T_PRIMARY, NULL); if (ret) { printf("error while rt_task_set_mode, code %d\n",ret); return; } ret = rt_task_wait_period(&overrun); if (ret) { printf("error while rt_task_wait_period, code %d\n",ret); return; } mcb_rcv.data = (caddr_t)datareply; mcb_rcv.size = sizeof(datareply); flowid = rt_task_receive(&mcb_rcv,PEER_RATE_NS); rt_printf("task 3 : flowid=%d rcv.size=%d bytes to receive buf, opcode=%d\n",\ flowid,mcb_rcv.size,mcb_rcv.opcode); if(flowid >= 0) { if (mcb_rcv.opcode == 3) { //this is mine mcb_reply.opcode = 0x3; mcb_reply.size = 1; datareply[0]=count; mcb_reply.data = datareply; rt_task_reply(flowid, &mcb_reply); rt_printf("replied from task3 to flowid=%d\n",flowid); } else { rt_printf("task3 : not mined\n"); //how to relay the catched msg to next ? } } fflush(NULL); } }Quoted 3 lines · Jan Kiszka
Well, you could start with mapping the existing RTAI API calls in xrtai-lab on local Native calls. That will already give you a non-distributed port.
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 1 line
Philippe.