1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-20 21:01:25 +03:00

Fix issue on close

This commit is contained in:
Mimmo La Fauci
2012-06-06 22:40:23 +02:00
parent 68583078f7
commit 1c539c0840
4 changed files with 22 additions and 20 deletions

Binary file not shown.

Binary file not shown.

View File

@ -356,7 +356,8 @@ void sendError()
//Wait to empty the buffer //Wait to empty the buffer
while(!spi_writeRegisterEmptyCheck(&AVR32_SPI)); while(!spi_writeRegisterEmptyCheck(&AVR32_SPI));
} }
BUSY_FOR_SPI();
WARN("Send SPI error!");
} }
#define ENABLE_SPI_INT() do { \ #define ENABLE_SPI_INT() do { \
@ -379,13 +380,15 @@ void sendError()
}while(0); }while(0);
void dump(char* _buf, uint16_t _count) { void dump(char* _buf, uint16_t _count) {
#ifdef _APP_DEBUG_
int i; int i;
for (i = 0; i < _count; ++i) for (i = 0; i < _count; ++i)
printk("0x%x ", _buf[i]); printk("0x%x ", _buf[i]);
printk("\n"); printk("\n");
#endif
} }
#ifdef _APP_DEBUG_
#define DUMP dump
#endif
#ifdef _APP_DEBUG_ #ifdef _APP_DEBUG_
#define DUMP_SPI_DATA(BUF, COUNT) do { \ #define DUMP_SPI_DATA(BUF, COUNT) do { \
@ -510,7 +513,7 @@ int set_key_cmd_cb(int numParam, char* buf, void* ctx) {
//printk("KEY len out of range %d", len); //printk("KEY len out of range %d", len);
RETURN_ERR(WL_FAILURE) RETURN_ERR(WL_FAILURE)
} }
#ifdef _APP_DEBUG_ #if 0
printk("KEY IDX = %d\n", idx); printk("KEY IDX = %d\n", idx);
dump(key, len); dump(key, len);
printk("KEY len %d\n", len); printk("KEY len %d\n", len);
@ -990,7 +993,7 @@ cmd_spi_state_t get_reply_idx_net_cb(char* recv, char* reply, void* ctx, uint16_
END_HEADER_REPLY(reply, 3+len+1, *count); END_HEADER_REPLY(reply, 3+len+1, *count);
dump(reply, *count); DUMP(reply, *count);
return SPI_CMD_DONE; return SPI_CMD_DONE;
} }
@ -1313,16 +1316,14 @@ unsigned char* getStartCmdSeq(unsigned char* _recv, int len, int *offset)
if (i!=0) if (i!=0)
{ {
DEB_PIN_DN(); DEB_PIN_DN();
//WARN("Disall. %d/%d cmd:%d\n", i, len,_recv[i+1]); WARN("Disall. %d/%d cmd:%d\n", i, len,_recv[i+1]);
WARN("D=%d\n", i);
} }
*offset = i; *offset = i;
return &_recv[i]; return &_recv[i];
} }
} }
DEB_PIN_DN(); DEB_PIN_DN();
WARN("D=%d\n", i); WARN("Disall. %d\n", i);
return NULL; return NULL;
} }
@ -1399,7 +1400,7 @@ int call_reply_cb(char* recv, char* reply) {
if (i==ARRAY_SIZE(cmd_spi_list)) if (i==ARRAY_SIZE(cmd_spi_list))
{ {
WARN("Unknown cmd 0x%x\n", cmdId); WARN("Unknown cmd 0x%x\n", cmdId);
dump(recv, count); DUMP(recv, count);
return REPLY_ERR_CMD; return REPLY_ERR_CMD;
} }
return REPLY_NO_ERR; return REPLY_NO_ERR;
@ -1475,7 +1476,7 @@ bool checkMsgFormat(uint8_t* _recv, int len, int* offset)
unsigned char* recv = getStartCmdSeq(_recv, len, offset); unsigned char* recv = getStartCmdSeq(_recv, len, offset);
if ((recv == NULL)||(recv!=_recv)) if ((recv == NULL)||(recv!=_recv))
{ {
if ((/*verboseDebug & */INFO_SPI_FLAG)&&(len < 20)) //TODO stamp only short messages wrong if ((INFO_WARN_FLAG)&&(len < 20)) //TODO stamp only short messages wrong
dump((char*)_recv, len); dump((char*)_recv, len);
if (recv == NULL) if (recv == NULL)
@ -1550,7 +1551,8 @@ void spi_poll(struct netif* netif) {
{ {
sendError(); sendError();
WARN("Check format msg failed!\n"); WARN("Check format msg failed!\n");
dump((char*)_receiveBuffer, receivedChars); if (INFO_WARN_FLAG)
dump((char*)_receiveBuffer, receivedChars);
state = SPI_CMD_IDLE; state = SPI_CMD_IDLE;
count=0; count=0;
} }

View File

@ -38,9 +38,10 @@ bool pending_accept = false;
static err_t tcp_data_sent(void *arg, struct tcp_pcb *pcb, u16_t len); static err_t tcp_data_sent(void *arg, struct tcp_pcb *pcb, u16_t len);
static void atcp_init() static void atcp_init_pend_flags()
{ {
pending_close = false; pending_close = false;
pending_accept = false;
} }
/** /**
@ -229,7 +230,7 @@ static void atcp_conn_err_cb(void *arg, err_t err) {
printk("Abort connection\n"); printk("Abort connection\n");
cleanSockState_cb(_ttcp); cleanSockState_cb(_ttcp);
pending_close = false; atcp_init_pend_flags();
} }
static void atcp_conn_cli_err_cb(void *arg, err_t err) { static void atcp_conn_cli_err_cb(void *arg, err_t err) {
@ -251,7 +252,7 @@ static void atcp_conn_cli_err_cb(void *arg, err_t err) {
free(_ttcp); free(_ttcp);
} }
pending_close = false; atcp_init_pend_flags();
} }
@ -265,7 +266,7 @@ static void close_conn(struct ttcp *_ttcp) {
if (err == ERR_MEM) if (err == ERR_MEM)
pending_close = true; pending_close = true;
else{ else{
pending_accept = false; atcp_init_pend_flags();
WARN("----------------------\n"); WARN("----------------------\n");
} }
} }
@ -339,8 +340,7 @@ static err_t atcp_poll(void *arg, struct tcp_pcb *pcb) {
pcb, arg, tcp_poll_retries); pcb, arg, tcp_poll_retries);
tcp_poll_retries = 0; tcp_poll_retries = 0;
tcp_abort(pcb); tcp_abort(pcb);
pending_accept = false; atcp_init_pend_flags();
pending_close = false;
return ERR_ABRT; return ERR_ABRT;
} }
@ -357,7 +357,7 @@ static err_t atcp_poll(void *arg, struct tcp_pcb *pcb) {
} }
else else
{ {
pending_close = false; atcp_init_pend_flags();
} }
INFO_TCP("ARD TCP [%p-%p] try to close pending:%d\n", pcb, (_ttcp)?_ttcp->tpcb:0, pending_close); INFO_TCP("ARD TCP [%p-%p] try to close pending:%d\n", pcb, (_ttcp)?_ttcp->tpcb:0, pending_close);
@ -450,7 +450,7 @@ static int atcp_start(struct ttcp* ttcp) {
} }
tcp_arg(ttcp->tpcb, ttcp); tcp_arg(ttcp->tpcb, ttcp);
atcp_init(); atcp_init_pend_flags();
if (ttcp->mode == TTCP_MODE_TRANSMIT) { if (ttcp->mode == TTCP_MODE_TRANSMIT) {
tcp_err(ttcp->tpcb, atcp_conn_cli_err_cb); tcp_err(ttcp->tpcb, atcp_conn_cli_err_cb);