日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

DSP:6678开发板NDK网口通信完整实现(附源码)

發布時間:2025/3/15 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 DSP:6678开发板NDK网口通信完整实现(附源码) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

如果出現圖片打不開,或是顯示異常,請點擊下方鏈接閱讀原文!!!

DSP:6678開發板NDK網口通信完整實現(附源碼) - 子木的文章 - 知乎 https://zhuanlan.zhihu.com/p/85110735

?

//*************************************************************************************************

//寫在前面:

1.已經有很多前輩做過很優秀的記錄,本篇盡量講得詳細一點,能夠讓新手直接上手。

2.在整個調試過程中,會遇到各種各樣的問題,如果遇到問題請看第四部分,大部分問題應該能解決掉,不能解決的就評論區留言。

3.我的CCS安裝路徑是“C:\Ti\***”,后文如果出現,請對應你自己的安裝路徑

?

1.開發環境:CCS 5.4 、卓嵐TCP&UDP調試工具

2.開發平臺: Ti TMDSEVM6678LE(TMDSEVM6678LE是開發板,程序在其他6678板卡上也運行過)

3.需要工程源文件,ccs,調試助手的評論區留言!

?

//*************************************************************************************************//

目錄

一、原理

二、調試流程

三、程序執行流程與部分程序解讀

四、注意事項與遇到過的問題及解決方法

五、程序源碼

?

?

一、原理

1.通過UDP實現DSP與PC的通信,硬件上只需要用網線連接電腦與6678板卡即可,在程序上只是對TI已有的范例進行一些修改就能實現簡單的通信。

2.板卡上電后,CCS通過JTAG連接調試板卡,則會首先從GEL的StartUp( )函數開始執行初始化,JTAG連接后執行OnTargetConnect( )函數,OnTargetConnect( )會調用Global_Default_Setup_Silent()函數中的ddr3_setup_auto_lvl_1333(0);和 configSGMIISerdes();函數完成DDR和SGMII的初始化。

3.如果要使用NDK,建立的ccs工程必須是跑sys/bios的工程。所以需要安裝bios,我安裝的是bios_setupwin32_6_33_06_50(正常情況下,安裝ccs時已經安裝了,檢查下安裝目錄)

4. 在任何SOCKET應用程序建立之前,TCP/IP堆棧必須被正確的配置然后初始化。通常可以動態創建或者在DSP/BIOS中靜態創建一個堆棧初始化任務,不管應用程序當中建立了多少SOCKET,在整個系統中只能有一個堆棧初始化任務,并且該任務會成為整個網絡任務的唯一調度者,因此該任務在應用程序結束前不會返回。

堆棧初始化過程:(1)使用NC_SystemOpen()。該函數為所有網絡應用程序建立堆棧和內存環境;(2)使用CfgNew()。該函數會創建一個配置句柄,利用該句柄使用CfgAddEntry()函數可以添加DHCP、DNS、HTTP等服務和配置SOCKET緩沖區大小與ARP超時參數;(3)使用NC_NetStart()。該函數根據前面的配置參數啟動網絡,并創建三個回調函數,分別是網絡啟動時只運行一次的函數、網絡被關閉時只運行一次的函數、當IP地址改變時運行的函數。通常會在啟動函數里面創建自己的應用程序線程,在關閉函數里面刪除創建的應用程序線程。

?

?

二、調試過程

1.首先需要安裝MCSDK和NDK,一般來說安裝的CCS版本不是太低,都已經自動安裝這些組件了。(我記得ndk_2_21_01_38這個版本是有問題的,盡量不用這個,安裝了也沒關系,可以在設置里面修改成其他版本。)

我ccs安裝目錄下文件狀態

2.導入工程

在C:\Ti\mcsdk_2_01_02_06\examples\ndk\helloWorld路徑下是ndk例程的官方例程,

導入工程可以分為在它源文件上進行調試,也可以復制到其他地方調試,擔心破壞掉源文件,所以這里采用把文件復制到其他路徑下調試。

(1)開始導入工程

(2)工程文件選擇到helloWorld或者evmc6678l都可以,因為后面還得改。第3步是把文件復制到自己的工作路徑下,我的是workspace

(3)可以看到此時文件標識有感嘆號,這是由于路徑不對,如果編譯,會報錯:

? ?

Description Resource Path Location Type gmake: *** No rule to make target `C:/Ti/workspace/udpHello.c', needed by `udpHello.obj'. helloworld_evmc6678l Unknown C/C++ Problem

(4)在工程上右鍵,點擊properties

(5)在箭頭處雙擊,進去過file找到helloWorld.c等4個c文件的位置,也就是:C:\Ti\mcsdk_2_01_02_06\examples\ndk\helloWorld里面。就完成了修改路徑

(6)修改完之后是下圖的狀態

(7)此時右鍵工程選擇Rebuild Project,編譯就通過了。

?

3.配置仿真文件

由于需要硬件仿真,需要選擇仿真器類型,創建ccxml和gel文件,如果以前寫過相關的ccxml和gel,只要仿真器和板卡沒變,可以直接復制過來使用,就可跳過這一步,文章最后會提供我的ccxml和gel。

(1)右鍵工程,選擇新建Target Configuration File

(2)命名為evmc6678l.ccxml

(3)選擇仿真器型號和芯片

(4)配置gel文件

【Gel文件的執行時間一般在DSP connect target之后,在download代碼之前。因為gel文件通常會進行一些初始化的寄存器的設置,比如memory map,PLL和DDR初始化等。所以在download之前必須初始化這些。

gel文件的腳本都可以找到的。CCS5的版本可以在這個目錄下找到大部分EVM的gel腳本

ccsv5\ccs_base\emulation\boards

gel腳本類似于C語言函數,就是運行一些函數。比如DDR初始化函數。如果DDR沒有初始化,是無法將代碼download到DDR中去的。執行gel腳本有兩種,一種是用戶自己執行,另一種是CCS5自動將gel腳本關聯到相關的操作中,比如connect target就自動關聯了初始化PLL,初始化DDR的gel函數。

可以找個gel腳本看看,這樣更有助于理解。】

雙擊剛剛新建的evmc6678l.ccxml文件,再點擊圖中位置,

(5)gel文件在CCS安裝路徑下的\ccsv5\ccs_base\emulation\boards里可以找到對應芯片的gel文件,最后點擊save。6678是多核芯片,這里只用到了core0,所以給0核配置就可以了。也可以直接在路徑中復制過來。

4.文件處理好的狀態

5.IP設置

(1)由于是采取的靜態IP,需要把板卡上的撥碼開關設置成下圖這樣,(這個撥碼開關決定選擇dhcp還是靜態IP)

(2)需要將程序中IP部分進行相應修改

(3)為了穩定,上位機使用的是一個網上的助手軟件。也可以用QT或是VS編寫,后面的文章會說到。下圖是助手界面,可以看到相關信息,目的IP(DSP的ip)是169.254.198.113。所以需要在DSP程序中進行修改。

(4)將原來helloWorld.c里面的ip改為助手顯示的IP就行

原IP

修改后的IP段程序:

? ?

/****助手IP***/ char *HostName = "tidsp"; char *LocalIPAddr = "169.254.198.113"; char *LocalIPMask = "255.255.0.0"; // Not used when using DHCP char *GatewayIP = "169.254.1.1"; // Not used when using DHCP char *DomainName = "demo.net"; // Not used when using DHCP char *DNSServer = "0.0.0.0"; // Used when set to anything but zero

(5)因為使用的是靜態IP,不需要DHCP,在helloWorld.c里面再修改下面的一段程序

修改后的程序(注釋后加一個if(1)就行了):

? ?

// If the IP address is specified, manually configure IP and Gateway //#if defined(_SCBP6618X_) || defined(_EVMTCI6614_) || defined(DEVICE_K2H) || defined(DEVICE_K2K) /* SCBP6618x, EVMTCI6614, EVMK2H, EVMK2K always uses DHCP */ // if (0) //#else // if (!platform_get_switch_state(1)) //#endif if(1) { printf("IP address is specified.\n"); CI_IPNET NA; CI_ROUTE RT; IPN IPTmp;

6.硬件調試

(1)rebuild project之后連接好線。板卡需要電源線,仿真器,網線。

(2)點擊view里面的Target configurations

(3)在彈出的界面右鍵ccxml文件,launch selected configuration

(4)選擇0核,再點擊連接

連接之后的打印信息:

? ?

C66xx_0: GEL Output: Setup_Memory_Map... C66xx_0: GEL Output: Setup_Memory_Map... Done. C66xx_0: GEL Output: Connecting Target... C66xx_0: GEL Output: DSP core #0 C66xx_0: GEL Output: C6678L GEL file Ver is 2.005 C66xx_0: GEL Output: Global Default Setup... C66xx_0: GEL Output: Setup Cache... C66xx_0: GEL Output: L1P = 32K C66xx_0: GEL Output: L1D = 32K C66xx_0: GEL Output: L2 = ALL SRAM C66xx_0: GEL Output: Setup Cache... Done. C66xx_0: GEL Output: Main PLL (PLL1) Setup ... C66xx_0: GEL Output: PLL in Bypass ... C66xx_0: GEL Output: PLL1 Setup for DSP @ 1000.0 MHz. C66xx_0: GEL Output: SYSCLK2 = 333.3333 MHz, SYSCLK5 = 200.0 MHz. C66xx_0: GEL Output: SYSCLK8 = 15.625 MHz. C66xx_0: GEL Output: PLL1 Setup... Done. C66xx_0: GEL Output: Power on all PSC modules and DSP domains... C66xx_0: GEL Output: Security Accelerator disabled! C66xx_0: GEL Output: Power on all PSC modules and DSP domains... Done. C66xx_0: GEL Output: PA PLL (PLL3) Setup ... C66xx_0: GEL Output: PA PLL Setup... Done. C66xx_0: GEL Output: DDR3 PLL (PLL2) Setup ... C66xx_0: GEL Output: DDR3 PLL Setup... Done. C66xx_0: GEL Output: DDR begin (1333 auto) C66xx_0: GEL Output: XMC Setup ... Done C66xx_0: GEL Output: DDR3 initialization is complete. C66xx_0: GEL Output: DDR done C66xx_0: GEL Output: DDR3 memory test... Started C66xx_0: GEL Output: DDR3 memory test... Passed C66xx_0: GEL Output: PLL and DDR Initialization completed(0) ... C66xx_0: GEL Output: configSGMIISerdes Setup... Begin C66xx_0: GEL Output: SGMII SERDES has been configured. C66xx_0: GEL Output: Enabling EDC ... C66xx_0: GEL Output: L1P error detection logic is enabled. C66xx_0: GEL Output: L2 error detection/correction logic is enabled. C66xx_0: GEL Output: MSMC error detection/correction logic is enabled. C66xx_0: GEL Output: Enabling EDC ...Done C66xx_0: GEL Output: Configuring CPSW ... C66xx_0: GEL Output: Configuring CPSW ...Done C66xx_0: GEL Output: Global Default Setup... Done.

(5)load .out文件

加載成功后的打印信息:

? ?

C66xx_0: GEL Output: Invalidate All Cache... C66xx_0: GEL Output: Invalidate All Cache... Done. C66xx_0: GEL Output: GEL Reset... C66xx_0: GEL Output: GEL Reset... Done. C66xx_0: GEL Output: Disable all EDMA3 interrupts and events.

(6)運行DSP

運行的打印信息:

? ?

[C66xx_0] QMSS successfully initialized CPPI successfully initialized PA successfully initialized TCP/IP Stack 'Hello World!' Application TCP/IP Stack 'Hello World!' Application PASS successfully initialized Ethernet subsystem successfully initialized Ethernet eventId : 48 and vectId (Interrupt) : 7 Registration of the EMAC Successful, waiting for link up .. Network Added: If-1:169.254.198.113

(7)打開助手軟件

dsp的程序實現的功能是上位機向dsp發送消息,dsp收到后再回傳給上位機。下圖是打開助手后的狀態

(8)測試結果

下圖是由上位機發送一串數字,并顯示接收到的消息的狀態

?

三、程序執行流程與部分程序解讀

1.首先執行EVM_init()函數,也就是在main()函數之前執行,具體設置在一個*.cfg文件中

? ?

void EVM_init()

2.在main函數中執行BIOS_start(),并創建進程StackTest()

? ?

int main() { /* Start the BIOS 6 Scheduler */ BIOS_start (); }

3.在進程StackTest中執行了QMSS、CPPI、PA等的初始化,完成了基本網絡配置

? ?

int StackTest()

4.初始化platform

5.完成相應配置后啟動NetworkOpen服務后,關聯了dtask_udp_hello任務,等待UDP連接,并執行相關操作

? ?

static void NetworkOpen() { // Create our local server hHello = DaemonNew( SOCK_DGRAM, 0, 7, dtask_udp_hello, OS_TASKPRINORM, OS_TASKSTKNORM, 0, 1 ); }

6.程序開始執行udpHello.c

?

四、注意事項與遇到過的問題及解決方法

?

1.路徑不要包含非ASCII字符

2.dsp每次燒寫程序都需要斷電重連

3.程序如果出問題了,可以在程序中用printf("**** ");打印信息。但是printf開銷很大,占用資源,完整的程序中應該少用。

4.如果遇到關于platform而出現的編譯問題,參考這個鏈接:https://blog.csdn.net/u013368345/article/details/87905638

5. 正常來說,PC是無法識別DSP的,因為沒有交互,但是能夠正常通信。所以在電腦上ping的話,會顯示ping不通。

6.導入工程出錯,選擇狀態欄的project方式或者在project explore界面右鍵導入

?

?

五、程序源碼

1.helloWorld.c

? ?

/* * helloWorld_bios6.c * * TCP/IP Stack 'Hello World!' Example ported to use BIOS6 OS. * * Copyright (C) 2007, 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ //-------------------------------------------------------------------------- // IP Stack 'Hello World!' Example // // This is a skeleton application, intended to provide application // programmers with a basic Stack setup, to which they can start // adding their code. // // To test it as is, use with helloWorld.exe from \winapps directory // #include <stdio.h> #include <ti/ndk/inc/netmain.h> /* BIOS6 include */ #include <ti/sysbios/BIOS.h> /* Platform utilities include */ #include "ti/platform/platform.h" #include "ti/platform/resource_mgr.h" /* Platform Information - we will read it form the Platform Library */ platform_info gPlatformInfo; //--------------------------------------------------------------------------- // Title String // char *VerStr = "\nTCP/IP Stack 'Hello World!' Application\n\n"; // Our NETCTRL callback functions static void NetworkOpen(); static void NetworkClose(); static void NetworkIPAddr( IPN IPAddr, uint IfIdx, uint fAdd ); // Fun reporting function static void ServiceReport( uint Item, uint Status, uint Report, HANDLE hCfgEntry ); // External references extern int dtask_udp_hello(); //--------------------------------------------------------------------------- // Configuration // char *HostName = "tidsp"; char *LocalIPAddr = "169.254.198.113"; char *LocalIPMask = "255.255.0.0"; // Not used when using DHCP char *GatewayIP = "169.254.1.1"; // Not used when using DHCP char *DomainName = "demo.net"; // Not used when using DHCP char *DNSServer = "0.0.0.0"; // Used when set to anything but zero // Simulator EMAC Switch does not handle ALE_LEARN mode, so please configure the // MAC address of the PC where you want to launch the webpages and initiate PING to NDK */ Uint8 clientMACAddress [6] = {0x5C, 0x26, 0x0A, 0x69, 0x44, 0x0B}; /* MAC address for my PC */ /************************************************************************* * @b EVM_init() * * @n * * Initializes the platform hardware. This routine is configured to start in * the evm.cfg configuration file. It is the first routine that BIOS * calls and is executed before Main is called. If you are debugging within * CCS the default option in your target configuration file may be to execute * all code up until Main as the image loads. To debug this you should disable * that option. * * @param[in] None * * @retval * None ************************************************************************/ void EVM_init() { platform_init_flags sFlags; platform_init_config sConfig; /* Status of the call to initialize the platform */ int32_t pform_status; /* * You can choose what to initialize on the platform by setting the following * flags. Things like the DDR, PLL, etc should have been set by the boot loader. */ memset( (void *) &sFlags, 0, sizeof(platform_init_flags)); memset( (void *) &sConfig, 0, sizeof(platform_init_config)); sFlags.pll = 0; /* PLLs for clocking */ sFlags.ddr = 0; /* External memory */ sFlags.tcsl = 1; /* Time stamp counter */ #ifdef _SCBP6618X_ sFlags.phy = 0; /* Ethernet */ #else sFlags.phy = 1; /* Ethernet */ #endif sFlags.ecc = 0; /* Memory ECC */ sConfig.pllm = 0; /* Use libraries default clock divisor */ pform_status = platform_init(&sFlags, &sConfig); /* If we initialized the platform okay */ if (pform_status != Platform_EOK) { /* Initialization of the platform failed... die */ while (1) { (void) platform_led(1, PLATFORM_LED_ON, PLATFORM_USER_LED_CLASS); (void) platform_delay(50000); (void) platform_led(1, PLATFORM_LED_OFF, PLATFORM_USER_LED_CLASS); (void) platform_delay(50000); } } } //--------------------------------------------------------------------- // Main Entry Point //--------------------------------------------------------------------- int main() { /* Start the BIOS 6 Scheduler */ BIOS_start (); } // // Main Thread // int StackTest() { int rc; int i; HANDLE hCfg; QMSS_CFG_T qmss_cfg; CPPI_CFG_T cppi_cfg; /* Get information about the platform so we can use it in various places */ memset( (void *) &gPlatformInfo, 0, sizeof(platform_info)); (void) platform_get_info(&gPlatformInfo); (void) platform_uart_init(); (void) platform_uart_set_baudrate(115200); (void) platform_write_configure(PLATFORM_WRITE_ALL); /* Clear the state of the User LEDs to OFF */ for (i=0; i < gPlatformInfo.led[PLATFORM_USER_LED_CLASS].count; i++) { (void) platform_led(i, PLATFORM_LED_OFF, PLATFORM_USER_LED_CLASS); } /* Initialize the components required to run this application: * (1) QMSS * (2) CPPI * (3) Packet Accelerator */ /* Initialize QMSS */ if (platform_get_coreid() == 0) { qmss_cfg.master_core = 1; } else { qmss_cfg.master_core = 0; } qmss_cfg.max_num_desc = MAX_NUM_DESC; qmss_cfg.desc_size = MAX_DESC_SIZE; qmss_cfg.mem_region = Qmss_MemRegion_MEMORY_REGION0; if (res_mgr_init_qmss (&qmss_cfg) != 0) { platform_write ("Failed to initialize the QMSS subsystem \n"); goto main_exit; } else { platform_write ("QMSS successfully initialized \n"); } /* Initialize CPPI */ if (platform_get_coreid() == 0) { cppi_cfg.master_core = 1; } else { cppi_cfg.master_core = 0; } cppi_cfg.dma_num = Cppi_CpDma_PASS_CPDMA; cppi_cfg.num_tx_queues = NUM_PA_TX_QUEUES; cppi_cfg.num_rx_channels = NUM_PA_RX_CHANNELS; if (res_mgr_init_cppi (&cppi_cfg) != 0) { platform_write ("Failed to initialize CPPI subsystem \n"); goto main_exit; } else { platform_write ("CPPI successfully initialized \n"); } if (res_mgr_init_pass()!= 0) { platform_write ("Failed to initialize the Packet Accelerator \n"); goto main_exit; } else { platform_write ("PA successfully initialized \n"); } // // THIS MUST BE THE ABSOLUTE FIRST THING DONE IN AN APPLICATION before // using the stack!! // rc = NC_SystemOpen( NC_PRIORITY_LOW, NC_OPMODE_INTERRUPT ); if( rc ) { platform_write("NC_SystemOpen Failed (%d)\n",rc); for(;;); } // Print out our banner platform_write(VerStr); // // Create and build the system configuration from scratch. // // Create a new configuration hCfg = CfgNew(); if( !hCfg ) { platform_write("Unable to create configuration\n"); goto main_exit; } // // THIS MUST BE THE ABSOLUTE FIRST THING DONE IN AN APPLICATION!! // rc = NC_SystemOpen( NC_PRIORITY_LOW, NC_OPMODE_INTERRUPT ); if( rc ) { printf("NC_SystemOpen Failed (%d)\n",rc); for(;;); } // Print out our banner printf(VerStr); // // Create and build the system configuration from scratch. // // Create a new configuration hCfg = CfgNew(); if( !hCfg ) { printf("Unable to create configuration\n"); goto main_exit; } // We better validate the length of the supplied names if( strlen( DomainName ) >= CFG_DOMAIN_MAX || strlen( HostName ) >= CFG_HOSTNAME_MAX ) { printf("Names too long\n"); goto main_exit; } // Add our global hostname to hCfg (to be claimed in all connected domains) CfgAddEntry( hCfg, CFGTAG_SYSINFO, CFGITEM_DHCP_HOSTNAME, 0, strlen(HostName), (UINT8 *)HostName, 0 ); // If the IP address is specified, manually configure IP and Gateway //#if defined(_SCBP6618X_) || defined(_EVMTCI6614_) || defined(DEVICE_K2H) || defined(DEVICE_K2K) /* SCBP6618x, EVMTCI6614, EVMK2H, EVMK2K always uses DHCP */ // if (0) //#else // if (!platform_get_switch_state(1)) //#endif if(1) { CI_IPNET NA; CI_ROUTE RT; IPN IPTmp; // Setup manual IP address bzero( &NA, sizeof(NA) ); NA.IPAddr = inet_addr(LocalIPAddr); NA.IPMask = inet_addr(LocalIPMask); strcpy( NA.Domain, DomainName ); NA.NetType = 0; // Add the address to interface 1 CfgAddEntry( hCfg, CFGTAG_IPNET, 1, 0, sizeof(CI_IPNET), (UINT8 *)&NA, 0 ); // Add the default gateway. Since it is the default, the // destination address and mask are both zero (we go ahead // and show the assignment for clarity). bzero( &RT, sizeof(RT) ); RT.IPDestAddr = 0; RT.IPDestMask = 0; RT.IPGateAddr = inet_addr(GatewayIP); // Add the route CfgAddEntry( hCfg, CFGTAG_ROUTE, 0, 0, sizeof(CI_ROUTE), (UINT8 *)&RT, 0 ); // Manually add the DNS server when specified IPTmp = inet_addr(DNSServer); if( IPTmp ) CfgAddEntry( hCfg, CFGTAG_SYSINFO, CFGITEM_DHCP_DOMAINNAMESERVER, 0, sizeof(IPTmp), (UINT8 *)&IPTmp, 0 ); } // Else we specify DHCP else { CI_SERVICE_DHCPC dhcpc; // Specify DHCP Service on IF-1 bzero( &dhcpc, sizeof(dhcpc) ); dhcpc.cisargs.Mode = CIS_FLG_IFIDXVALID; dhcpc.cisargs.IfIdx = 1; dhcpc.cisargs.pCbSrv = &ServiceReport; CfgAddEntry( hCfg, CFGTAG_SERVICE, CFGITEM_SERVICE_DHCPCLIENT, 0, sizeof(dhcpc), (UINT8 *)&dhcpc, 0 ); } // // Configure IPStack/OS Options // // We don't want to see debug messages less than WARNINGS rc = DBG_WARN; CfgAddEntry( hCfg, CFGTAG_OS, CFGITEM_OS_DBGPRINTLEVEL, CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&rc, 0 ); // // This code sets up the TCP and UDP buffer sizes // (Note 8192 is actually the default. This code is here to // illustrate how the buffer and limit sizes are configured.) // // UDP Receive limit rc = 8192; CfgAddEntry( hCfg, CFGTAG_IP, CFGITEM_IP_SOCKUDPRXLIMIT, CFG_ADDMODE_UNIQUE, sizeof(uint), (UINT8 *)&rc, 0 ); // // Boot the system using this configuration // // We keep booting until the function returns 0. This allows // us to have a "reboot" command. // do { rc = NC_NetStart( hCfg, NetworkOpen, NetworkClose, NetworkIPAddr ); } while( rc > 0 ); // Delete Configuration CfgFree( hCfg ); // Close the OS main_exit: NC_SystemClose(); return(0); } // // System Task Code [ Server Daemon Servers ] // static HANDLE hHello=0; // // NetworkOpen // // This function is called after the configuration has booted // static void NetworkOpen() { // Create our local server hHello = DaemonNew( SOCK_DGRAM, 0, 7, dtask_udp_hello, OS_TASKPRINORM, OS_TASKSTKNORM, 0, 1 ); } // // NetworkClose // // This function is called when the network is shutting down, // or when it no longer has any IP addresses assigned to it. // static void NetworkClose() { DaemonFree( hHello ); } // // NetworkIPAddr // // This function is called whenever an IP address binding is // added or removed from the system. // static void NetworkIPAddr( IPN IPAddr, uint IfIdx, uint fAdd ) { IPN IPTmp; if( fAdd ) printf("Network Added: "); else printf("Network Removed: "); // Print a message IPTmp = ntohl( IPAddr ); printf("If-%d:%d.%d.%d.%d\n", IfIdx, (UINT8)(IPTmp>>24)&0xFF, (UINT8)(IPTmp>>16)&0xFF, (UINT8)(IPTmp>>8)&0xFF, (UINT8)IPTmp&0xFF ); } // // Service Status Reports // // Here's a quick example of using service status updates // static char *TaskName[] = { "Telnet","HTTP","NAT","DHCPS","DHCPC","DNS" }; static char *ReportStr[] = { "","Running","Updated","Complete","Fault" }; static char *StatusStr[] = { "Disabled","Waiting","IPTerm","Failed","Enabled" }; static void ServiceReport( uint Item, uint Status, uint Report, HANDLE h ) { printf( "Service Status: %-9s: %-9s: %-9s: %03d\n", TaskName[Item-1], StatusStr[Status], ReportStr[Report/256], Report&0xFF ); // // Example of adding to the DHCP configuration space // // When using the DHCP client, the client has full control over access // to the first 256 entries in the CFGTAG_SYSINFO space. // // Note that the DHCP client will erase all CFGTAG_SYSINFO tags except // CFGITEM_DHCP_HOSTNAME. If the application needs to keep manual // entries in the DHCP tag range, then the code to maintain them should // be placed here. // // Here, we want to manually add a DNS server to the configuration, but // we can only do it once DHCP has finished its programming. // if( Item == CFGITEM_SERVICE_DHCPCLIENT && Status == CIS_SRV_STATUS_ENABLED && (Report == (NETTOOLS_STAT_RUNNING|DHCPCODE_IPADD) || Report == (NETTOOLS_STAT_RUNNING|DHCPCODE_IPRENEW)) ) { IPN IPTmp; // Manually add the DNS server when specified IPTmp = inet_addr(DNSServer); if( IPTmp ) CfgAddEntry( 0, CFGTAG_SYSINFO, CFGITEM_DHCP_DOMAINNAMESERVER, 0, sizeof(IPTmp), (UINT8 *)&IPTmp, 0 ); } }

2.udphello.c

? ?

/* * udpHello.c * * This program implements a UDP echo server, which echos back any * input it receives. * * Copyright (C) 2007 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include <ti/ndk/inc/netmain.h> // // dtask_udp_hello() - UDP Echo Server Daemon Function // (SOCK_DGRAM, port 7) // // Returns "1" if socket 's' is still open, and "0" if its been closed // int dtask_udp_hello( SOCKET s, UINT32 unused ) { struct sockaddr_in sin1; struct timeval to; int i,tmp; char *pBuf; HANDLE hBuffer; (void)unused; // Configure our socket timeout to be 3 seconds to.tv_sec = 3; to.tv_usec = 0; setsockopt( s, SOL_SOCKET, SO_SNDTIMEO, &to, sizeof( to ) ); setsockopt( s, SOL_SOCKET, SO_RCVTIMEO, &to, sizeof( to ) ); for(;;) { tmp = sizeof( sin1 ); i = (int)recvncfrom( s, (void **)&pBuf, 0, (PSA)&sin1, &tmp, &hBuffer ); // Spit any data back out if( i >= 0 ) { sendto( s, pBuf, i, 0, (PSA)&sin1, sizeof(sin1) ); recvncfree( hBuffer ); } else break; } // Since the socket is still open, return "1" // (we need to leave UDP sockets open) return(1); }

總結

以上是生活随笔為你收集整理的DSP:6678开发板NDK网口通信完整实现(附源码)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 精品一区二区三区四区视频 | 五月婷婷六月婷婷 | 欧美裸体按摩 | 欧美成人影音 | www.成人在线观看 | av网站在线观看不卡 | 久久久久成人精品无码中文字幕 | 日韩中文电影 | 日本高清精品 | 国产成人啪免费观看软件 | 性感少妇在线观看 | 熊出没之冬日乐翻天免费高清观看 | 亚洲免费av网址 | 欧美香蕉视频 | 亚一区二区 | 九九视频在线播放 | 潮喷失禁大喷水aⅴ无码 | 91精品久久久久久久99蜜桃 | 国产一区二区视频免费在线观看 | 欧美色图校园春色 | 五月天色婷婷综合 | 操三八男人的天堂 | 性色av浪潮| 欧美色射 | 五月天激情四射 | 俄罗斯黄色大片 | 欧美人妻日韩精品 | youjizz.com日本| 亚洲av成人无码一区二区三区在线观看 | 在线免费看毛片 | 天天插天天插 | 九九精品在线观看 | 国产xxx在线 | 动漫美女被吸乳奶动漫视频 | 在线观看福利视频 | 成人娱乐网 | 欧美人与禽猛交乱配视频 | 91久久精品国产91性色tv | 亚洲综人网 | 色视频综合 | 91久久电影 | 国产精品免费无遮挡无码永久视频 | 婷婷视频在线 | 综合久久五月天 | 日韩大片免费观看视频播放 | 久综合网 | 亚洲av综合永久无码精品天堂 | 日韩成人精品一区二区 | 131mm少妇做爰视频 | 国产精品又黄又爽又色无遮挡 | 国产精品成人自拍 | 久久综合第一页 | 在线欧美| 中文人妻熟女乱又乱精品 | 午夜私人福利 | 精品亚洲国产成av人片传媒 | 成人黄色激情网 | av无毛| 夜夜爽夜夜叫夜夜高潮漏水 | 波多野结衣亚洲视频 | 一亲二脱三插 | 在线视频观看一区 | 99国产超薄肉色丝袜交足 | 男ji大巴进入女人的视频 | 激情亚洲网 | 精品一区二区免费视频 | www视频在线免费观看 | 亚洲天堂影院 | 亚洲二区精品 | 91福利一区二区 | 国产九色在线播放九色 | 色视频在线看 | 大黄一级片 | 国产成人一级片 | 香蕉依人| 中文字幕在线观看 | 奶水喷溅虐奶乳奴h文 | 无码精品人妻一二三区红粉影视 | 一区二区视频播放 | 在线观看欧美一区 | 欧美性猛交xx | 亚州一区二区 | 黄色刺激视频 | 亚洲国产视频一区 | 亚洲一区二区美女 | 久久亚洲精精品中文字幕早川悠里 | 亚洲GV成人无码久久精品 | 91性高潮久久久久久久 | 亚洲狠狠婷婷综合久久久久图片 | 黄色无毒网站 | 福利在线小视频 | 51嘿嘿嘿国产精品伦理 | 99久久精| 欧美一区二区三区四区在线观看 | 欧美国产精品一区二区 | jizzjizz日本免费视频 | 国产美女自拍视频 | 99热国产| 国产夫绿帽单男3p精品视频 |