?? use_rawapi.c
字號:
INT16S SendData(SOCKET channel, INT8U *buf, INT16S len)
{
if (len <= 0)
return (0);
tcp_write(gpcb, buf, len, 0);
tcp_output(gpcb);
return 1;
}
err_t tcprecv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
BCExecutableCmd *pExecutableCmd;
INT32S uiSize;
INT16U i;
if (err == ERR_OK && p != NULL)
{
tcp_recved(pcb, p->tot_len);
gpcb = pcb;
uiSize = p->tot_len;
for (i = 0; i < uiSize; i++)
g_ucTmpData[i] = ((INT8U*)p->payload)[i];
if (uiSize > 0)
{
if ( gSystem.ulSysStatus[gSystem.ulSysStatusCur] != STATUS_GET_DATA)
{
pExecutableCmd = (BCExecutableCmd *)g_ucTmpData;
if (pExecutableCmd->usCmdFlag != EXECUTABLE_CMD) //Is 0x55AA?
{ //Command error
printf("error!");
}
else
bsGetCmdAndData((INT8U *)&g_ucTmpData);
}
else
bcGetRunData(g_ucTmpData, uiSize);
}
pbuf_free(p);
}
else
pbuf_free(p);
pcb = gpcb;
if (err == ERR_OK && p == NULL)
{
tcp_arg(pcb, NULL);
tcp_sent(pcb, NULL);
tcp_recv(pcb, NULL);
tcp_close(pcb);
}
return ERR_OK;
}
err_t tcpaccept(void *arg, struct tcp_pcb *pcb, err_t err)
{
tcp_arg(pcb, NULL);
tcp_sent(pcb, NULL);
tcp_recv(pcb, tcprecv);
return ERR_OK;
}
void TcpEcho_Thread(void)
{
struct tcp_pcb *pcb;
// Create a new TCP PCB.
pcb = tcp_new();
// Bind the PCB to TCP port 80.
tcp_bind(pcb, NULL, 700);
// Change TCP state to LISTEN.
pcb = tcp_listen(pcb);
// Set up http_accet() function to be called
//when a new connection arrives.
tcp_accept(pcb, tcpaccept);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -