Hi all,
for the first: I'm sorry for my
english...
I have linux kernel 2.6.10.0, RTAI 3.1 and rtnet
0.8.3.
I'm realizing a communication between a node master
and a node slave: slave send
n (in this case n=200) message to master with a
similar code:
///////////////////////////////////////////////////////////////// C O D E S L A V E /////////////////////////////////////////////////////////////////////// #include "stdio.h"
#include "stdlib.h" #include "time.h" . . . /* include */ . #define TIMERTICKS 500000 using namespace std;
RTIME periodo;
int main() {
static struct sockaddr_in
local_addr;
static struct sockaddr_in pc3_addr; static struct sockaddr_in pc2_addr; static struct sockaddr_in pc4_addr; int sockfd = 0; int ret = 0; int i=0; //contatore del ciclo del task int len; int nuovo = 1000; long long timeout; //variabile per gestire timeout della funzione "recv" timeout=2000000; //variabile per gestire timeout della funzione "recv" char buf[10]= "virtus"; RT_TASK *task; // nome task //################################################## A D D R E S S ####################################################### memset(&local_addr, 0, sizeof(struct sockaddr_in)); memset(&pc3_addr, 0, sizeof(struct sockaddr_in)); memset(&pc2_addr, 0, sizeof(struct sockaddr_in)); memset(&pc4_addr, 0, sizeof(struct sockaddr_in)); local_addr.sin_family = AF_INET; local_addr.sin_addr.s_addr = INADDR_ANY; local_addr.sin_port = htons(atoi("50000")); //setta porta locale pc3_addr.sin_family = AF_INET; pc3_addr.sin_addr.s_addr = inet_addr("10.0.0.3"); pc3_addr.sin_port = htons(atoi("3000")); //setta porta pc3 pc2_addr.sin_family = AF_INET; pc2_addr.sin_addr.s_addr = inet_addr("10.0.0.2"); pc2_addr.sin_port = htons(atoi("2000")); //setta porta pc3 pc4_addr.sin_family = AF_INET; pc4_addr.sin_addr.s_addr = inet_addr("10.0.0.4"); pc4_addr.sin_port = htons(atoi("40000")); mlockall(MCL_CURRENT|MCL_FUTURE); //############################################### S O C K E T ############################################################ sockfd = socket_rt(AF_INET, SOCK_DGRAM, 0); . . . //############################################### I O C T L ############################################################## ioctl_rt(sockfd, RTNET_RTIOC_EXTPOOL, &nuovo); //############################################ T A S K I N I T ########################################################## task = rt_task_init(4800, 1, 0,
0);
. . . rt_make_hard_real_time(); //########################################## B I N D ############################################# bind_rt(sockfd, (struct sockaddr *) &local_addr, sizeof(struct sockaddr_in)); //####################################### T I M E O U T ############################################# ioctl_rt(sockfd, RTNET_RTIOC_TIMEOUT, &timeout); //############################################### W H I L E ############################################################## while(i<200) { sendto_rt(sockfd, buf, sizeof(buf), 0, (struct sockaddr*)&pc3_addr, (socklen_t)sizeof(sockaddr)); i++; } //############################################### C L O S E ############################################################## rt_make_soft_real_time(); close_rt(sockfd); rt_task_delete(task); return 1; } //////////////////////////////////////////////////////////// E N
D C O D E
///////////////////////////////////////////////////////////////////
(the code for master is similar) I organise tdma.conf file in this mode:
# Primary master master: ip 10.0.0.3 cycle 1000 slot 0 200 slot 2 600 # Slave A
slave: ip 10.0.0.1 slot 10 0 slot 2 400 I would that the slave send two message (RT) to master in one cycle of
TDMA. I hope to read that, for example :
time event
0 synchronization TDMA
10 slave(10.0.0.3) send a message to master(10.0.0.1) 200 master receive a message from slave 400 slave send a message to master 600 master receive a message from slave 1000 synchronization TDMA 1010 slave(10.0.0.3) send a message to master(10.0.0.1) 1200 master receive a message from slave 1400 slave send a message to master 1600 master receive a message from slave 2000 synchronization TDMA . . . . . in the reality I have this situation:
time event
0 synchronization TDMA
10 slave(10.0.0.3) send a message to master(10.0.0.1) 200 master receive a message from slave 1000 synchronization TDMA 1010 slave(10.0.0.3) send a message to master(10.0.0.1) 1200 master receive a message from slave 2000 synchronization TDMA . . . . . I'm searching to do a control in an automation system and I need to send a message to master very quickly (100-150us for the moment), for this motif I do the tests above... I read in old mails (and I verify this) that a cycle of 600us is stressfull for the network,but for my situation I must to send a message in shorter time(100-150us), for this I would to poll a node more than one time in the cycle. thanks for all, Ciao
Andrea
|
- [RTnet-users] TDMA: management time slot Andrea Forni
- Re: [RTnet-users] TDMA: management time slot Jan Kiszka
- Re: Re: [RTnet-users] TDMA: management time slot Andrea Forni
- Re: [RTnet-users] TDMA: management time slot Jan Kiszka
- [RTnet-users] time slot matrix_df hotmail
- [RTnet-users] Re: time slot Jan Kiszka
- [RTnet-users] ping requests slave ... matrix_df hotmail
- [RTnet-users] Re: ping request... Jan Kiszka
- RE: [RTnet-users] Re: ping... matrix_df hotmail
- Re: [RTnet-users] Re: ping... Jan Kiszka
- [RTnet-users] Simpleserver... matrix_df hotmail