Hello everybody,

Has anybody successfully tested captured the sync frame on RTAI. I tried to run 
the tdma-api.c example on rtai (i modified the code a bit), but when i issue 
the 
rt_dev_ioctl(fd, RTMAC_RTIOC_WAITONCYCLE_EX, &waitinfo); 
it returns the "error code -38". Any idea why is that?

I set the machine to tdma master on rteth0 interface and the sync frame is 
transmited.
 I sniffed the lan with wireshark and it is there. The code i tested is pasted 
below.

Regards
Klemen

---------------------------------------------------------------------

#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <sys/mman.h>
#include <rtnet.h>
#include <rtmac.h>

int fd;

int main(int argc, char *argv[])
{
    RT_TASK                 *task;
    struct rtmac_waitinfo   waitinfo;
   
 int                     err;

    mlockall(MCL_CURRENT | MCL_FUTURE);

    fd = rt_dev_open("TDMA0", O_RDWR);
    if (fd < 0) {
        fprintf(stderr, "failed to open TDMA0\n");
        exit(1);
    }

    rt_make_hard_real_time();
 

    waitinfo.type = TDMA_WAIT_ON_SYNC;
    waitinfo.size = sizeof(waitinfo);


   while (1) {
        do
        {
            err = rt_dev_ioctl(fd, RTMAC_RTIOC_WAITONCYCLE_EX, &waitinfo);
            if (err) {
                fprintf(stderr, "failed to issue RTMAC_RTIOC_WAITONCYCLE_EX, "
                        "error code %d\n", err);
                rt_dev_close(fd);
                exit(1);
            }
        } while (waitinfo.cycle_no%100 != 0);


     
        printf("cycle #%ld, start %.9f s, offset %lld ns\n",
               waitinfo.cycle_no,
               (waitinfo.cycle_start+waitinfo.clock_offset)/1000000000.0,
               (unsigned long long)waitinfo.clock_offset);
    }

    rt_make_soft_real_time();

    rt_dev_close(fd);
    return(0);
}
------------------------------------------------------------------------------
Time is money. Stop wasting it! Get your web API in 5 minutes.
www.restlet.com/download
http://p.sf.net/sfu/restlet
_______________________________________________
RTnet-users mailing list
RTnet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rtnet-users

Reply via email to