Hi,
[Long message ahead]
we want to setup an application using RTnet:
Our setup is as follows:
gnulinuxpc-NIC -- crossed cable -- rtai/rtnet_lxrtpc-NIC
The gnu/linux pc is sending standard UDP packets on eth0 (measured data).
It is part of a "commercial" system, so putting rtai/rtnet on this pc is
not an option.
The rtai/rtnet_lxrtpc is pc that controls a motion control using lxrt.
Now we want this motion control application to use the measured data of
the gnu/linux pc.
Therefore, our thought was using rtnet_lxrt. We know that we won't get
true real-time performance in that way, but that's ok.
We have succeeded in setting up the lxrt environment and running the
examples/lxrt example (simpleserver and simpleclient) over the crossed UTP
cable.
Now, I had written a client program in gnu/linux to do the same.
=======================================================================
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/uio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
struct sockaddr_in local_addr;
struct sockaddr_in server_addr;
int main (int argc, char *argv[])
{
int sockfd = 0;
int ret = 0;
char msg[] = "This message was sent using gnu/linux.";
/* Set address structures to zero. */
memset(&local_addr, 0, sizeof(struct sockaddr_in));
memset(&server_addr, 0, sizeof(struct sockaddr_in));
printf("RTnet, simple linux client for LXRT server\n");
if (argc==4)
{
local_addr.sin_family = AF_INET;
local_addr.sin_addr.s_addr = INADDR_ANY;
local_addr.sin_port = htons(atoi(argv[1]));
server_addr.sin_family = AF_INET;
inet_aton(argv[2], &server_addr.sin_addr);
server_addr.sin_port = htons(atoi(argv[3]));
// server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
}
else
{
fprintf(stderr, "Usage: %s <local-port> <server-ip>
<server-port>\n",
argv[0]);
exit(1);
}
/* Create new socket. */
printf("Creating socket\n");
sockfd = socket(PF_INET, SOCK_DGRAM, 0);
if (sockfd<0) { perror("socket()"); exit(1); }
/* Bind socket to local address specified as parameter. */
printf("Binding socket\n");
ret = bind(sockfd, (struct sockaddr *) &local_addr,
sizeof(struct sockaddr_in));
if (ret<0) { perror("bind()"); exit(1); }
/* Specify destination address for socket; needed for send(). */
printf("Connecting socket\n");
ret = connect(sockfd, (struct sockaddr *) &server_addr,
sizeof(struct sockaddr_in));
if (ret<0) { perror("connect()"); exit(1); }
/* Send a message. */
printf("Sending...\n");
ret = send(sockfd, msg, sizeof(msg), 0);
printf("ret = %d\n", ret);
if (ret<0) { perror("send()"); exit(1); }
/* close socket */
printf("Closing socket\n");
close(sockfd);
return 0;
}
==========================================================================
But when running this program, the connection to the destination socket
fails. The program exits after trying to connect to the destination
socket with "cannot connect to network".
Is this to be expected, did we forget something obvious? Is the idea of
combining non-realtime and real-time in this way reasonable?
If not, are there other solutions for the goal we want to achieve?
Thx! (even for reading until here :)
klaas
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
RTnet-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/rtnet-users