Because no one answered the questions in my previous post, I opened another one. I used LWIP to send data successfully, but only 1446 data were sent at a time. I captured 16384 data at a time, so I needed to send 16K data in a cycle. What can I do to achieve it?
If I send only 1446 data at a time, the efficiency will be slow and it will take many cycles to send the captured data at a time.
A development branch of how to use lwip with ad9361 you can find here: https://github.com/analogdevicesinc/no-OS/tree/ad9361_remove_blocking_read, that is working with iio-oscilloscope: https://github.com/analogdevicesinc/iio-oscilloscope, as a client.
Have a look in: https://github.com/analogdevicesinc/no-OS/blob/ad9361_remove_blocking_read/projects/drivers/network/network.c
to checkout how we use lwip. We use tcp, probably if you configure lwip to use UDP instead you can hope for better results. We use tcp to be compatible to iio-oscilloscope. If you configure lwip to use UDP protocol, you will need a client application, since you can't use iio-oscilloscope.
Using tcp protocol, with 1446 bytes of util data, we managed to reach over 30Mbit/s .
Thank you for your answer. I have another question.
Can I send multiple packets at a time by calling tcp_write multiple times?
Yes, you can send multiple packets sequentially, by calling "tcp_write()" multiple times. Before calling "tcp_write()" (that only puts data in some queue), you should check the number of bytes available in the output queue by calling "tcp_sndbuf()" function.
Finally "tcp_output()" must be called to effectively send the data.
Please check "network_write_data()" function in:
For more documentation on lwip please read this: http://www.nongnu.org/lwip/2_0_x/raw_api.html
If you are not using already Wireshark tool to debug the network communication, I would suggest to try it.
I have another question. Now I'm implementing continuous data transmission. My sending process is to capture data first, then send data with tcp-write and tcp-output.
How can data be captured continuously during execution of sending instructions without losing data due to execution of sending instructions?
In addition, I would like to ask if the number of bytes available can be adjusted.
I'm not familiar with software programming and I haven't found a place to modify it.
I hope to get an answer. Thank you.
No matter how many times I call tcp_write, only 1446 data can be sent each time I execute tcp_output. Is that normal? It can not be adjusted by modifying the parameters.
For continuous acquisition you will have to use interrupts. Use the option "ADC_DMA_IRQ_EXAMPLE ". In this way "adc_capture()" becomes non-blocking and an interrupt handler is called when the transfer into memory is completed and "dma_transfer_completed_flag" is set. If you would like, it is possible to re implement the interrupt handler. While DMA captures data from the converter, you should send data from previous finished capture, over network interface. Of course network transfer should be faster than the DMA capture. It is possible to slow down the capture, by adjusting sampling rate.
Sending 1446 bytes at a time should not be a problem. You can split the 16K in 1446 bytes packets.
lwip can be configured probably to support larger packets. Check out "tcp_mss" in "lwipopts.h". By default it is set to 1460. I, personally didn't managed to increase it, probably you should check for support from lwip dev team.
Probably this value of
#define TCP_MSS 1446
it is limited by MTU:
Thank you very much for your answer. I found inspiration to help me complete this function.