All,

please find the code snippets below. I try to set up some real-time
network tests. If I send the buffer contents to 10.0.0.255 (broadcast)
using rt_dev_sendto, everything works fine and I get the bytes sent. As
soon as I try to send the packets to a specific receiver (let's say
10.0.0.20) rt_dev_sendto returns -113.

This is all UDP, so the problem can't be "connection" related...

Anyone seen this before?

TIA::Bernhard


[main...]

        /* Create the UDP socket */
        if (((sock = rt_dev_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))) == -1) {
                printf("Error opening UDP/IP socket: %d\n", sock);
                exit(1);
        }

        /* Enable broadcast on this socket */
        int broadcast = 1;
        if (rt_dev_setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &broadcast,
sizeof(broadcast)) == -1) {
                printf("Can't set broadcast options\n");
                rt_dev_close(sock);
                exit(1);
        }

        /* Local IP configuration */
        local_addr.sin_family      = AF_INET;
        local_addr.sin_port        = htons(PORT);
        local_addr.sin_addr.s_addr = INADDR_ANY;

        /* Remote IP settings */
        transmit_addr.sin_family      = AF_INET;
        transmit_addr.sin_port        = htons(PORT);
        transmit_addr.sin_addr.s_addr = inet_addr("10.0.0.20");
        //memset(transmit_addr.sin_zero, '\0', sizeof(transmit_addr.sin_zero));

        /* Configure and bind the socket */
        if (rt_dev_bind(sock, (struct sockaddr *) &local_addr, sizeof(struct
sockaddr_in)) == -1) {
                rt_printk("Can't configure the network socket");
                rt_dev_close(sock);
                exit(1);
        }
[...]



/** The sender task */
static void *sender(void *arg)
{
        /* Initialise the sender thread */
        if (!(Sender_Task = rt_thread_init(nam2num("TXTSK"), 0, 0, SCHED_FIFO,
CPUMAP))) {
                printf("Cannot initialise the sender task\n");
                exit(1);
        }

        rt_printk("FuCSnet: Transmitter task initialised\n");

        /* We need max determinism */
        rt_make_hard_real_time();

        /* Protect the next section */
        rt_sem_wait_barrier(barrier);

        /* Start delay */
        RTIME start = rt_get_time() + nano2count(200000000);

        /* Now run the show */
        if (0 != rt_task_make_periodic(Sender_Task, start,
nano2count(WORKCYCLE))) {
                printf("Make periodic failed\n");
                exit(1);
        }

        /* The sender loop */
        while(!end) {

                /* Store the current timestamp */
                sprintf(buffer_out, "%ld", (long) rt_get_time_ns());

                /* Brodcast the current timestamp */
                slen = rt_dev_sendto(sock, buffer_out, strlen(buffer_out), 0, 
(struct
sockaddr*)&transmit_addr, sizeof(transmit_addr));
                printf("sent %d bytes to %s\n", slen, 
inet_ntoa(transmit_addr.sin_addr));

                /* Wait until the next cycle is due */
                rt_task_wait_period();
        }

        /* Cleanup */
        rt_sem_wait_barrier(barrier);
        rt_make_soft_real_time();
        rt_thread_delete(Sender_Task);

        return 0;
}




-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
RTnet-users mailing list
RTnet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rtnet-users

Reply via email to