完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
EVM6678le CCS5.3 导入例程D:tiBIOS_MCSDK_02_01_02_06_p1mcsdk_2_01_02_06examplesndkhelloWorldevmc6678l
原程序已经调通..但我不想用TI 本身的SERVER SUITE 想自己直接写SOCKET 修改代码如下. int connect_nonb(SOCKET s, PSA sin, int msecs) [ int nonb; fd_set fdset; struct timeval tv; nonb = 0; if ( setsockopt( s, SOL_SOCKET, SO_BLOCKING, (void*)&nonb, sizeof( int ) ) != 0 ) [ return -1; ] if ( connect( s, ( PSA ) sin, sizeof( struct sockaddr ) ) != 0 ) [ FD_ZERO( &fdset ); FD_SET( s, &fdset ); tv.tv_sec = msecs / 1000; tv.tv_usec = (msecs % 1000) * 1000; if ( fdSelect( 0, 0, &fdset, 0, &tv ) != 1 ) [ return -1; ] ] nonb = 1; if ( setsockopt( s, SOL_SOCKET, SO_BLOCKING, (void*)&nonb, sizeof( int ) ) != 0 ) [ return -1; ] return 0; ] // // 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. // // // 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 configurationn" ); 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 longn" ); 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 ( !platform_get_switch_state( 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; NA.NetType = AF_INET; // 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 ); // // 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 );*/ SOCKET s; struct sockaddr_in sin; struct timeval tv; int k, tms, nbytes; rc = fdOpenSession(TaskSelf()); bzero(&sin, sizeof(struct sockaddr_in)); sin.sin_len = sizeof(struct sockaddr_in); sin.sin_family = AF_INET; sin.sin_port = htons( 3456 ); sin.sin_addr.s_addr = inet_addr( "192.168.1.100" ); s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); rc = connect_nonb(s, (PSA)&sin, 1000); if (rc == 0) [ tv.tv_sec = 0; tv.tv_usec = 800000; setsockopt( s, SOL_SOCKET, SO_SNDTIMEO, (void*)&tv, sizeof( tv ) ); setsockopt( s, SOL_SOCKET, SO_RCVTIMEO, (void*)&tv, sizeof( tv ) ); tms = 0; for ( k = 0; k < 300; k ++ ) [ nbytes = send(s, (void *)"Hello World!", 12, 0); if (nbytes <= 0) [ if (++ tms == 100) [ break; ] ] ] ] fdClose(s); fdCloseSession(TaskSelf()); // Delete Configuration CfgFree( hCfg ); // Close the OS main_exit: NC_SystemClose(); return( 0 ); ] 其它没动...每次执行到connect 程序就动不了.....非阻塞也没用 |
|
相关推荐
3个回答
|
|
自己搞定了...缺了一个NC_NetStart...好像必须用回调的方式..
|
|
|
|
可以把你的完整程序发一下吗?我刚接触这一块,总是调不通,981342847@qq.com,非常非常感谢! |
|
|
|
你好: 请问一下你说的却一个NC_NetStart不过我看你程序里面有这个函数调用了啊? |
|
|
|
只有小组成员才能发言,加入小组>>
NA555DR VCC最低电压需要在5V供电,为什么用3.3V供电搭了个单稳态触发器也使用正常?
694 浏览 3 评论
MSP430F249TPMR出现高温存储后失效了的情况,怎么解决?
605 浏览 1 评论
对于多级放大电路板,在PCB布局中,电源摆放的位置应该注意什么?
1065 浏览 1 评论
757 浏览 0 评论
普中科技F28335开发板每次上电复位后数码管都会显示,如何熄灭它?
529 浏览 1 评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
171浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
133浏览 14评论
在使用3254进行录音的时候出现一个奇怪的现象,右声道有吱吱声,请教一下,是否是什么寄存器设置存在问题?
130浏览 13评论
TLV320芯片内部自带数字滤波功能,请问linein进来的模拟信号是否是先经过ADC的超采样?
126浏览 12评论
GD32F303RCT6配置PA4 ADC引脚,将PA2代替key功能,PA2连接时无法实现预期功能,为什么?
64浏览 10评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-29 11:12 , Processed in 0.768997 second(s), Total 51, Slave 44 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号