Monotosh Das wrote:
> Hi all,
> I am a new user of RTAI, RTnet and even Linux. 
> I am using rtai-3.4-cv rtnet-0.9.8 and linux-2.6.17.
> I want to *receive* UDP/IP data in a simple periodic fashion with sampling 
> time constraint of 1ms. I am using the RTAI lxrt in hard real time mode.
> I have followed the codes given in the example and put the 
> rt_dev_recv(sockfd, msgStr,sizeof(msgStr), MSG_DONTWAIT) in a periodic task.
> the segments are as follows:
> static struct sockaddr_in local_addr;static struct sockaddr_in 
> server_addr;static void *SendRcvFun(void *arg){    RT_TASK *handler;    
> //local handler    static struct {        unsigned long indx;        RTIME 
> time;    } msg = {0,0};        int sockfd = 0;        int ret    = 0;    char 
> msgStr[100] = "Hello world";    /* Set variables to zero.  */    
> memset(msgStr, 0, sizeof(msgStr));    memset(&local_addr, 0, sizeof (struct 
> sockaddr_in));    memset(&server_addr, 0, sizeof(struct sockaddr_in));
>     /* Check arguments and set addresses. */
>         local_addr.sin_family      = AF_INET;        
> local_addr.sin_addr.s_addr = INADDR_ANY;        local_addr.sin_port        = 
> htons(11000);//htons(atoi(11000));
>         server_addr.sin_family = AF_INET;        inet_aton("139.30.6.66", 
> &server_addr.sin_addr);        server_addr.sin_port = htons(11000);
>  
>     rtf_create(FIFO, 2000);    mlockall(MCL_CURRENT | MCL_FUTURE);    sockfd 
> = rt_dev_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);    if (sockfd < 0) {       
>  printf("Error opening socket: %d\n", sockfd);        exit(1);    }
>                             //    if (!(handler= 
> rt_task_init_schmod(nam2num("SRTSK"), 0, 0, 0,SCHED_FIFO, 0xFF))) {           
>      printf("CANNOT INIT SendRcvFun\n");        rt_dev_close(sockfd);         
>        exit(1);        }    rt_set_periodic_mode();    start_rt_timer(0);    
> period = start_rt_timer(nano2count(TIMERTICKS));    
> rt_task_make_periodic(handler, rt_get_time()+period, period);
>     rt_make_hard_real_time();    /* Bind socket to local address specified as 
> parameter. */    ret = rt_dev_bind(sockfd, (struct sockaddr *) &local_addr, 
> sizeof(struct sockaddr_in));    /* Specify destination address for socket; 
> needed for rt_socket_send(). */    rt_dev_connect(sockfd, (struct sockaddr *) 
> &server_addr, sizeof(struct sockaddr_in));    //ret = rt_dev_recv(sockfd, 
> msgStr, sizeof(msgStr), 0);    /* Send a message. */    rt_dev_send(sockfd, 
> msgStr, sizeof(msgStr), MSG_DONTWAIT);    //rt_dev_recv(sockfd, msgStr, 
> sizeof(msgStr), MSG_DONTWAIT);    //ret = rt_dev_sendto(sockfd, msgStr, 
> sizeof(msgStr), 0);    endSendRcvFun = 0;
>     while (!endSendRcvFun) {        rt_dev_send(sockfd, msgStr, 
> sizeof(msgStr), MSG_DONTWAIT);        ret = rt_dev_recv(sockfd, msgStr, 
> sizeof(msgStr), MSG_DONTWAIT);
>         msg.indx = ret;        msg.time = rt_get_time_ns();        
> rtf_put(FIFO, &msg, sizeof(msg));        //printk("h");        
> rt_task_wait_period();    }    stop_rt_timer();    rt_make_soft_real_time();  
>   rt_dev_close(sockfd);    rt_task_delete(handler);    rtf_destroy(FIFO);    
> printf("deletedTask\n");    return 0;}
>  
> Running this code gives an error that the LXRT has changed mode and getting 
> hanged. Could anybody please help me in this regard.
> _Monotosh Das_ 
> 

As you can see, your code is hopelessly line-wrapped. Please us a sane
mail client and don't post HTML.

Jan

Attachment: signature.asc
Description: OpenPGP digital signature

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
RTnet-users mailing list
RTnet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rtnet-users

Reply via email to