mirror of https://github.com/noisymime/Arduino.git
Fix issue on close
This commit is contained in:
parent
68583078f7
commit
1c539c0840
Binary file not shown.
Binary file not shown.
|
@ -356,7 +356,8 @@ void sendError()
|
|||
//Wait to empty the buffer
|
||||
while(!spi_writeRegisterEmptyCheck(&AVR32_SPI));
|
||||
}
|
||||
|
||||
BUSY_FOR_SPI();
|
||||
WARN("Send SPI error!");
|
||||
}
|
||||
|
||||
#define ENABLE_SPI_INT() do { \
|
||||
|
@ -379,13 +380,15 @@ void sendError()
|
|||
}while(0);
|
||||
|
||||
void dump(char* _buf, uint16_t _count) {
|
||||
#ifdef _APP_DEBUG_
|
||||
|
||||
int i;
|
||||
for (i = 0; i < _count; ++i)
|
||||
printk("0x%x ", _buf[i]);
|
||||
printk("\n");
|
||||
#endif
|
||||
}
|
||||
#ifdef _APP_DEBUG_
|
||||
#define DUMP dump
|
||||
#endif
|
||||
|
||||
#ifdef _APP_DEBUG_
|
||||
#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);
|
||||
RETURN_ERR(WL_FAILURE)
|
||||
}
|
||||
#ifdef _APP_DEBUG_
|
||||
#if 0
|
||||
printk("KEY IDX = %d\n", idx);
|
||||
dump(key, 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);
|
||||
|
||||
dump(reply, *count);
|
||||
DUMP(reply, *count);
|
||||
|
||||
return SPI_CMD_DONE;
|
||||
}
|
||||
|
@ -1313,16 +1316,14 @@ unsigned char* getStartCmdSeq(unsigned char* _recv, int len, int *offset)
|
|||
if (i!=0)
|
||||
{
|
||||
DEB_PIN_DN();
|
||||
//WARN("Disall. %d/%d cmd:%d\n", i, len,_recv[i+1]);
|
||||
WARN("D=%d\n", i);
|
||||
|
||||
WARN("Disall. %d/%d cmd:%d\n", i, len,_recv[i+1]);
|
||||
}
|
||||
*offset = i;
|
||||
return &_recv[i];
|
||||
}
|
||||
}
|
||||
DEB_PIN_DN();
|
||||
WARN("D=%d\n", i);
|
||||
WARN("Disall. %d\n", i);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1399,7 +1400,7 @@ int call_reply_cb(char* recv, char* reply) {
|
|||
if (i==ARRAY_SIZE(cmd_spi_list))
|
||||
{
|
||||
WARN("Unknown cmd 0x%x\n", cmdId);
|
||||
dump(recv, count);
|
||||
DUMP(recv, count);
|
||||
return REPLY_ERR_CMD;
|
||||
}
|
||||
return REPLY_NO_ERR;
|
||||
|
@ -1475,7 +1476,7 @@ bool checkMsgFormat(uint8_t* _recv, int len, int* offset)
|
|||
unsigned char* recv = getStartCmdSeq(_recv, len, offset);
|
||||
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);
|
||||
|
||||
if (recv == NULL)
|
||||
|
@ -1550,7 +1551,8 @@ void spi_poll(struct netif* netif) {
|
|||
{
|
||||
sendError();
|
||||
WARN("Check format msg failed!\n");
|
||||
dump((char*)_receiveBuffer, receivedChars);
|
||||
if (INFO_WARN_FLAG)
|
||||
dump((char*)_receiveBuffer, receivedChars);
|
||||
state = SPI_CMD_IDLE;
|
||||
count=0;
|
||||
}
|
||||
|
|
|
@ -38,9 +38,10 @@ bool pending_accept = false;
|
|||
|
||||
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_accept = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -229,7 +230,7 @@ static void atcp_conn_err_cb(void *arg, err_t err) {
|
|||
printk("Abort connection\n");
|
||||
cleanSockState_cb(_ttcp);
|
||||
|
||||
pending_close = false;
|
||||
atcp_init_pend_flags();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
pending_close = false;
|
||||
atcp_init_pend_flags();
|
||||
}
|
||||
|
||||
|
||||
|
@ -265,7 +266,7 @@ static void close_conn(struct ttcp *_ttcp) {
|
|||
if (err == ERR_MEM)
|
||||
pending_close = true;
|
||||
else{
|
||||
pending_accept = false;
|
||||
atcp_init_pend_flags();
|
||||
WARN("----------------------\n");
|
||||
}
|
||||
}
|
||||
|
@ -339,8 +340,7 @@ static err_t atcp_poll(void *arg, struct tcp_pcb *pcb) {
|
|||
pcb, arg, tcp_poll_retries);
|
||||
tcp_poll_retries = 0;
|
||||
tcp_abort(pcb);
|
||||
pending_accept = false;
|
||||
pending_close = false;
|
||||
atcp_init_pend_flags();
|
||||
return ERR_ABRT;
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ static err_t atcp_poll(void *arg, struct tcp_pcb *pcb) {
|
|||
}
|
||||
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);
|
||||
|
@ -450,7 +450,7 @@ static int atcp_start(struct ttcp* ttcp) {
|
|||
}
|
||||
|
||||
tcp_arg(ttcp->tpcb, ttcp);
|
||||
atcp_init();
|
||||
atcp_init_pend_flags();
|
||||
|
||||
if (ttcp->mode == TTCP_MODE_TRANSMIT) {
|
||||
tcp_err(ttcp->tpcb, atcp_conn_cli_err_cb);
|
||||
|
|
Loading…
Reference in New Issue