Please start new topics in new threads and do not reply to old ones.

Franz Engel wrote:
> Hello,
> 
> With the following code I can start an socket an I get no errors until the 
> initialization.
> 
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <sys/types.h>
> #include <sys/mman.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> #include <errno.h>
> 
> #include <sched.h>
> #include <netdb.h>
> #include <arpa/inet.h>
> #include <netinet/in.h>
> #include <rtnet.h>
> 
> #include <rtai_serial.h>
> #include <rtai_lxrt.h>
> 
> 
> static struct sockaddr_in local_addr;
> static struct sockaddr_in server_addr;
> 
> int main(int argc, char **argv)
> {
>     system("/sbin/insmod /lib/modules/2.6.31.8-rtai-1v/rtcfg.ko");
>     system("/sbin/insmod /lib/modules/2.6.31.8-rtai-1v/rtmac.ko");
>     system("/sbin/insmod /lib/modules/2.6.31.8-rtai-1v/tdma.ko");
>     system("/sbin/insmod /usr/realtime/modules/rtai_hal.ko");
>     system("/sbin/insmod /usr/realtime/modules/rtai_lxrt.ko");
>     system("/sbin/insmod /usr/realtime/modules/rtai_sem.ko");
>     system("/sbin/insmod /usr/realtime/modules/rtai_rtdm.ko");
>     system("/sbin/insmod /lib/modules/2.6.31.8-rtai-1v/rtnet.ko");
>     system("/sbin/insmod /lib/modules/2.6.31.8-rtai-1v/rtipv4.ko");
>     system("/sbin/insmod /lib/modules/2.6.31.8-rtai-1v/rtudp.ko");
>     system("/sbin/insmod /lib/modules/2.6.31.8-rtai-1v/rtpacket.ko");
>     system("/sbin/insmod /lib/modules/2.6.31.8-rtai-1v/rt_loopback.ko");
>     system("/sbin/insmod /lib/modules/2.6.31.8-rtai-1v/rt_8139too.ko");
> 
>     int sockfd = 0;
>     int ret    = 0;
>     int res;
>     RTIME period;
>     RT_TASK *lxrtnettsk;
> 
>     char msg[] = "This message was sent using rtnet_lxrt.";
>     printf("RTnet, simpleclient for LXRT\n");
> 
>     memset(&local_addr, 0, sizeof(struct sockaddr_in));
>     memset(&server_addr, 0, sizeof(struct sockaddr_in));
> 
>     local_addr.sin_family = AF_INET;
>     local_addr.sin_addr.s_addr = inet_addr("192.168.180.1");
>     local_addr.sin_port = htons(atoi("8080"));
> 
>     server_addr.sin_family = AF_INET;
>     server_addr.sin_addr.s_addr = inet_addr("192.168.180.2");
>     server_addr.sin_port = htons(atoi("8080"));
> 
> 
>     /* Lock allocated memory into RAM. */
>     mlockall(MCL_CURRENT|MCL_FUTURE);
> 
>     for(int i=1;i<sockfd;i++)
>     {
>           rt_dev_close(i);
>     }
> 
>     sockfd = rt_dev_socket(AF_INET, SOCK_DGRAM, 0);
>     //system("")
>     rt_dev_send(sockfd, msg, sizeof(msg), 0);
>     if (sockfd < 0)
>     {
>         printf("Error opening socket: %d\n", sockfd);
>         exit(1);
>     }
>     else
>     {
>          printf("Öffnet socket: %d\n", sockfd);
>     }
> 
>     /* Initialize a real time buddy. */
>     lxrtnettsk = rt_task_init(4800, 1, 0, 0);
>     if (NULL == lxrtnettsk) {
>         rt_dev_close(sockfd);
>         printf("CANNOT INIT MASTER TASK\n");
>         exit(1);
>     }
> 
>     /* Switch over to hard realtime mode. */
>     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(). */
>     int k = rt_dev_connect(sockfd, (struct sockaddr *) &server_addr, 
> sizeof(struct sockaddr_in));
>     printf("K: %i",k);
> 
>     /* Send a message. */
>     rt_dev_send(sockfd, msg, sizeof(msg), 0);
> 
>     /* Switch over to soft realtime mode. */
>     rt_make_soft_real_time();
> 
>     /* Close socket.
>      * Note: call must be in soft-mode because socket was created as non-rt! 
> */
>     rt_dev_close(sockfd);
> 
>     /* Delete realtime buddy. */
>     rt_task_delete(lxrtnettsk);
> 
>     return 0;
> }
> 
> 
> But when the programm try to send I get the following dmesg-output:
> [ 2328.237746] RTcfg: init real-time configuration distribution protocol
> [ 2328.247369] RTmac: init realtime media access control
> [ 2328.263020] RTmac/TDMA: init time division multiple access control 
> mechanism
> [ 2328.289233] RTnet: host 192.168.180.2 unreachable
> 
> And I receive nothing on my second computer. Also Wireshark doesn't trace 
> something. Furthermore, withe the command "./rtroute" I saw that threre stand 
> nothing in the routing table, beside "Hash    Destination    HW Address       
>  Device". So I get "ioctl: No route to host" back if I try to rtping the 
> second computer.
> 
> One more idea?

Now you lack the "rtroute add" that your previous code contains - or
some "rtroute solicit", or a full RTcfg setup.

Jan

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
_______________________________________________
RTnet-users mailing list
RTnet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rtnet-users

Reply via email to