Visualizzazione dei risultati da 1 a 8 su 8
  1. #1

    undefined to reference

    Gentili utenti, ho un problema di compilazione di un protocollo, che ho modificato per scopi di tesi. L'errore che mi da, è : (file_dove_è_presente_l'errore): undefined to reference to 'rt_funzione'.
    Come posso risolvere ??

  2. #2

  3. #3

    risposta

    si, pultroppo che nn sono un programmatore ma un ingegnere elettronico, che deve risolvere questo problema di tesi.. e poi pensavo che in questo forum si poteva discutere con persone preparate su questo tipo di argomento..


    Appello a tutte quelle persone che possono aiutarmi sul tipo di errore "undefined reference to.."

  4. #4
    Moderatore di Linux e software L'avatar di francofait
    Registrato dal
    Aug 2001
    Messaggi
    13,559

    Re: risposta

    Originariamente inviato da tonuzzoo
    si, pultroppo che nn sono un programmatore ma un ingegnere elettronico, che deve risolvere questo problema di tesi.. e poi pensavo che in questo forum si poteva discutere con persone preparate su questo tipo di argomento..


    Appello a tutte quelle persone che possono aiutarmi sul tipo di errore "undefined reference to.."
    sei nel forum sbagliato , ti sposto in programmazine , comunque anche lì senza qualche dettaglio in più , non sono fratiindovino.

  5. #5
    Moderatore di Programmazione L'avatar di LeleFT
    Registrato dal
    Jun 2003
    Messaggi
    17,304

    Re: Re: risposta

    Originariamente inviato da francofait
    sei nel forum sbagliato , ti sposto in programmazine , comunque anche lì senza qualche dettaglio in più , non sono fratiindovino.
    Alcune di queste informazioni in più sono:

    1) In che linguaggio stai programmando?
    2) Un po' di codice per capire quali librerie utilizzi, come richiami le relative funzioni...


    Ciao.
    "Perchè spendere anche solo 5 dollari per un S.O., quando posso averne uno gratis e spendere quei 5 dollari per 5 bottiglie di birra?" [Jon "maddog" Hall]
    Fatti non foste a viver come bruti, ma per seguir virtute e canoscenza

  6. #6

    help!!

    Chiedo scusa per le mie scarsi informazioni!!
    Il mio ambiente di programmazione è linux, nello specifico, linux knoppix.
    Sto lavorando su il protocollo PTP (IEEE 1588), che è un protocollo di sincronizzazione (scritto in C), in fine, la modifica che ho apportato a questo protocollo, è nel file net.c , che è relativo alla trasmissione e ricezione dei vari messaggi..
    Le librerie incluse sono:
    codice:
    /* net.c */
    
    #include "../ptpd.h"
    #include <stdio.h>
    #include <stdlib.h>
    #include <fcntl.h>
    #include <sched.h>
    #include <netdb.h>
    #include <sys/types.h>
    #include <sys/mman.h>
    #include <sys/stat.h>
    #include <arpa/inet.h>
    #include <netinet/in.h>
    #include <asm/io.h>
    
    #include <rtai_lxrt.h>
    #include <rtnet.h>
    la parte relativa alle mie modifiche è riguardante la funzione netRecvEvent:

    codice:
    ssize_t netRecvEvent(Octet *buf, TimeInternal *time, NetPath *netPath)
    {
      ssize_t ret; 
      struct msghdr msg;
      struct iovec vec[1];
      struct sockaddr_in from_addr;  //struttura che specifica the client's address
      union {
          struct cmsghdr cm;  //struttura che viene utilizzata per ridurre al minimo il numero di parametri
          char control[CMSG_SPACE(sizeof(struct timeval))];
      } cmsg_un;
      struct cmsghdr *cmsg;
      struct timeval *tv;
      
      RT_TASK *lxrtnettsk;                      //
          
      vec[0].iov_base = buf;
      vec[0].iov_len = PACKET_SIZE;
      
      memset(&msg, 0, sizeof(msg));
      memset(&from_addr, 0, sizeof(from_addr));
      memset(buf, 0, PACKET_SIZE);
      memset(&cmsg_un, 0, sizeof(cmsg_un));
      
      msg.msg_name = (caddr_t)&from_addr;
      msg.msg_namelen = sizeof(from_addr);
      msg.msg_iov = vec;
      msg.msg_iovlen = 1;
      msg.msg_control = cmsg_un.control;
      msg.msg_controllen = sizeof(cmsg_un.control);
      msg.msg_flags = 0;
      
          /* Initialize a real time buddy. */
        lxrtnettsk = rt_task_init(4900, 1, 0, 0);
        if (NULL == lxrtnettsk) {
            rt_dev_close(netPath->eventSock);
            printf("CANNOT INIT MASTER TASK\n");
            exit(1);
        }
    
       	 /* Switch over to hard realtime mode. */
        	rt_make_hard_real_time();
    
    //	ret = rt_dev_recv(netPath->eventSock, msg, sizeof(msg), 0);
    //	ret = rt_dev_recv(netPath->eventSock, msg.msg_name, sizeof(&msg), 0);
    	ret = rt_dev_recv(netPath->eventSock, msg.msg_name, sizeof(&msg), 0);
    
    
      	/* Switch over to soft realtime mode. */
    	rt_make_soft_real_time();          // aggiunto !!
    
       	/* Delete realtime buddy. */
       	rt_task_delete(lxrtnettsk);     //aggiunto !!
    
    //  ret = recvmsg(netPath->eventSock, &msg, MSG_DONTWAIT);  // funzione che deve ricevere un messaggio da una modalità di connessione tipicamente da un socket
      if(ret <= 0)
      {
        if(errno == EAGAIN || errno == EINTR)   // files libreria standard d C che contiene definizioni di macro per la gestione delle situazioni di errori
          return 0;
        
        return ret;
      }
      
      if(msg.msg_flags&MSG_TRUNC)
      {
        ERROR("received truncated message\n");
        return 0;
      }
      
      /* get time stamp of packet */
      if(!time)
      {
        ERROR("null receive time stamp argument\n");
        return 0;
      }
      
      if(msg.msg_flags&MSG_CTRUNC)
      {
        ERROR("received truncated ancillary data\n");
        return 0;
      }
      
      if(msg.msg_controllen < sizeof(cmsg_un.control))
      {
        ERROR("received short ancillary data (%d/%d)\n",
          msg.msg_controllen, (int)sizeof(cmsg_un.control));
        
        return 0;
      }
      
      tv = 0;
      for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg))
      {
        if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_TIMESTAMP)
          tv = (struct timeval *)CMSG_DATA(cmsg);
      }
      
      if(tv)
      {
        time->seconds = tv->tv_sec;
        time->nanoseconds = tv->tv_usec*1000;
        DBGV("kernel recv time stamp %us %dns\n", time->seconds, time->nanoseconds);
      }
      else
      {
        /* do not try to get by with recording the time here, better to fail
           because the time recorded could be well after the message receive,
           which would put a big spike in the offset signal sent to the clock servo */
           
        DBG("no recieve time stamp\n");
        return 0;
      }
    
      return ret;
    }
    
    ssize_t netRecvGeneral(Octet *buf, NetPath *netPath)
    {
    
      RT_TASK *lxrtnettsk;                      //
    
      ssize_t ret;  //ssize_t , è un tipo di dato per rappresentare le dimenzione dei blocchi, che possono essere letti o scritti in una sola operazione
      //struct sockaddr_in addr; // struttura per impostare gli indirizzi
      //socklen_t addr_len = sizeof(struct sockaddr_in); // socklen_t--> richiamo di una applicazione UDP
    				//socket = punto di contatto tra un processo e una risorsa gestita
      //receive from, è una funzione di input/output di un socket
    
          /* Initialize a real time buddy. */
        lxrtnettsk = rt_task_init(4900, 1, 0, 0);
        if (NULL == lxrtnettsk) {
            rt_dev_close(netPath->eventSock);
            printf("CANNOT INIT MASTER TASK\n");
            exit(1);
        }
    
        /* Switch over to hard realtime mode. */
        rt_make_hard_real_time();
    
    
      	ret = rt_dev_recv(netPath->generalSock, buf, sizeof(buf), 0);        //
    
      	/* Switch over to soft realtime mode. */
       	 rt_make_soft_real_time();          // aggiunto !!
    
       	/* Delete realtime buddy. */
       	rt_task_delete(lxrtnettsk);     //aggiunto !!
    
    
    //  ret = recvfrom(netPath->generalSock, buf, PACKET_SIZE, MSG_DONTWAIT, (struct sockaddr *)&addr, &addr_len);
      if(ret <= 0)
      {
        if(errno == EAGAIN || errno == EINTR)  //erro rappresenta la libreria standard del C che contiene definizioni di macro per la gestione delle situazioni di errore.
          return 0;
        
        return ret;
      }  
     
      return ret;
    }
    
    ssize_t netSendEvent(Octet *buf, UInteger16 length, NetPath *netPath)
    {
      ssize_t ret;
      struct sockaddr_in addr; // struttura per impostare gli indirizzi
      
      addr.sin_family = AF_INET;
      addr.sin_port = htons(PTP_EVENT_PORT);
      addr.sin_addr.s_addr = netPath->multicastAddr;
      
      
        RT_TASK *lxrtnettsk;                      //
          /* Initialize a real time buddy. */
        lxrtnettsk = rt_task_init(4900, 1, 0, 0);
        if (NULL == lxrtnettsk) {
            rt_dev_close(netPath->eventSock);
            printf("CANNOT INIT MASTER TASK\n");
            exit(1);
        }
    
        /* Switch over to hard realtime mode. */
        rt_make_hard_real_time();
    
        ret = rt_dev_send(netPath->eventSock, buf, length, 0);
    //  ret = sendto(netPath->eventSock, buf, length, 0, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)); // sendto, è un dato di Imput/Output, dei socket
      if(ret <= 0)
        DBG("error sending multi-cast event message\n");
      
      if(netPath->unicastAddr)  //nethPath, consente di lavorare con file di vari percorssi, valori di stringa utilizzati per eseguire la totalità delle operazioni
      {
        addr.sin_addr.s_addr = netPath->unicastAddr;
        
    //    ret = sendto(netPath->eventSock, buf, length, 0, (struct sockaddr *)&addr, sizeof(struct sockaddr_in));  ////ssize_t , è un tipo di dato per rappresentare le dimenzione dei blocchi, che possono essere letti o scritti in una sola operazione
        ret = rt_dev_send(netPath->eventSock, buf, length, 0);
        if(ret <= 0)
          DBG("error sending uni-cast event message\n");  //DBG , sono dei tipi di flies, in formato Portable Executable, conteneti informazioni di debug in formato codeView
      }
      
      
      	/* Switch over to soft realtime mode. */
       	 rt_make_soft_real_time();          // aggiunto !!
    
       	/* Delete realtime buddy. */
       	rt_task_delete(lxrtnettsk);     //aggiunto !!
    
    
      return ret;
    }
    
    ssize_t netSendGeneral(Octet *buf, UInteger16 length, NetPath *netPath)
    {
      ssize_t ret;
      struct sockaddr_in addr;  // struttura per impostare gli indirizzi
      //'netRecvEvent';
      addr.sin_family = AF_INET;
      addr.sin_port = htons(PTP_GENERAL_PORT);
      addr.sin_addr.s_addr = netPath->multicastAddr;
    
        RT_TASK *lxrtnettsk;                      //
          /* Initialize a real time buddy. */
        lxrtnettsk = rt_task_init(4900, 1, 0, 0);
        if (NULL == lxrtnettsk) {
            rt_dev_close(netPath->eventSock);
            printf("CANNOT INIT MASTER TASK\n");
            exit(1);
        }
    
        /* Switch over to hard realtime mode. */
        rt_make_hard_real_time();
    
    //  ret = sendto(netPath->generalSock, buf, length, 0, (struct sockaddr *)&addr, sizeof(struct sockaddr_in));
        ret = rt_dev_send(netPath->generalSock, buf, length, 0);
    
    
    	if(ret <= 0)
        DBG("error sending multi-cast general message\n");
      
      if(netPath->unicastAddr)
      {
        addr.sin_addr.s_addr = netPath->unicastAddr;
        
    //    ret = sendto(netPath->eventSock, buf, length, 0, (struct sockaddr *)&addr, sizeof(struct sockaddr_in));
        ret = rt_dev_send(netPath->eventSock, buf, length, 0);
        if(ret <= 0)
          DBG("error sending uni-cast general message\n");
      }
      
    
      	/* Switch over to soft realtime mode. */
       	 rt_make_soft_real_time();          // aggiunto !!
    
       	/* Delete realtime buddy. */
       	rt_task_delete(lxrtnettsk);     //aggiunto !!
    
      return ret;
    }
    GRAZIE MILLE PER L'AIUTO!!

  7. #7
    Moderatore di Programmazione L'avatar di LeleFT
    Registrato dal
    Jun 2003
    Messaggi
    17,304

    Moderazione

    I tag CODE quando si posta del codice...

    Corretto e aggiornato.


    Ciao.
    "Perchè spendere anche solo 5 dollari per un S.O., quando posso averne uno gratis e spendere quei 5 dollari per 5 bottiglie di birra?" [Jon "maddog" Hall]
    Fatti non foste a viver come bruti, ma per seguir virtute e canoscenza

  8. #8
    Il relativo makefile, e gli errori che mi da: ()

    ---------Questo è il makefile modificato-----------------

    # Makefile for ptpd

    RM = rm -f

    #CFLAGS = -Wall

    CFLAGS = -Wall -I /usr/realtime/include/ -I /usr/realtime/include/rtdm -I /usr/realtime/include/asm -I/usr/realtime/include/I386 -I
    /usr/local/rtnet/include -I /usr/src/linux-2.6.17.11/include/

    LDFLAGS = -L /usr/realtime/lib -llxrt -lpthread -static

    #INCLUDES = -I /usr/realtime/include/ -I /usr/realtime/include/rtdm -I /usr/realtime/include/asm -I/usr/realtime/include/I386
    -I /usr/local/rtnet/include -I /usr/src/linux-2.6.17.11/include/ -L /usr/realtime/lib -llxrt -lpthread -static

    #LDFLAGS = -I /usr/realtime/include/ -I /usr/realtime/include/rtdm -I /usr/realtime/include/asm -I/usr/realtime/include/I386
    -I /usr/local/rtnet/include -I /usr/src/linux-2.6.17.11/include/ -L /usr/realtime/lib -llxrt -lpthread -static

    #CPPFLAGS = -DPTPD_DBG -DPTPD_NO_DAEMON

    PROG = ptpd
    OBJ = ptpd.o arith.o bmc.o probe.o protocol.o \
    dep/msg.o dep/net.o dep/servo.o dep/startup.o dep/sys.o dep/timer.o
    HDR = ptpd.h constants.h datatypes.h \
    dep/ptpd_dep.h dep/constants_dep.h dep/datatypes_dep.h

    .c.o: $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<

    all: $(PROG)

    $(PROG): $(OBJ)

    $(CC) $(LDFLAGS) -o $@ $(OBJ)

    $(OBJ): $(HDR)

    clean:
    $(RM) $(PROG) $(OBJ)

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.