不,你以前不需要主人。我只是假设你能在C中编程,甚至更多,你必须能够“读”它,特别是如果你想开始用示例代码学习的时候。自学和做中学也是一个很好的方法。你只是需要一些开始,从简单的…更先进。什么是“简单”取决于你的开始知识。最重要的是(没有人能回答你),你想用你当前的“项目”来实现什么。即使你可能回答你的主要目标是“学习”,那么下一个问题可能是,接下来你想用你的新K来做什么。现有知识。(当你写信说你从Android / Java编程切换到PIC嵌入式时,我很惊讶。)我有时也想知道一些技术,但我知道我只想得到粗略的理解,我不打算“使用”它,我不需要关心细节。然后我还有其他的“项目”。TS“我想避免深入细节,因为我只是想使用一些技术,但它会花费我太多的时间来关注细节。例如,对于我来说,PIC USB堆栈可能与UART代码类似。但是还有第三类,我想知道所有的细节,因为我很好奇,或者因为我不能做我的工作。例如,在嵌入式项目中,经常需要通过UART、I2C或SPI进行通信,所以在学习时,深入到这里是很有价值的。因为我不知道你要去哪里,所以很难推荐一些东西。如果你的硬件从读卡器到网页都能工作,你可以把精力集中在一些令人兴奋的应用程序上。你不想知道更多关于RS232、UART或TCP的细节,因为这会分散你的注意力,或者你没有时间。如果你从很远的地方看它,那么这是真的。但显然你有一个问题,所以当它进入细节时是不一样的。所以我们回到“我的”主要问题,向你推荐什么。从我所看到的,我想你有必要了解更多关于你的UART的细节(只是为了学习)。在这种情况下,您需要了解UART.C文件。但是你也可以考虑UART.C来成为一个库,它允许你从UART中抽象出来,你只需要知道这个文件/库提供的函数。(假设这个代码中没有bug,什么是有挑战性的)。你的UAR2TCPBase.C利用这个低级UART。C已经混合了UART、中断、缓冲器、状态机、TCP的概念。这是比较困难的,事实上,我自己不想分析和调试它给你或教给你,它需要太多的时间(用尽我的时间现在这个职位),不知道你真正要做什么,你的问题是哪里。这就是为什么我认为THA。你从一个太复杂的例子开始。UART2TCPBReal.c文件显示了很多编辑和注释部分等。所以我不太相信它是经过验证的代码,它只是按原样工作。如果这是唯一的问题,那么答案是,假设文件是一个桥。一个UART和一个TCP连接。(连接的2个方面)的概念是,例如UART的数据保存在RAM中的缓冲区中。查看文件中的评论,例如VuARTrxFIFO,RXHeadPtr,RXTailPtr。该实现使用循环缓冲区(因此,头和尾),并且它也似乎使用阴影缓冲。因此,您的问题的答案是,将传入的数据保存在缓冲区中。如果文件按预期使用(不需要更多代码就不可能看到),这是我不想看到的。EE),然后数据是“刚刚处理,并再次扔掉”,正如你写的。还有一些其他代码必须确保正确的初始化并保持状态机(UART2TCPBRIDGETASK函数)运行。
以上来自于百度翻译
以下为原文
No, you don't need a master before. I just assume that you are able to program in C, and even more, you must be able to "read" it, especially if you would like to start learning with sample code.
Learning by yourself and learning by doing is also a good method.
You just need something to start with, from simple ... to more advanced. What is "simple" depends on your starting knowledge.
The most important is (and nobody can answer that for you), what you want to achieve with your current "project".
Even if you might answer that your major goal is "learning", then the next question could be, what you want to to next with your new knowledge. (I was astonished when you wrote that you switched from Android/Java programming to PIC embedded.)
I sometimes also would like to know about some technology, but I know I only want to get a rough understanding, I'm not going to "use" it, I do not need to care about details.
Then I have other "projects" where I would like to avoid having to dive into the details, because I just want to use some technology, but it would take me just too much time to care about the details. E.g. for me the PIC USB stack may be similar to your UART code.
But then there is a third category, where I want to know all the details, either because I'm curious or because otherwise I cannot do my work. E.g. knowledge about communication via UART, i2C or SPI is very often required in embedded projects, so it is worth to go more into the depth here when learning.
Since I do not know where you are going, it is difficult to recommend something.
Possibly you are happy if you all your hardware from Card Reader to Web Page just works and you can focus on some exciting application built on that. And you don't want to know more details about RS232, UART or TCP, because that would distract you from the focus or you just don't have the time.
If you are looking at it from a far enough distance, then this is true. But apparently you have a problem, so it is not the same when it goes into details.
So we are back to "my" main problem, what to recommend to you. From what I see, I would guess it makes sense that you go into more details about your UART (just for learning). In this case you need to understand your uart.c file. But you could also consider uart.c to to be a library, which allows you to abstract from the UART and you only have to know about the functions provided by this file/library. (this assumes that there are no bugs in this code, what is challenging).
Your UAR2TCPBridge.c makes use of this low-level uart.c.
It already mixes concepts of UART, Interrupts, buffers, state machines, TCP. This is more difficult and actually I myself would not like to analyze and possibly debug that for you or teach it to you, it just takes too much time (used up my time for this post now), and without knowing what you really are going to do and where your problem is.
That's the reason why I think that you started with a too complex example.
Also the UART2TCPBride.c file shows a LOT of editing and commenting out parts etc. So I'm not very confident that it's proven code, which just works as it is.
If that's really the only question, then the answer is, that the file is assumed to make a bridge between an UART and a TCP connection. (2 sides of your connection)
The concept is that the data from e.g. the UART is saved in a buffer in RAM. See the comments in the file for e.g. vUARTRXFIFO, RXHeadPtr, RXTailPtr. The implementation uses a circular buffer (therefore Head and Tail) and it seem also to use shadow buffering.
So the answer to your question is, that your incoming data is saved in the buffer.
If the file is used as intended (which is impossible to see without even more code, which I do not want to see), then the data is "just processed and again thrown away" as you wrote. Still some other code would have to ensure proper initialization and keep the state machine (UART2TCPBridgeTask function) running.