完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
工具:MPLAB-X V3.61 XC8 V1.42 MCC配置器TCP-IP Lite STACK,如果您从1921年获取TCPHObjor demo代码并尝试编译,它将引发多个错误。看来,语法不符合当前的XC8实现。有人找到了纠正这个方法吗?微芯片源代码如下:
以上来自于百度翻译 以下为原文 Tools: MPLAB-X v3.61 XC8 v1.42 MCC Configurator TCP-IP Lite Stack If you take the TCP_CLIENT demo code from AN1921 and try to compile, it will throw multiple errors. It appears that the syntax isn't compliant with the current implementation of XC8. Has anybody found a way to correct this? Microchip source code below: #include #include #include #include "mcc_generated_files/mcc.h" #include "tcp_client_demo.h" #include "mcc_generated_files/TCPIPLibrary/tcpv4.h" #include "mcc_generated_files/TCPIPLibrary/ipv4.h" #include "mcc_generated_files/TCPIPLibrary/tcpip_config.h" sockaddr_in_t remoteSocket; void DEMO_TCP_Client(void) { // create the socket for the TCP Client static tcpTCB_t port60TCB; // create the TX and RX Client's buffers static uint8_t rxdataPort60[50]; static uint8_t txdataPort60[80]; static time_t t_client; static time_t socketTimeout; uint16_t rx_len; socketState_t socketState; rx_len = 0; uint16_t pot; char strTmp[17]; socketState = TCP_SocketPoll(&port60TCB); time(&t_client); switch(socketState) { case NOT_A_SOCKET: // Inserting and initializing the socket TCP_SocketInit(&port60TCB); break; case SOCKET_CLOSED: // if the socket is closed we will try to connect again // try to connect once at 2 seconds socketTimeout = t_client + 2; TCP_InsertRxBuffer(&port60TCB, rxdataPort60, sizeof(rxdataPort60)); TCP_Connect(&port60TCB, &remoteSocket); break; case SOCKET_IN_PROGRESS: // if the socket is closed we will try to connect again if(t_client >= socketTimeout) { TCP_Close(&port60TCB); } break; case SOCKET_CONNECTED: // implement an echo client over TCP // check if the previous buffer was sent if (TCP_SendDone(&port60TCB)) { rx_len = TCP_GetReceivedData(&port60TCB); // handle the incoming data if(rx_len > 0) { // check for "led x on/off" command if (rx_len > 16) { rxdataPort60[16] = 0; } else { rxdataPort60[rx_len] = 0; } if(rxdataPort60[0] == 'l' && rxdataPort60[1] == 'e' && rxdataPort60[2] == 'd') { if(rxdataPort60[6] == 'o' && rxdataPort60[7] == 'n') { Toggle_Led_SetHigh(); }else { if(rxdataPort60[6] == 'o' && rxdataPort60[7] == 'f' && rxdataPort60[8] == 'f') { Toggle_Led_SetLow(); } } } // reuse the RX buffer TCP_InsertRxBuffer(&port60TCB, rxdataPort60, sizeof(rxdataPort60)); } if(t_client >= socketTimeout) { // send board status message only once at 2 seconds socketTimeout = t_client + 2; pot = ADC_GetConversion(Pot); sprintf(txdataPort60,"Pot: %dn LED's state: %dn", pot, LATAbits.LATA5); //send data back to the source TCP_Send(&port60TCB, txdataPort60, strlen(txdataPort60)); } } break; case SOCKET_CLOSING: TCP_SocketRemove(&port60TCB); break; default: break; // we should not end up here } } void TCP_Client_Initialize(){ remoteSocket.addr.s_addr = MAKE_IPV4_ADDRESS(192, 168, 0, 16); remoteSocket.port = 60; } |
|
相关推荐
7个回答
|
|
有哪些错误?用错误显示输出。/ Ruben
以上来自于百度翻译 以下为原文 What are the errors? Show the output with the errors. /Ruben |
|
|
|
嗨,不确定你使用的是哪种TCP Lite版本,但是你必须从下面的链接获取TCP Lite堆栈(在当前下载的标签下):如果MCC插件版本和XC8编译器版本是AlgnDeReGa,则HTTP://www. MigCHIP.COM/MPLAB/MPLAB-CODE-CODER示例应该编译没有错误。RDS
以上来自于百度翻译 以下为原文 Hi, Not sure which TCP lite version you used but you must take the TCP lite stack from the followink link (under the "current download" tab : http://www.microchip.com/mplab/mplab-code-configurator Example should compile with no errors if the MCC plugin version and XC8 compiler version are aligned Regards |
|
|
|
是的,它应该工作,但它不。在MPLAB-X和安装MCC设置中创建一个新项目,遵循1921年的字母,使用MAC资源中的EXXXJ6X设置,然后将AN1921文件丢弃到项目中。它不会编译干净。我希望看到有人尝试并把结果公布回去。
以上来自于百度翻译 以下为原文 Yes it SHOULD work but it doesn't. Create a new project in MPLAB-X and setup MCC settings by following AN1921 to the letter, using the ETHxxJ6x setting in the MAC resource, then drop the AN1921 files into the project. It will NOT compile clean. I'd like to see somebody try this and post the results back. |
|
|
|
您好,您是说有编译错误或功能错误吗?如何连接电缆:板& lt;=& gt;开关& lt;==& gt;PC或板& lt;==& gt;PC?当做
以上来自于百度翻译 以下为原文 Hi, You mean there are compilation errors or functional errors ? How to you connect the cables : board <=> switch <==> PC or board <==> PC ? Regards |
|
|
|
实际上,在我得到硬件之前,1921年提供的代码在没有错误的情况下根据APP注释建立时不会编译。我相信演示板工作,但演示板使用不同的PIC18,外部以太网芯片和外部RAM。在MCC中,我没有调用外部RAM,而是将MAC设置为EXXXJ6X。否则,除了纠正XC8的语法错误之外,我没有偏离App Note。我确实花了一些时间清理代码,以消除语法错误。我从电路中得到的最多的是在网络上的握手,我能用WiReSARK看到它。本质上:被测设备(MAC地址)问谁有(PC IP地址)?PC回应说它有它正在寻找的IP地址。在这一点上没有进一步的通信,代码最终进入一个循环。我使用的是按照数据表而不是演示板设计的定制电路。没有外部RAM,没有外部PHY。该设备***入到一个开关,然后到PC。我已经尝试直接到PC,但得到相同的结果。同直电缆和X-Over一样。我不能为1921年的语法错误说话,但是功能错误是否可能与外部RAM或缺少它有关?芯片的数据表没有提及外部RAM是必要的。
以上来自于百度翻译 以下为原文 Both actually. Before I even get the hardware involved, the code as provided in AN1921 will not compile when it's set up according to the app note without errors. I'm sure the demo board works, but the demo board uses an different PIC18, outboard Ethernet chip, and external RAM. In MCC I didn't invoke external RAM and I set the MAC to ETHxxJ6x. Otherwise I didn't deviate from the app note except to correct syntax errors for XC8. I did spend some time cleaning up the code to get rid of syntax errors. The most I was able to get from the circuit was a handshake over the network which I was able to see with WireShark. In essence: - Device under test (MAC address) asks who has (PC IP address)? - PC responds saying that it has the IP address it was looking for. No further comm happens past that point and the code eventually goes into a loop. I'm using a custom designed circuit designed in accordance with the datasheet, not the demo board. There is no external RAM and no external PHY. The device is plugged into a switch then to the PC. I've tried going direct to the PC but got the same results. Same with straight cable vs. x-over. I can't speak for the AN1921 syntax errors but could the functional errors be related to the external RAM or lack thereof? The chip's datasheet made no mention of external RAM being necessary. |
|
|
|
你能说出至少一个你必须解决的“语法错误”吗?对不起,我没有时间去取所有的代码,复制你的整个环境。
以上来自于百度翻译 以下为原文 Can you name at least one of these "syntax errors" you had to fix? Sorry, I don't have time to go off and fetch all the code and reproduce your whole environment. |
|
|
|
您好,据我所知,您不应该把AN1921文件放到项目中。您应该使用MCC库模板生成的文件。也就是说,有其他线程对更新TCP IP Lite堆栈的代码和文档进行了承诺。请参见此线程:http:///。微芯片COM/…/ FindPost / 989875 MysIL
以上来自于百度翻译 以下为原文 Hi, As far as I know, You shall Not 'drop the AN1921 files into the project'. You should use files generated from the MCC library templates. That said, there have been other threads with promises about ongoing work with updating both code and documentation for TCP-IP Lite Stack. See this thread: http://www.microchip.com/.../FindPost/989875 Mysil |
|
|
|
只有小组成员才能发言,加入小组>>
5228 浏览 9 评论
2026 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3199 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
770浏览 1评论
658浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
585浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
668浏览 0评论
570浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-18 10:02 , Processed in 1.651242 second(s), Total 90, Slave 73 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号