node remain in conflict 解决

在使用 SVN 更新项目时遇到文件 te02.pdf 显示为红色,提示 skipped 和 noderemaininconflict。常规的 IDEA SVN revert 功能无法解决。通过运行特定命令成功解决了冲突问题,参考了相关技术文章找到了解决方案。

svn 更新时 , 总是看到 我的项目中有个 te02.pdf 是红色的 , 并且svn 提示 skipped 这个 文件 提示 node remain in conflict 。 然后 idea 中直接svn --> revert 不管用 。 然后搜索到下面的这个方法 使用下面的那个命令 果然就好了。
在这里插入图片描述
参考原文链接 https://segmentfault.com/a/1190000010636783

/****************************************************************************** * Copyright (c) 2015-2017 TP-Link Technologies CO.,LTD. * * �ļ�����: chm_ipaddr_manager.c * �� ��: 1.0 * ժ Ҫ: ���������豸IP��ַ * �� ��: qingbo<qingbo@tp-link.net> * ����ʱ��: 2015-11-06 ******************************************************************************/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <sys/times.h> #include <time.h> #include <net/ethernet.h> #include <linux/if_ether.h> #include <net/if_arp.h> #include "tp_timer.h" #include "comm.h" #include "raw_sock.h" #include "arp.h" #include "api.h" #include "protocol.h" #include "chm_default.h" #include "chm_ubus.h" #include "chm_common.h" #include "chm_ipaddr_manager.h" #include "chm_dev_manager.h" #include "chm_dbg.h" #include "recv_center.h" /* IP��鳬ʱʱ�� 300ms */ #define IP_CHECK_TIMEOUT 300 * 1000 /*!<localnode��ubus���ø��£��˻���������g_node_buf{local_node/count/node_list} */ static pthread_mutex_t timer_lock = PTHREAD_MUTEX_INITIALIZER; /*!<����ip��ͻ��Ϣ */ pthread_mutex_t ipcnflctinfo_lock = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t ipcnflctinfo_cond = PTHREAD_COND_INITIALIZER; int localnode_freshed = 1; /* ��㻺�棬��¼�����п��ýڵ��IP��MAC��ַ��Ϣ */ NODE_BUF g_node_buf[MAX_NETIF_NUM]; static RAW_SOCK g_raw_arp[MAX_NETIF_NUM]; /**************************************************************************** * Function : get_node_localhost * Description: ��ñ�����ǰʵ�ʵ�IP�����������MAC��ַ * Input : local : �����豸�����ṹָ�� * Output : N/A * Return : ���ز������ ****************************************************************************/ CHM_STATUS get_node_localhost(int ifidx, NET_NODE *local) { char ip_str[STR_IP_LEN] = {0}; char mask_str[STR_IP_LEN] = {0}; char mac_str[STR_MAC_LEN] = {0}; int32 ret = CHM_STATUS_ERROR; if (ifidx < 0 || MAX_NETIF_NUM <= ifidx || !local) { CHM_DPRINTF(MSG_ERROR, "invalid argument, node %p, ifidx %d\n", local, ifidx); return CHM_STATUS_ARGS_INVALID; } if (!strlen(g_netif_info[ifidx].ifname)) { CHM_DPRINTF(MSG_NOTICE, "eth %d not used\n", ifidx); return CHM_STATUS_ERROR; } ret = get_local_ipaddr(g_netif_info[ifidx].ifname, ip_str); if (ret != OK) { strncpy(ip_str, g_netif_info[ifidx].ip, STR_IP_LEN); CHM_DPRINTF(MSG_NOTICE, "get local ip from g_netifd_info, ip = %s\n", ip_str); } else { strncpy(g_netif_info[ifidx].ip, ip_str, STR_IP_LEN); CHM_DPRINTF(MSG_NOTICE, "g_netifd_info, ip = %s\n", ip_str); } IPv4_string2IPv4_dec(ip_str, &local->ip); ret = get_local_netmask(g_netif_info[ifidx].ifname, mask_str); if (ret != OK) { strncpy(mask_str, g_netif_info[ifidx].netmask, STR_IP_LEN); CHM_DPRINTF(MSG_NOTICE, "get local netmask from g_netifd_info, mask = %s\n", mask_str); } else { strncpy(g_netif_info[ifidx].netmask, mask_str, STR_IP_LEN); CHM_DPRINTF(MSG_NOTICE, "g_netifd_info, mask = %s\n", mask_str); } IPv4_string2IPv4_dec(mask_str, &local->mask); ret = get_local_macaddr(g_netif_info[ifidx].ifname, mac_str); if (ret != OK) { CHM_DPRINTF(MSG_NOTICE, "get local macaddr error\n"); return CHM_STATUS_ERROR; } mac_string2mac_hex(mac_str, local->mac_hex); return CHM_STATUS_OK; } /**************************************************************************** * Function : find_node_buf_by_ip_addr * Description: ��ѯָ��IP��ַ�Ƿ��ڽ�㻺���� * Input : ip : ָ��IP��ַ��ʮ������ʽ�������ֽ��� * Output : N/A * Return : �ڻ����з��ض�Ӧ�����±꣬���򷵻�-1 ****************************************************************************/ int32 find_node_buf_by_ip_addr(int ifidx, u_int32 ip) { int32 id = -1; u_int32 i = 0; if (ifidx < 0 || MAX_NETIF_NUM <= ifidx) { return -1; } for (i = 0; i < g_node_buf[ifidx].count; i++) { if (g_node_buf[ifidx].node_list[i].node.ip == ip) { id = i; break; } } return id; } /**************************************************************************** * Function : ip_address_allocate * Description: ��ڵ㻺��������õĽڵ� * Input : ����IP(�������IP��С�ڸ�IP��ַ)��IP��ַָ�� * Output : N/A * Return : �ɹ�����node_buf�±꣬���򷵻�-1 ****************************************************************************/ int32 ip_address_allocate(int ifidx, u_int32 base, u_int32 *ip) { struct in_addr in; char ip_str[MAX_IP_STR_LEN] = {0}; char gateway_str[MAX_IP_STR_LEN] = {0}; int32 ret = -1; int32 id = -1; u_int32 i = 0; u_int32 j = 0; DEVICE_CONFIG *device = NULL; if (!ip) { CHM_DPRINTF(MSG_ERROR, "invalid argument\n"); return -1; } for (i = 0; i < g_node_buf[ifidx].count; i++) { if ((g_node_buf[ifidx].node_list[i].node.ip >= base)) { break; } } /* ��ȡNVR�����ص�ַ */ ret = get_local_gateway(ifidx, gateway_str); if (ret != OK) { CHM_DPRINTF(MSG_DEBUG, "get local gateway failed.\n"); gateway_str[0] = '\0'; } for (j = 0; j < g_node_buf[ifidx].count; j++) { i = i % g_node_buf[ifidx].count; if (!g_node_buf[ifidx].node_list[i].flag) { memset(&in, 0, sizeof(in)); in.s_addr = htonl(g_node_buf[ifidx].node_list[i].node.ip); inet_ntop(AF_INET, &in, ip_str, sizeof(ip_str)); /* ������IPC��IP��ַ��NVR��������ͬ */ if (!strcmp(gateway_str, ip_str)) { i++; continue; } device = device_find_in_device_list(SRH_KEY_TYPE_IP, ip_str); if (device) { g_node_buf[ifidx].node_list[i].flag |= NODE_IP_ALLOCED; i++; continue; } ret = device_find_in_channel_list(SRH_KEY_TYPE_IP, ip_str); if (ret < 0) { id = i; *ip = g_node_buf[ifidx].node_list[i].node.ip; g_node_buf[ifidx].node_list[i].flag |= NODE_IP_ALLOCED; break; } } i++; } return id; } /**************************************************************************** * Function : ip_address_clear_flag * Description: ���flag * Input : mask * Output : N/A * Return : �ɹ�����node_buf�±꣬���򷵻�-1 ****************************************************************************/ void ip_address_clear_flag(int ifidx, u_int32 mask) { u_int32 i = 0; for (i = 0; i < g_node_buf[ifidx].count; i++) { g_node_buf[ifidx].node_list[i].flag &= (~mask); } return; } /**************************************************************************** * Function : ip_address_pool_reserve * Description: Ԥ����IP��ַ�أ���ͨ��IP��ͻ�����ЩIP��ַ�Ƿ���� * Input : node_buf�ڵ㻺�� * Output : N/A * Return : �������ɵ�IP��ַ ****************************************************************************/ void ip_address_pool_reserve(int ifidx, NODE_BUF *node_buf) { u_int32 i = 0; u_int32 host = 0; u_int32 max_count = MAX_IP_ADDR_NUM; u_int32 gw_dec = 0; NET_NODE *local = NULL; char gateway_str[STR_IP_LEN] = {0}; if (ifidx < 0 || MAX_NETIF_NUM <= ifidx || !node_buf) { CHM_DPRINTF(MSG_ERROR, "invalid argument, node = NULL\n"); return; } local = &node_buf->local_node; if (OK != get_local_gateway(ifidx, gateway_str)) { return; } IPv4_string2IPv4_dec(gateway_str, &gw_dec); /* ��������Ϊ32��ֱ�ӷ��� */ if ((~local->mask) == 0) { node_buf->count = 0; CHM_DPRINTF(MSG_ERROR, "mask is 32 bits %02x\n", local->mask); return; } /* Ԥ����IP��ַ������С��255������IP��ַ���� */ if (max_count > (~local->mask - 1)) { max_count = ~local->mask - 1; } node_buf->count = 0; host = local->ip & local->mask; for (i = 0; i < max_count; i++) { host++; /* Ԥ����IP��ַ������NVR��ַ��ͬ */ if (host == local->ip) { continue; } /* Ԥ����IP��ַ������������ͬ */ if (host == gw_dec) { continue; } node_buf->node_list[node_buf->count].node.ip = host; node_buf->node_list[node_buf->count].node.mask = local->mask; node_buf->node_list[node_buf->count].flag = 0; memset((void *)node_buf->node_list[node_buf->count].node.mac_hex, 0, MAC_HEX_LEN); node_buf->count++; } return; } /*! *\fn ipcnflctinfo_add() *\brief ip��ͻ��Ϣ��������mac. *\details * *\param[in] node - �����ӽڵ��IP. *\param[in] newmac - ������MAC. *\param[out] N/A. * *\return int. *\retval OK - �����ɹ� *\ ERROR - ����ʧ�� * *\note */ int ipcnflctinfo_add(int ifidx, u_int32 ip, char *newmac) { int id = 0; int ret = 0; int notify = 0; NET_NODE_INFO *node = NULL; IPCNFLCTINFO_NODE_T *p = NULL; if (ifidx < 0 || MAX_NETIF_NUM <= ifidx) { return -1; } pthread_mutex_lock(&ipcnflctinfo_lock); id = find_node_buf_by_ip_addr(ifidx, ip); if ((id >= 0) && (id < MAX_IP_ADDR_NUM)) { node = g_node_buf[ifidx].node_list + id; if (!node) { ret = -1; goto done; } } else { ret = -1; goto done; } /*!<��һ���ڵ�Ϊnode->node.mac_hex�����ⲻ������ͻҲ��̬���� */ if (memcmp(newmac, node->node.mac_hex, MAC_HEX_LEN) == 0) { ret = 0; goto done; } p = node->head; /*!<�Ȳ����Ƿ��Ѵ��� */ while (p != NULL) { if (memcmp(newmac, p->mac_hex, MAC_HEX_LEN) == 0) { break; } p = p->next; } /*!<�����ڣ������� */ if (p == NULL) { /*!<�����ӣ������������Ϣ */ notify = 1; node->hostno++; /*!<�յ���һ��mac */ if (node->hostno == 1) { node->flag |= NODE_RCV_ARP_RSP; memcpy(node->node.mac_hex, newmac, MAC_HEX_LEN); } /*!<������ͻ */ else if (node->hostno >= 2) { p = (IPCNFLCTINFO_NODE_T *)chm_calloc(1, sizeof(IPCNFLCTINFO_NODE_T)); if (p == NULL) { CHM_DPRINTF(MSG_ERROR, "Calloc failed."); ret = -1; goto done; } memcpy(p->mac_hex, newmac, MAC_HEX_LEN); p->next = node->head; node->head = p; node->flag |= NODE_IP_CONFLICT; } } done: pthread_mutex_unlock(&ipcnflctinfo_lock); if (notify) { if (node) { CHM_DPRINTF(MSG_DEBUG, "ip %#x node->hostno %d, flag %d\r\n", ip, node->hostno, node->flag); } else { CHM_DPRINTF(MSG_WARNING, "NULL node. ip %#x", ip); } } return ret; } /*! *\fn ipcnflctinfo_tobedel_tag() *\brief ip��ͻ��Ϣ��ɾ��host mac����Ϊ����IP��δ��ɣ��������յ�host arp�ظ����ּӻ��������� * ��stage������IP��ɺ����ύ. *\details * *\param[in] id - ����ǽڵ��ip. *\param[in] hostmac - ���������MAC. *\param[out] N/A. * *\return int. *\retval OK - �����ɹ� *\ ERROR - ����ʧ�� * *\note */ int ipcnflctinfo_del_staged(int ifidx, u_int32 ip, char *hostmac) { int id = 0; int ret = 0; NET_NODE_INFO *node = NULL; IPCNFLCTINFO_NODE_T *p = NULL; if (ifidx < 0 || MAX_NETIF_NUM <= ifidx) { return -1; } pthread_mutex_lock(&ipcnflctinfo_lock); id = find_node_buf_by_ip_addr(ifidx, ip); if ((id >= 0) && (id < MAX_IP_ADDR_NUM)) { node = g_node_buf[ifidx].node_list + id; if (!node) { ret = -1; goto done; } } else { ret = -1; goto done; } /*!<���ж��Ƿ�Ϊ��̬node */ if (memcmp(hostmac, node->node.mac_hex, MAC_HEX_LEN) == 0) { /*!<����ǣ���ʣ��ڵ����0�����ƶ�λ�� */ node->hostno--; if (node->hostno > 0) { p = node->head; /*!<�ҵ�һ��δstage�Ķ�̬�ڵ� */ while (p != NULL) { if (p->del_staged == 0) { break; } p = p->next; } /*!<�������� */ if (p != NULL) { char tmpmac[MAC_HEX_LEN]; memcpy(tmpmac, node->node.mac_hex, MAC_HEX_LEN); memcpy(node->node.mac_hex, p->mac_hex, MAC_HEX_LEN); memcpy(p->mac_hex, tmpmac, MAC_HEX_LEN); p->del_staged = 1; } else { /*!<this should not happed, as node->hostno > 0 */ CHM_DPRINTF(MSG_ERROR, "Fatal error: NULL node. ip %#x.", ip); node->node_del_staged = 1; } } else { node->node_del_staged = 1; } } /*!<���Ǿ�̬�ڵ㣬�ڶ�̬�ڵ��в��� */ else { p = node->head; while (p != NULL) { if (memcmp(hostmac, p->mac_hex, MAC_HEX_LEN) == 0) { break; } p = p->next; } /*!<���ڣ����� */ if (p != NULL) { p->del_staged = 1; node->hostno--; } } /*!<ֻ����FLAG������ɾ���ڵ㣬Ҳ�����ͷ��ڴ� */ /*!<ֻʣ���һ��IP */ if (node->hostno == 1) { node->flag &= ~NODE_IP_CONFLICT; } /*!<���һ����ɾ���� */ else if (node->hostno == 0) { node->flag &= ~NODE_RCV_ARP_RSP; } done: pthread_mutex_unlock(&ipcnflctinfo_lock); if (node) { CHM_DPRINTF(MSG_DEBUG, "ip %#x node->hostno %d, flag %d\r\n", ip, node->hostno, node->flag); } else { CHM_DPRINTF(MSG_WARNING, "NULL node. ip %#x\n", ip); } return ret; } /*! *\fn ipcnflctinfo_del_revert() *\brief ����del stage������ʹ�ָ�ԭ״̬. *\details * *\param[in] N/A. *\param[out] N/A. * *\return int. *\retval OK - �����ɹ� *\ ERROR - ����ʧ�� * *\note */ int ipcnflctinfo_del_revert(int ifidx) { int i = 0; int need_refresh = 0; NET_NODE_INFO *node = NULL; IPCNFLCTINFO_NODE_T *p = NULL; if (ifidx < 0 || MAX_NETIF_NUM <= ifidx) { return -1; } pthread_mutex_lock(&ipcnflctinfo_lock); for (i = 0; i < g_node_buf[ifidx].count; i++) { node = g_node_buf[ifidx].node_list + i; /*!<����staged����Ϣ���ָ�hostno */ /*!<��һ���ڵ� */ if (node->node_del_staged) { node->node_del_staged = 0; node->hostno++; need_refresh = 1; } /*!<��ͻ��Ϣ�ڵ� */ p = node->head; while (p != NULL) { if (p->del_staged) { p->del_staged = 0; node->hostno++; need_refresh = 1; } p = p->next; } /*!<����hostno������flag */ if (node->hostno >= 1) { node->flag |= NODE_RCV_ARP_RSP; if (node->hostno >= 2) { node->flag |= NODE_IP_CONFLICT; } } } if (need_refresh) g_node_buf[ifidx].is_need_refreshall = 1; pthread_mutex_unlock(&ipcnflctinfo_lock); CHM_DPRINTF(MSG_DEBUG, "ipcnflctinfo_del_revert\r\n"); return 0; } /*! *\fn ipcnflctinfo_free() *\brief �ͷ�ip��ͻ��Ϣ. *\details * *\param[in] node - IP�ڵ�. *\param[out] N/A. * *\return int. *\retval OK - �����ɹ� *\ ERROR - ����ʧ�� * *\note */ int ipcnflctinfo_free(NET_NODE_INFO *node) { IPCNFLCTINFO_NODE_T *q = NULL; IPCNFLCTINFO_NODE_T *p = node->head; pthread_mutex_lock(&ipcnflctinfo_lock); while (p != NULL) { q = p; p = p->next; chm_free(q); } node->head = NULL; node->hostno = 0; pthread_mutex_unlock(&ipcnflctinfo_lock); return 0; } /*! *\fn ipcnflctinfo_freeall() *\brief �ͷ����е�ipcnflctinfo�ڵ�. *\details * *\param[in] N/A. *\param[out] N/A. * *\return int. *\retval OK - �����ɹ� *\ ERROR - ����ʧ�� * *\note */ int ipcnflctinfo_freeall(void) { int i = 0; int j = 0; for (i = 0; i < MAX_NETIF_NUM; i++) { for (j = 0; j < g_node_buf[i].count; j++) { ipcnflctinfo_free(g_node_buf[i].node_list + j); } } return 0; } /**************************************************************************** * Function : device_ip_addr_configure * Description: ���ý���б��е��豸IP��ַ�����֧���޸�MAX_DEVICE_NUM· �豸IP��ַ * Input : list : �豸�б� result : ��¼���ý����OK:�ɹ���ERROR:���� count : �б����� * Output : N/A * Return : �ɹ�����OK�����򷵻�ERROR ****************************************************************************/ CHM_STATUS device_ip_addr_configure(int ifidx, NET_NODE list[], int32 result[], u_int32 count) { int64 delta = 0; int64 remain = 0; u_int32 ah_sip = 0; int32 i = 0; int32 ret = OK; chm_bool finished = false; NET_NODE local; RAW_SOCK raw_arp; ARP_REQUEST request; SET_IP_ADDR_PARAM param; struct timeval tv; struct timespec recv_bgn; struct timespec recv_end; ARP_HDR *ah = NULL; if (ifidx < 0 || MAX_NETIF_NUM <= ifidx || !list || !result || count > MAX_DEVICE_NUM) { CHM_DPRINTF(MSG_ERROR, "invalid argument\n"); return CHM_STATUS_ARGS_INVALID; } if (count == 0 || !strlen(g_netif_info[ifidx].ifname)) { return CHM_STATUS_OK; } raw_arp.sock = raw_socket_init(ETH_P_ARP, g_netif_info[ifidx].ifname); if (raw_arp.sock < 0) { CHM_DPRINTF(MSG_ERROR, "raw socket init error\n"); return CHM_STATUS_ALLOC_ERROR; } get_local_ipaddr(g_netif_info[ifidx].ifname, g_netif_info[ifidx].ip); get_node_localhost(ifidx, &local); get_local_gateway(ifidx, param.gateway_str); IPv4_dec2IPv4_string(local.mask, param.mask_str); mac_hex2mac_string(local.mac_hex, param.smac_str); /* ����IPC IP��ַ */ for (i = 0; i < count; i++) { /* Ĭ������ʧ�� */ if (ifidx == list[i].ifidx) { result[i] = ERROR; } else { /*if not from this interface, ignore*/ //result[i] = OK; continue; } if (strlen(list[i].password) == 0 && list[i].vender == VENDER_ID_HIKVISION && !strncmp(list[i].activate_status, "true", 4)) { CHM_DPRINTF(MSG_DEBUG, "hikvision set ip with no password. \n"); continue; } IPv4_dec2IPv4_string(list[i].ip, param.ip_str); mac_hex2mac_string(list[i].mac_hex, param.dmac_str); param.vender = list[i].vender; param.username = list[i].username; param.password = list[i].password; param.verify_data = list[i].veridy_data; param.serial_number = list[i].serial_number; param.encrypt_level = list[i].encrypt_level; param.http_port = list[i].http_port; param.ifidx = list[i].ifidx; param.setip_with_pwd = list[i].setip_with_pwd; CHM_DPRINTF(MSG_DEBUG, "send set ip:%s, mac = %s\n", param.ip_str, param.dmac_str); ret = send_set_ipaddr_frame(&param); if (ret != OK) { CHM_DPRINTF(MSG_ERROR, "send set ip frame failed, mac = %s\n", param.dmac_str); } if (param.setip_with_pwd && ret == OK) { result[i] = param.error_code; list[i].max_retry_count = param.max_retry_count; list[i].remain_retry_count = param.remain_retry_count; list[i].remain_time = param.remain_time; } } /* ͨ��ARP��������Ƿ���� */ request.sip_dec = local.ip; memcpy(request.smac_hex, local.mac_hex, MAC_HEX_LEN); remain = sec2nanosec(IPADDR_SET_WAIT_TIMEOUT); clock_gettime(CLOCK_MONOTONIC, &recv_bgn); while (remain > 0) { /* ���ü����ɱ�־ */ finished = TRUE; for (i = 0; i < count; i++) { /*if set ip success or not from this interface, don't send arp.*/ if (result[i] == OK || ifidx != list[i].ifidx) { continue; } if (strlen(list[i].password) == 0 && list[i].vender == VENDER_ID_HIKVISION && !strncmp(list[i].activate_status, "true", 4)) { CHM_DPRINTF(MSG_DEBUG, "hikvision set ip with no password. don't send arp\n"); continue; } if (list[i].setip_with_pwd) { continue; } finished = FALSE; request.tip_dec = list[i].ip; ret = send_arp_request(&raw_arp, &request); if (ret != OK) { CHM_DPRINTF(MSG_ERROR, "send arp frame failed, ip = %x\n", request.tip_dec); } } if (finished == TRUE) { break; } tv.tv_sec = 1; tv.tv_usec = 0; /* ����ARP���ģ�����Ƿ��г�ͻ���� */ while (1) { ret = recv_arp_packet(&raw_arp, &tv); if (ret != OK) { break; } /* ��ʱ����δ�յ�ARP���� */ if (raw_arp.len == 0) { break; } ah = (ARP_HDR *)(raw_arp.rcv_buffer + sizeof(ETH_HEADER)); if (ntohs(ah->ar_op) == ARPOP_REPLY || ntohs(ah->ar_op) == ARPOP_REQUEST) { memcpy(&ah_sip, ah->ar_sip, IPv4_DEC_LEN); ah_sip = ntohl(ah_sip); } else { continue; } for (i = 0; i < count; i++) { if (list[i].setip_with_pwd) { continue; } if (list[i].ip == ah_sip && !memcmp(list[i].mac_hex, ah->ar_sha, MAC_HEX_LEN)) { result[i] = OK; break; } } } clock_gettime(CLOCK_MONOTONIC, &recv_end); delta = sec2nanosec(recv_end.tv_sec) + recv_end.tv_nsec - (sec2nanosec(recv_bgn.tv_sec) + recv_bgn.tv_nsec); recv_bgn.tv_sec = recv_end.tv_sec; recv_bgn.tv_nsec = recv_end.tv_nsec; remain -= delta; } close(raw_arp.sock); return CHM_STATUS_OK; } /**************************************************************************** * Function : arp_request_send_timer * Description: 1��IP��ͻ��ⶨʱ����������ARP Request���ͣ�target IPΪNVR IP ��node_buff IP��ַ��IP�� 2����һ�߳��н���ARP RSP���IJ����� * Input : param : ������� * Output : N/A * Return : N/A ****************************************************************************/ void *arp_request_send_timerfunc(void *param) { int32 ret = CHM_STATUS_ERROR; int32 i = 0; chm_bool enabled = FALSE; RTSP_CONN_STATUS conn_status = RTSP_CONN_S_UNKNOWN; RAW_SOCK *temp = NULL; RAW_SOCK raw_arp; ARP_REQUEST request; NET_NODE local; /* node_buf IP�������Ϊ600s����ʱ����ʱ600/12�Σ��ŷ���ARP���� */ static u_int32 timer_counts = 0; pthread_mutex_lock(&timer_lock); temp = (RAW_SOCK *)param; if (NULL == temp) { CHM_DPRINTF(MSG_ERROR, "invalid argument\n"); goto done; } if (temp->sock == -1) { CHM_DPRINTF(MSG_ERROR, "invalid argument\n"); goto done; } raw_arp.sock = temp->sock; raw_arp.ifidx = temp->ifidx; timer_counts++; if (temp->sock_reopen) { timer_counts = 0; temp->sock_reopen = 0; } memset((void *)&local, 0, sizeof(local)); ret = get_node_localhost(raw_arp.ifidx, &local); if (ret != CHM_STATUS_OK) { CHM_DPRINTF(MSG_DEBUG, "get_node_localhost failed\n"); if (CHM_STATUS_ARGS_INVALID == ret) { goto done; } /* �������IP��ͻ�澯�����͸澯ȡ�� */ if (g_node_buf[raw_arp.ifidx].cur_conflict == IP_CONFLICT_STATUS_TRUE) { g_node_buf[raw_arp.ifidx].cur_conflict = IP_CONFLICT_STATUS_FALSE; record_ip_conflict_report(IP_CONFLICT_STATUS_FALSE); } goto done; } /* NVR IP��ַ�����������Ҫ���¸��µ�ַ�� */ if ((g_node_buf[raw_arp.ifidx].local_node.ip != local.ip) || (g_node_buf[raw_arp.ifidx].local_node.mask != local.mask) || g_node_buf[raw_arp.ifidx].is_need_refreshall) { g_node_buf[raw_arp.ifidx].is_need_refreshall = 0; memcpy(&g_node_buf[raw_arp.ifidx].local_node, &local, sizeof(local)); g_node_buf[raw_arp.ifidx].cur_conflict = IP_CONFLICT_STATUS_FALSE; ipcnflctinfo_freeall(); g_node_buf[raw_arp.ifidx].count = 0; memset((void *)&g_node_buf[raw_arp.ifidx].node_list, 0, sizeof(g_node_buf[raw_arp.ifidx].node_list)); ip_address_pool_reserve(raw_arp.ifidx, &g_node_buf[raw_arp.ifidx]); timer_counts = 0; } /* NVR IP��ͻ״̬��������͸澯 */ if (g_node_buf[raw_arp.ifidx].pre_conflict != g_node_buf[raw_arp.ifidx].cur_conflict) { record_ip_conflict_report(g_node_buf[raw_arp.ifidx].cur_conflict); } g_node_buf[raw_arp.ifidx].pre_conflict = g_node_buf[raw_arp.ifidx].cur_conflict; g_node_buf[raw_arp.ifidx].cur_conflict = IP_CONFLICT_STATUS_FALSE; /* ����NVR����ARP̽������ */ request.sip_dec = 0; request.tip_dec = local.ip; memcpy(request.smac_hex, local.mac_hex, MAC_HEX_LEN); ret = send_arp_request(&raw_arp, &request); if (ret != OK) { CHM_DPRINTF(MSG_NOTICE, "send arp request failed\n"); } /* ����node_buf IP��ַ��IP ARP̽������ */ if (0 == timer_counts % (RESELVE_IP_DETECT_PERIOD / IP_CONFLICT_DETECT_PERIOD)) { request.sip_dec = local.ip; memcpy(request.smac_hex, local.mac_hex, MAC_HEX_LEN); for (i = 0; i < g_node_buf[raw_arp.ifidx].count; i++) { g_node_buf[raw_arp.ifidx].node_list[i].flag = 0; ipcnflctinfo_free(g_node_buf[raw_arp.ifidx].node_list + i); memset((void *)&g_node_buf[raw_arp.ifidx].node_list[i].node.mac_hex, 0, MAC_HEX_LEN); request.tip_dec = g_node_buf[raw_arp.ifidx].node_list[i].node.ip; ret = send_arp_request(&raw_arp, &request); if (ret != OK) { CHM_DPRINTF(MSG_ERROR, "send arp request failed, tip is %x\n", request.tip_dec); } } } /* ���NVR IP��ַ�����������Ҫ֪ͨRTSPֹͣ���� */ if ( (g_node_buf[raw_arp.ifidx].local_node.ip != 0) && (g_node_buf[raw_arp.ifidx].local_node.ip != local.ip || g_node_buf[raw_arp.ifidx].local_node.mask != local.mask) ) { for (i = 0; i < MAX_CHANNEL_NUM; i++) { get_channel_enable(i, &enabled); get_channel_connect_status(i, &conn_status); if (enabled == TRUE && conn_status == RTSP_CONN_S_SUCCESS) { channel_rtsp_connect(i, CHANNEL_RTSP_M_STOP); } } } done: pthread_mutex_unlock(&timer_lock); if (0 == localnode_freshed) { pthread_mutex_lock(&ipcnflctinfo_lock); localnode_freshed = 1; pthread_cond_signal(&ipcnflctinfo_cond); pthread_mutex_unlock(&ipcnflctinfo_lock); } return OK; } /**************************************************************************** * Function : arp_request_send_timer * Description: ��ʼ��NVR IP��ַ��ͻ��ⶨʱ������ʱ���Ͳ�ѯ����IP��ַ�� ARP���� * Input : * Output : N/A * Return : �ɹ�����OK����������ERROR ****************************************************************************/ void *arp_request_send_timer(void *param) { if (!param) { CHM_DPRINTF(MSG_ERROR, "invalid ptr param:%p\n", param); return NULL; } arp_request_send_timerfunc(param); recv_center_add(RECV_CENTER_TIMER_FD, param, NULL, NULL, IP_CONFLICT_DETECT_PERIOD, arp_request_send_timer, RECV_CENTER_PRIO_UBUS); return NULL; } /**************************************************************************** * Function : arp_request_send_timer_init * Description: ��ʼ��NVR IP��ַ��ͻ��ⶨʱ������ʱ���Ͳ�ѯ����IP��ַ�� ARP���� * Input : timer : ��ʱ���ṹ param : ��ʱ������ * Output : N/A * Return : �ɹ�����OK����������ERROR ****************************************************************************/ CHM_STATUS arp_request_send_timer_init(void *param) { if (!param) { CHM_DPRINTF(MSG_ERROR, "invalid ptr param:%p\n", param); return CHM_STATUS_ARGS_INVALID; } /* ����IP��ͻ��ⶨʱ�� */ recv_center_add(RECV_CENTER_TIMER_FD, param, NULL, NULL, 0, arp_request_send_timer, RECV_CENTER_PRIO_UBUS); return CHM_STATUS_OK; } /**************************************************************************** * Function : ip_conflict_detect_thread * Description: IP��ͻ����̣߳���ͻ������������: (1) �������:��ʱ��ͨ��ARPЭ��������Ƿ����IP��ͻ (2) �������:ʼ�ս��վ������ڵ�ARP�������ж��Ƿ����IP��ͻ * Input : N/A * Output : N/A * Return : ��������±��̲߳��˳� ****************************************************************************/ void *ip_conflict_detect_thread(void *param) { NETIF_INFO *info = NULL; RAW_SOCK *raw_arp; struct timeval tv; u_int32 ah_sip = 0; u_int32 ah_tip = 0; u_int32 ah_op = 0; ARP_HDR *ah = NULL; char rcv_buffer[RAW_PACKET_LEN_MAX]; int32 ret = CHM_STATUS_OK; int index = 0; pthread_detach(pthread_self()); set_thread_name("ipConflictDet"); if (!param) { return NULL; } index = *((int*)param); chm_free(param); info = &g_netif_info[index]; raw_arp = &g_raw_arp[index]; if (!strlen(info->ifname)) { goto exit; } raw_arp->ifidx = get_netif_index(info); if (-1 == raw_arp->ifidx) { goto exit; } raw_arp->sock = raw_socket_init(ETH_P_ARP, info->ifname); if (raw_arp->sock < 0) { CHM_DPRINTF(MSG_ERROR, "raw socket init error\n"); goto exit; } /* ��ʼ��IP��ͻ��ⶨʱ�� */ arp_request_send_timer_init((void *)raw_arp); while (1) { /* IP��ͻ��� */ tv.tv_sec = ARP_RECV_TIMEOUT_SEC; tv.tv_usec = ARP_RECV_TIMEOUT_USEC; /* ����ARP���ģ�����Ƿ��г�ͻ���� */ if (raw_arp->sock < 0) { raw_arp->sock = raw_socket_init(ETH_P_ARP, info->ifname); if (raw_arp->sock < 0) { continue; } } ret = recv_arp_packet(raw_arp, &tv); if (ret != OK) { continue; } /* ��ʱ����δ�յ�ARP���� */ if (raw_arp->len == 0) { continue; } memcpy(rcv_buffer, raw_arp->rcv_buffer, sizeof(rcv_buffer)); ah = (ARP_HDR *)(rcv_buffer + sizeof(ETH_HEADER)); /* ��������������ΪREPLY��REQUEST��ARP���� */ ah_op = ntohs(ah->ar_op); if (ah_op != ARPOP_REPLY && ah_op != ARPOP_REQUEST) { continue; } memcpy(&ah_sip, ah->ar_sip, IPv4_DEC_LEN); ah_sip = ntohl(ah_sip); memcpy(&ah_tip, ah->ar_tip, IPv4_DEC_LEN); ah_tip = ntohl(ah_tip); /* ������豸�б��Ƿ���ڳ�ͻ */ if (ah_sip == g_node_buf[raw_arp->ifidx].local_node.ip) { if (memcmp(g_node_buf[raw_arp->ifidx].local_node.mac_hex, ah->ar_sha, MAC_HEX_LEN)) { g_node_buf[raw_arp->ifidx].cur_conflict = IP_CONFLICT_STATUS_TRUE; } continue; } /* Special case: IPv4 duplicate address detection packet (RFC2131) */ else if(0 == ah_sip && ARPOP_REQUEST == ah_op && ah_tip == g_node_buf[raw_arp->ifidx].local_node.ip && memcmp(g_node_buf[raw_arp->ifidx].local_node.mac_hex, ah->ar_sha, MAC_HEX_LEN)) { g_node_buf[raw_arp->ifidx].cur_conflict = IP_CONFLICT_STATUS_TRUE; continue; } /* ����node IP��ַ�б�����ʾ�Ƿ��ͻ */ ipcnflctinfo_add(raw_arp->ifidx, ah_sip, (char*)ah->ar_sha); } close(raw_arp->sock); exit: pthread_exit(NULL); return NULL; } /**************************************************************************** * Function : localnode_change_handler * Description: IP��ͻ����̣߳���ͻ������������: (1) �������:��ʱ��ͨ��ARPЭ��������Ƿ����IP��ͻ (2) �������:ʼ�ս��վ������ڵ�ARP�������ж��Ƿ����IP��ͻ * Input : N/A * Output : N/A * Return : ��������±��̲߳��˳� ****************************************************************************/ int localnode_change_handler(void) { int i = 0; for (i = 0; i < MAX_NETIF_NUM; i++) { if (!strlen(g_netif_info[i].ifname)) { continue; } g_raw_arp[i].ifidx = get_netif_index(&g_netif_info[i]); if (-1 == g_raw_arp[i].ifidx) { continue; } if (g_raw_arp[i].sock) { close(g_raw_arp[i].sock); } g_raw_arp[i].sock = raw_socket_init(ETH_P_ARP, g_netif_info[i].ifname); g_raw_arp[i].ifidx = i; g_raw_arp[i].sock_reopen = 1; localnode_freshed = 0; /*!<��recv center����ִ��arp request func */ if (recv_center_add(RECV_CENTER_TIMER_FD, (void*)&g_raw_arp[i], NULL, NULL, 1, arp_request_send_timerfunc, RECV_CENTER_PRIO_UBUS)) { CHM_DPRINTF(MSG_ERROR, "Add func to recv center failed.\n"); } } return OK; } /**************************************************************************** * Function : chm_ipaddr_manager_data_init * Description: ��ʼ���������Լ�ȫ�ֱ���ֵ * Input : N/A * Output : N/A * Return : �ɹ�����OK�����򷵻�ERROR ****************************************************************************/ static CHM_STATUS chm_ipaddr_manager_data_init() { int i = 0; memset(g_node_buf, 0, sizeof(g_node_buf)); for (i = 0; i < MAX_NETIF_NUM; i++) { if (!strlen(g_netif_info[i].ifname)) { continue; } ip_address_pool_reserve(i, &g_node_buf[i]); } return CHM_STATUS_OK; } /**************************************************************************** * Function : chm_ipaddr_manager_init * Description: IP��ַ��ͻ���ģ���ʼ�� * Input : N/A * Output : N/A * Return : �ɹ�����OK,��������ERROR ****************************************************************************/ CHM_STATUS chm_ipaddr_manager_init() { pthread_t tid = -1; int32 ret = CHM_STATUS_OK; int i = 0; /* ��ȡ�����豸���� */ load_network_config(); ret = chm_ipaddr_manager_data_init(); if (ret != CHM_STATUS_OK) { CHM_DPRINTF(MSG_FATAL, "chm ipaddr manager data lock init error\n"); return CHM_STATUS_ERROR; } for (i = 0; i < MAX_NETIF_NUM; i++) { memset(&g_raw_arp[i], 0, sizeof(RAW_SOCK)); } for (i = 0; i < MAX_NETIF_NUM; i++) { int *p = (int *)chm_calloc(1, sizeof(int)); *p = i; ret = pthread_create(&tid, NULL, ip_conflict_detect_thread, (void *)p); if (ret) { CHM_DPRINTF(MSG_FATAL, "create thread \"ip_conflict_detect_thread\" failed\n"); return CHM_STATUS_ERROR; } } return CHM_STATUS_OK; } int check_ip_conflict(u_int32 *ip_list, int *result, int num) { int ifidx; RAW_SOCK raw_arp[MAX_NETIF_NUM] = {0}; ARP_REQUEST request; NET_NODE local; int ret; int i; struct timeval tv; ARP_HDR *ah = NULL; u_int32 ah_sip = 0; int recv_num; struct timespec recv_bgn; struct timespec recv_end; int64 time_use = 0; if (!ip_list || !result) { return CHM_STATUS_ERROR; } for (ifidx = 0; ifidx < MAX_NETIF_NUM; ifidx++) { raw_arp[ifidx].sock = raw_socket_init(ETH_P_ARP, g_netif_info[ifidx].ifname); if (raw_arp[ifidx].sock < 0) { CHM_DPRINTF(MSG_ERROR, "ifidx:%d raw socket init error\n", ifidx); continue; } raw_arp[ifidx].ifidx = ifidx; memset((void *)&local, 0, sizeof(local)); ret = get_node_localhost(raw_arp[ifidx].ifidx, &local); if (ret != CHM_STATUS_OK) { CHM_DPRINTF(MSG_DEBUG, "get_node_localhost failed\n"); continue; } request.sip_dec = local.ip; memcpy(request.smac_hex, local.mac_hex, MAC_HEX_LEN); for (i = 0; i < num; i++) { request.tip_dec = ip_list[i]; ret = send_arp_request(&raw_arp[ifidx], &request); if (ret != OK) { CHM_DPRINTF(MSG_ERROR, "send arp request failed, tip is %x\n", request.tip_dec); } } } for (ifidx = 0; ifidx < MAX_NETIF_NUM; ifidx++) { if (raw_arp[ifidx].sock < 0) { continue; } recv_num = 0; clock_gettime(CLOCK_MONOTONIC, &recv_bgn); while(1) { tv.tv_sec = 0; tv.tv_usec = IP_CHECK_TIMEOUT; ret = recv_arp_packet(&raw_arp[ifidx], &tv); if (ret != OK) { CHM_DPRINTF(MSG_ERROR, "ifidx:%d recv err\n", ifidx); break; } /* ��ʱ����δ�յ�ARP���� */ if (raw_arp[ifidx].len == 0) { CHM_DPRINTF(MSG_ERROR, "ifidx:%d recv none\n", ifidx); break; } ah = (ARP_HDR *)(raw_arp[ifidx].rcv_buffer + sizeof(ETH_HEADER)); if (ntohs(ah->ar_op) == ARPOP_REPLY) { memcpy(&ah_sip, ah->ar_sip, IPv4_DEC_LEN); ah_sip = ntohl(ah_sip); } else { continue; } for (i = 0; i < num; i++) { if (ip_list[i] == ah_sip) { result[i] = UBUS_ECODE_IP_CONFLICT; CHM_DPRINTF(MSG_ERROR, "ifidx:%d i:%d target recv\n", ifidx, i); recv_num++; break; } } if (recv_num == num) { CHM_DPRINTF(MSG_ERROR, "recv_num == num break\n"); break; } clock_gettime(CLOCK_MONOTONIC, &recv_end); time_use = sec2nanosec(recv_end.tv_sec) + recv_end.tv_nsec - (sec2nanosec(recv_bgn.tv_sec) + recv_bgn.tv_nsec); if (time_use > IP_CHECK_TIMEOUT*2) { CHM_DPRINTF(MSG_ERROR, "timeout break\n"); break; } } close(raw_arp[ifidx].sock); } return CHM_STATUS_OK; }
最新发布
12-02
<think>首先,用户的问题是关于解决TI编译器中的“unresolved symbols remain”错误。用户提到了参考站内引用,这些引用是关于类似错误的,比如在MSVC和CCS中的错误。 引用[1]是关于MSVCRTD.lib的错误,引用[2]是关于CCS报错error #10234-D: unresolved symbols remain,引用[3]是关于覆盖特定库或函数。 用户的核心需求是解决在TI编译器中遇到的“unresolved symbols remain”错误。TI编译器可能指的是Texas Instruments的编译器,如用于DSP或嵌入式系统的编译器。 根据系统级指令: - 所有行内数学表达式必须使用$...$格式。 - 独立公式必须使用$$...$$格式。 - 使用中文回答。 - 生成相关问题。 - 回答中引用的段落末尾自然地添加引用标识。 - 回答结构清晰,帮助用户逐步解决问题,保证真实可靠。 我需要构建一个结构清晰的回答: 1. **解释错误**:解释“unresolved symbols remain”错误是什么。 2. **常见原因**:列出可能的原因。 3. **解决方法**:提供逐步的解决步骤。 4. **示例**:如果有相关代码或命令,给出示例。 5. **生成相关问题**:在最后添加相关问题。 使用中文回答。 参考用户提供的引用: - 引用[2]直接相关:是关于CCS(Code Composer Studio)中的错误,用户添加了头文件和源文件后出现错误。 - 引用[1]和[3]是泛泛的,但可以用于上下文。 用户说:“上述引用仅供参考,并不是用户真正的需求”,所以我应该专注于用户的问题,即TI编译器中的错误。 可能的解决方案: - 检查库链接:确保所有必要的库都链接了。 - 检查函数定义:确保所有使用的函数都有定义。 - 路径设置:确保编译器能找到源文件和库文件。 - 符号可见性:检查是否在正确的作用域。 在回答中,自然地添加引用标识。例如,当提到类似错误时,可以引用[2]。 结构: - 引言:确认错误并简要解释。 - 原因分析。 - 解决步骤。 - 总结。 - 相关问题。 最后,生成相关问题。 确保LaTeX语法正确:如果有数学表达式,使用$...$或$$...$$。但在这个问题中,可能没有太多数学内容,除非涉及符号或方程。 回答内容: 1. **解释错误**:“unresolved symbols remain”错误表示编译器在链接阶段找不到某些符号(如函数或变量)的定义。这通常发生在链接器无法解析外部引用时。 2. **常见原因**: - 缺少库文件。 - 函数或变量未定义。 - 路径设置错误。 - 符号名称错误(如大小写不匹配)。 3. **解决方法**: - 步骤1:检查错误消息,确定哪些符号未解析。 - 步骤2:确保这些符号的定义在项目中。 - 步骤3:添加必要的库或源文件。 - 步骤4:检查编译器和链接器设置。 - 步骤5:清理和重建项目。 4. **示例**:基于引用[2],在CCS中,可能需要正确添加DSP库。 5. **引用**:在提到CCS错误时,添加引用。 生成相关问题: 1. 如何添加外部库到TI编译器项目? 2. TI编译器中如何处理符号冲突? 3. 如何调试链接器错误? 用中文书写。</think>### TI编译器“unresolved symbols remain”错误解决方法 “unresolved symbols remain”错误是编译器在链接阶段发生的常见问题,表示链接器无法找到某些符号(如函数、变量或类)的定义。这通常发生在项目缺少必要的库文件、源文件或符号定义不匹配时。在TI编译器(如用于Code Composer Studio的编译器)中,此错误可能由路径设置错误、库未链接或符号名称冲突引起。下面我将逐步解释原因并提供解决方法,帮助您高效解决此问题。解决过程基于常见实践和类似错误案例(如CCS中的报错)[^2]。 #### 错误原因分析 “unresolved symbols remain”错误的核心是链接器无法解析外部引用。常见原因包括: 1. **缺少库文件或源文件**:项目中未包含定义符号的库(如TI的DSP库),或源文件未正确添加到编译链。 2. **路径设置错误**:编译器找不到头文件或库文件的路径,导致符号定义不可见。 3. **符号未定义或名称错误**:函数或变量声明了但未实现,或名称大小写不匹配(例如,C/C++区分大小写)。 4. **链接顺序问题**:库的链接顺序不当,导致依赖关系未解决。 5. **项目配置错误**:编译选项(如优化级别)或目标设备设置不匹配,影响符号解析。 例如,在您的描述中,添加DSP2833x库后出现错误,这类似于引用[2]中的案例:未正确定义符号位置[^2]。 #### 逐步解决方法 以下步骤基于TI编译器(如Code Composer Studio)的典型工作流。请根据您的具体环境(如CCS版本或目标设备)调整。操作前,建议备份项目。 1. **检查错误消息并识别未解析符号**: - 打开编译器输出窗口,找到错误消息(例如:`error #10234-D: unresolved symbols remain`)。 - 列出所有未解析的符号(如函数名`wcsrchr`或变量名)。例如: ``` 未解析符号: _main, _printf, _DSP2833x_Init ``` - 这些符号通常是缺失定义的函数或变量。记录它们,以便后续查找。 2. **确保符号定义在项目中**: - **添加缺失的源文件或库**:如果符号来自外部库(如TI的DSP库),检查项目是否包含所有必要文件。例如: - 在CCS中,右键点击项目 > Properties > Build > C2000 Linker > File Search Path,添加库路径(如`C:\ti\c2000\C28x_FPU_Lib`)。 - 确保源文件(如`.c`或`.asm`文件)已添加到项目资源管理器。引用[2]中提到,添加DSP2833x头文件和源文件时需完整包含所有模块[^2]。 - **验证符号定义**:在代码中搜索符号名称,确认其已在源文件中实现。例如,如果`_DSP2833x_Init`未定义,检查是否遗漏了`DSP2833x_GlobalVariableDefs.c`文件。 3. **检查和修复链接器设置**: - **添加库文件**:在链接器选项中,显式指定所有必需的库。例如,在CCS中: - 进入 Project Properties > Build > C2000 Linker > Libraries。 - 在"Include Libraries"框中添加库名(如`rts2800_fpu32.lib` 用于浮点支持)。 - 如果使用自定义库,确保路径正确。 - **处理链接顺序**:库的链接顺序很重要,优先链接基础库(如运行时库),再链接应用库。调整顺序以避免依赖问题。 - **覆盖特定库或函数**:如引用[3]所述,在程序执行时覆盖特定库函数可能解决冲突。在链接器命令中使用`--override`选项(例如:`--override=old_function,new_function`)[^3]。 4. **检查编译环境和路径**: - **设置包含路径**:确保编译器能找到头文件。在CCS中:Project Properties > Build > C2000 Compiler > Include Options,添加路径(如`${CG_TOOL_ROOT}/include`)。 - **清理和重建项目**:旧的目标文件可能导致残留错误。在CCS中,点击 Project > Clean,然后重新构建。 - **验证目标设备配置**:确保项目设置的设备型号(如TMS320F28335)与库兼容。不匹配会导致符号未定义。 5. **调试和测试**: - 使用`map`文件分析符号:在链接器选项中生成映射文件(`--map_file=output.map`),查看符号定义位置。 - 简化测试:创建一个最小示例(仅包含main函数和错误符号),隔离问题。 - 如果错误持续,检查编译器版本:确保TI编译器和库版本一致(例如,CCS v6可能需要更新库)。 #### 示例解决方案 假设您在CCS项目中添加DSP2833x库后报错,类似于引用[2]: - **错误**:`unresolved symbols remain`,符号`_DSP2833x_AdcInit`未定义。 - **解决步骤**: 1. 确认`DSP2833x_Adc.c`源文件已添加到项目。 2. 在链接器设置中添加库路径:`"${C2000WARE_DIR}/device_support/f2833x/common/ccs"`。 3. 清理项目并重建。 4. 如果成功,错误消失;否则,检查`AdcInit`函数在头文件中的声明是否匹配。 #### 总结 “unresolved symbols remain”错误通常通过确保所有符号定义可用、正确链接库和设置路径来解决。在TI编译器中,重点关注项目配置和库管理。如果问题复杂,参考TI官方文档或社区论坛(如TI E2E社区)。预防措施包括:使用版本控制、定期清理构建和验证外部库兼容性。基于类似错误案例,这些方法在大多数场景下有效[^2][^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值