Other Parts Discussed in Thread: TEST2
Hello everyone,
So I have been trying to get TCP working on the TM4C with the LWIP provided in the utilities libraries.
It's to add into a existing project so using TI-RTOS would be a pain (or maybe less pain?)
Anyway, I have seen the echo example and after fumbling a bit with it and having some issues due to never have used something like this I got to this point.
The idea is to basically use it to transfer data to and from a python application. Nothing fancy, it's basically a serial port. The test I am making generates messages at 2Khz, all 48 bytes in size which will have to be eventually reach the python app.
I made a test program for this. It's not ideal but by itself it should work.
I have ran into some issues one that seems related to this "already fixed" bug. Let's call this test1
In test1 I use putty to read the tcp data. It basically is a reader and discards. I am basically watching variables that indicate if "anyone" dropped bytes (before the solution I have now it did). No problems for 30min.
But it seems that pcb->snd_queuelen base value keep increasing ever so slowly. I have tried disabling the message generator in the middle of the test and snd_queuelen did not decrease!
Other issue. Let's call it test2.
Pretty much the same, the difference is that I am using python application. Not a python test code, it's the application with the twist that it simply discards everything as soon as it takes it from the socket buffer. Just to remove possible bottleneck. Well it works fine until the TM4C simply stops sending data. It didn't froze, timer interrupt keep getting called, message generator working, connection established, no faults, lwip TCP queues don't seem full. it simply stopped sending stuff. There might be something in the pcb or lwip_stats that I might be missing (most likely) but it seems weird.
Wireshark shows "TCP out-of-order"
I still haven't checked everything I want for both tests but since, at least the first 1 seems reminiscent of the older bug, I decided to post here. The 2nd test is probably something obvious in the flags that I don't know so help from experience would be awesome.
With that, some details on what I've got implemented:
Nagle enabled
Some choices are to ensure that the raw api calls are made all in the same context. Not quite since there's 1 tcp_write called in main but it's with IntMasterDisable so I am hoping there no issue.
- I have a function "serial_lwIP_Send". It's called from the main code. It can either
- It calls tcp_write with IntMasterDisable. Sets a flag to 0 when this happens (sentEvent), Only does this if sentEvent ==1 or circular buffer is empty.
- If sentEvent == 0 then it loads a circular buffer
- If tcp_write returned err_mem then it loads the circular buffer.
- Made callback for "tcp_sent". I call "tcp_sent" before each and every tcp_write
- This is en charge of doing sentEvent = 1 and calling tcp_write() if there is data in the circular buffer. Only give tcp_write() a maximum of tcp_sndbuf()
- Really only does this
- Made a periodic timer ISR with 5ms period
- This ISR is higher priority (should be) than ethernet ISR
- call tcp_output every 10th interrupt (so 50ms period)
- calls lwIPTimer
Any help would be appreciated.
I can provide lwipopts.h. I don't believe the memory is the issue, I probably got way too much for what I need. PBufs related might not be the best though.