Hello<br> <br>I am trying to send packets throw UDP sockets, on the board M5234BCC whose microcontroller is mcf 5234 (coldfire), with RTEMS<br>The Examples that comes with RTEMS works perfectly, including the loopback exaqmple.<br>
<br>Well The next code is the application that I am trying to make but doesn't send anything throw the cable ( I see with the commview program).<br><br>Could someone help me and tell me if is there some error?  Thanks!<br>
<br>The code:<br><br>/*<br> *  $Id: init.c,v 1.6 2007/04/05 15:22:58 joel Exp $<br> */<br><br>#include <bsp.h><br><br>#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER<br>#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER<br>
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE<br><br>#define CONFIGURE_EXECUTIVE_RAM_SIZE        (512*1024)<br>#define CONFIGURE_MAXIMUM_SEMAPHORES        20<br>#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES    20<br>#define CONFIGURE_MAXIMUM_TASKS            20<br>
<br>#define CONFIGURE_MICROSECONDS_PER_TICK    10000<br>#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 50<br>#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM<br><br>#define CONFIGURE_INIT_TASK_STACK_SIZE    (10*1024)<br>#define CONFIGURE_INIT_TASK_PRIORITY    50<br>
#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \<br>                                           RTEMS_NO_TIMESLICE | \<br>                                           RTEMS_NO_ASR | \<br>                                           RTEMS_INTERRUPT_LEVEL(0))<br>
<br>#define CONFIGURE_INIT<br>rtems_task Init(rtems_task_argument argument);<br><br>#include <rtems/confdefs.h><br><br>#include <rtems/rtems_bsdnet.h><br>#include <rtems/error.h><br>#include <stdio.h><br>
#include <stdarg.h><br>#include <stdlib.h><br>#include <string.h><br>#include <errno.h><br>#include <sys/socket.h><br>#include <netinet/in.h><br>#include <net/if.h><br>#include <sys/ioctl.h><br>
#include <sys/sockio.h><br><br>/*<br> * Network configuration<br> */<br>//extern void rtems_bsdnet_loopattach();<br>static struct rtems_bsdnet_ifconfig netdriver_config = {<br>    //"lo0",                          /* name */<br>
   // (int (*)(struct rtems_bsdnet_ifconfig *, int))rtems_bsdnet_loopattach, /* attach function */<br>     RTEMS_BSP_NETWORK_DRIVER_NAME,<br>     RTEMS_BSP_NETWORK_DRIVER_ATTACH,      <br>     NULL,                           /* link to next interface */<br>
    "138.100.48.254",                    /* IP address */<br>    "255.225.225.128",                    /* IP net mask */<br>     NULL,<br>     0,<br>};<br><br>struct rtems_bsdnet_config rtems_bsdnet_config = {<br>
    &netdriver_config,       /* Network interface */<br>    NULL,                   /* Use fixed network configuration */<br>    0,                      /* Default network task priority */<br>    0,                      /* Default mbuf capacity */<br>
    0,                      /* Default mbuf cluster capacity */<br>    "testSystem",           /* Host name */<br>    "<a href="http://nowhere.com">nowhere.com</a>",          /* Domain name */<br>    "138.100.48.129",            /* Gateway */<br>
    "138.100.48.253",            /* Log host */<br>    {"127.0.0.1" },         /* Name server(s) */<br>    {"127.0.0.1" },         /* NTP server(s) */<br>};<br><br>/*<br> * Thread-safe output routines<br>
 */<br>static rtems_id printMutex;<br>static void printSafe(const char *fmt, ...)<br>{<br>    va_list args;<br>    va_start(args, fmt);<br>    rtems_semaphore_obtain(printMutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);<br>    vprintf(fmt, args);<br>
    rtems_semaphore_release(printMutex);<br>    va_end(args);<br>}<br>#define printf printSafe<br><br><br><br><br>/*<br> * The real part of the client<br> */<br>static rtems_task clientWorker(int arg)<br>{<br>    <br>     int s;<br>
        struct sockaddr_in myAddr, farAddr,buffer;<br>        struct sockaddr hola;<br>        char cbuf[]={"HOLA DIEGO TE HABLA 5235"};<br>        int i;<br>        int f, flags;<br>        struct ifreq *device;    <br>
     struct ifconf data;<br>         unsigned long int broadaddr=0;<br>         data.ifc_len=sizeof(device);    <br>     memset(data.ifc_buf,0,data.ifc_len);<br>         <br>     flags = IFF_UP|IFF_RUNNING;<br>        <br>
      s=socket(AF_INET,SOCK_DGRAM,0);<br>    if (s < 0)<br>    { <br>        printf("Can't create client socket: %s\n", strerror(errno));<br>            return;<br>    }<br>//SIOCSIFBRDADDR<br>        printf("\nENTRA EN LA TAREA CLIENT WORKER\n");<br>
    //rtems_bsdnet_ifconfig(RTEMS_BSP_NETWORK_DRIVER_NAME, SIOCGIFDSTADDR, &device);    <br>    <br>        <br>     //buffer=(struct sockaddr_in)device->ifr_ifru.ifru_broadaddr;<br>    <br>    <br><br>      <br>    broadaddr=(device->ifr_ifru.ifru_addr.sa_data[0])<<24;<br>
     broadaddr|=(device->ifr_ifru.ifru_addr.sa_data[1])<<16;<br>     broadaddr|=(device->ifr_ifru.ifru_addr.sa_data[2])<<8;<br>     broadaddr|=(device->ifr_ifru.ifru_addr.sa_data[3]);<br>    <br>        /*<br>
    printf("\name:%s",device->ifr_name);<br>        printf("\n direccion de broadcast=%u  \n",broadaddr);<br>        */<br><br>    memset(&myAddr, 0, sizeof myAddr);<br>    myAddr.sin_family = AF_INET;<br>
//    myAddr.sin_port = htons(10100);<br>    myAddr.sin_port = 10100;<br>    myAddr.sin_addr.s_addr = inet_addr("138.100.48.254");<br>    <br>    if (bind(s, (struct sockaddr *)&myAddr, sizeof myAddr) < 0) <br>
    {<br>        printf("Can't bind socket: %s\n", strerror(errno));<br>            goto close;<br>       }<br>        memset(&farAddr, 0, sizeof farAddr);<br>    farAddr.sin_family = AF_INET;<br>//    farAddr.sin_port=htons(10001);<br>
    farAddr.sin_port=10001;<br>    farAddr.sin_addr.s_addr = inet_addr("138.100.48.253");<br>/***************************************************************/<br>    rtems_bsdnet_show_inet_routes ();<br>//     rtems_bsdnet_show_mbuf_stats ();<br>
//    rtems_bsdnet_show_if_stats ();<br>//    rtems_bsdnet_show_ip_stats ();<br>//    rtems_bsdnet_show_udp_stats ();<br>    <br>    <br>    printf("\n sending to host\n ");<br>    i=sendto(s,&cbuf,25,0,(struct sockaddr*)&farAddr,sizeof(struct sockaddr));<br>
    <br>    if (i>0)<br>    {<br>        printf("Enviado correctamente\n %d",i);<br>        <br>    }<br>    else<br>    {<br>        printf("Enviado Incorrectamente\n");<br>    }<br>  close:<br>    printf("Client closing connection.\n");<br>
    if (close(s) < 0)<br>    {<br>                printf("Can't close client task socket: %s\n", strerror(errno));<br>    }<br>}<br><br><br><br><br>rtems_task<br>Init (rtems_task_argument ignored)<br>{<br>
    int net_state=0;<br>    <br>    <br><br>     printf("\"Network\" initializing! HI DIEGO\n");<br>    net_state=rtems_bsdnet_initialize_network();<br>    printf("\"Network\" initialized! %d\n",net_state);<br>
<br>    printf("Try running client with no server present.\n");<br>    printf("Should fail with `connection refused'.\n");<br>    clientWorker(0);<br><br>}<br><br>