HPM APP
HPMicro Application solution
tcp_echo.c File Reference
#include <string.h>
#include "tcp_echo.h"
#include "lwip/tcp.h"
#include "adc_16_pmt.h"

Functions

static err_t tcpecho_recv (void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
 TCP echo receive:This function is called by tcpecho_accept, where it processes the received data. ;TCP回环接收函数:该函数被tcpecho_accept调用,在该函数中处理接收到的数据 More...
 
static err_t tcpecho_accept (void *arg, struct tcp_pcb *newpcb, err_t err)
 TCP receive function: This function is called when new data is received. ;TCP接收函数:当收到新的数据时会调用该函数。 More...
 
static void tcp_block_write (uint8_t *buff, uint32_t len)
 Write data for sending.Send data through TCP based on the address and length of the data being sent. ;写入需要发送的数据,根据发送数据的地址和长度,将数据通过TCP发送出去。 More...
 
void tcp_poll_handle (void)
 Sending data using polling.Firstly, determine the values of adc_done[0] and adc_done[0]. If both are 1, it indicates that the data was not sent in a timely manner. If adc_done[0] is 1, set adc_done[0] to 0 and send the first half of the buff data; If adc_done[1] is 1, set adc_done[1] to 0 and send the second half of the buff data; ;LWIP将ADC的采样结果通过polling的方式发送出去,首先判断 adc_done[0]和adc_done[1]的值,如果同为1,表示数据未能及时发送。 若adc_done[0]为1,将adc_done[0]置0并发送adc_buff的前半部分数据; 若adc_done[1]为1,将adc_done[1]置0并发送adc_buff的前后半部分数据 More...
 
void tcp_echo_init (void)
 TCP initialization, binding IP address and port number. ;TCP初始化,绑定IP地址和端口号。 More...
 

Variables

static struct tcp_pcb * send_newpcb = NULL
 

Function Documentation

◆ tcp_block_write()

static void tcp_block_write ( uint8_t *  buff,
uint32_t  len 
)
static

Write data for sending.Send data through TCP based on the address and length of the data being sent. ;写入需要发送的数据,根据发送数据的地址和长度,将数据通过TCP发送出去。

Parameters
[in]buffBuff for sending data. ;发送数据的buff.
[in]lenData length in bytes. ;发送数据的长度,单位为字节。

◆ tcpecho_accept()

static err_t tcpecho_accept ( void *  arg,
struct tcp_pcb *  newpcb,
err_t  err 
)
static

TCP receive function: This function is called when new data is received. ;TCP接收函数:当收到新的数据时会调用该函数。

Parameters
[in]argThe parameters passed in. ;传入的参数
[out]newpcbtcp_pcb to set the receive callback. ;接收回调的tcp_pcb结构体
[in]errerror type. ;错误类型。
  • ERR_OK: No error, everything OK. ;没有错误,一切正常。
  • ERR_MEM: Out of memory error. ;内存溢出错误。
  • ERR_BUF: Buffer error. ;缓存区错误。
  • ERR_TIMEOUT: Timeout. ;超时。
  • ERR_RTE: Routing problem. ;路由问题。
  • ERR_INPROGRESS: Operation in progress. ;操作正在进行。
  • ERR_VAL: Illegal value. ;非法值。
  • ERR_WOULDBLOCK: Operation would block. ;操作将阻塞。
  • ERR_USE: Address in use. ;地址正在使用。
  • ERR_ALREADY: Already connecting. ;已连接。
  • ERR_ISCONN: Conn already established. ;已建立连接。
  • ERR_CONN: Not connected. ;未连接。
  • ERR_IF: Low-level netif error. ;网络接口低电平错误。
  • ERR_ABRT: Connection aborted. ;连接失败。
  • ERR_RST: Connection reset. ;连接重置。
  • ERR_CLSD: Connection closed. ;连接已关闭。
  • ERR_ARG: Illegal argument. ;非法参数。
Returns
ERR_OK

◆ tcpecho_recv()

static err_t tcpecho_recv ( void *  arg,
struct tcp_pcb *  tpcb,
struct pbuf *  p,
err_t  err 
)
static

TCP echo receive:This function is called by tcpecho_accept, where it processes the received data. ;TCP回环接收函数:该函数被tcpecho_accept调用,在该函数中处理接收到的数据

Parameters
[in]argThe parameters passed in. ;传入的参数。
[out]tpcbthe tcp_pcb for which data is read. ;接收数据的tcp_pcb结构体。
[out]pmain packet buffer struct for recive. ;接收区的主数据包结构体。
[in]errerror type. ;错误类型。
  • ERR_OK: No error, everything OK. ;没有错误,一切正常。
  • ERR_MEM: Out of memory error. ;内存溢出错误。
  • ERR_BUF: Buffer error. ;缓存区错误。
  • ERR_TIMEOUT: Timeout. ;超时。
  • ERR_RTE: Routing problem. ;路由问题。
  • ERR_INPROGRESS: Operation in progress. ;操作正在进行。
  • ERR_VAL: Illegal value. ;非法值。
  • ERR_WOULDBLOCK: Operation would block. ;操作将阻塞。
  • ERR_USE: Address in use. ;地址正在使用。
  • ERR_ALREADY: Already connecting. ;已连接。
  • ERR_ISCONN: Conn already established. ;已建立连接。
  • ERR_CONN: Not connected. ;未连接。
  • ERR_IF: Low-level netif error. ;网络接口低电平错误。
  • ERR_ABRT: Connection aborted. ;连接失败。
  • ERR_RST: Connection reset. ;连接重置。
  • ERR_CLSD: Connection closed. ;连接已关闭。
  • ERR_ARG: Illegal argument. ;非法参数。
Returns
ERR_OK

Variable Documentation

◆ send_newpcb

struct tcp_pcb* send_newpcb = NULL
static