1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-10 21:24:12 +01:00

Added verbose debug command

This commit is contained in:
Mimmo La Fauci 2012-03-24 09:10:02 +01:00
parent 22504d0c8c
commit 236a518baa
6 changed files with 33 additions and 9 deletions

Binary file not shown.

Binary file not shown.

View File

@ -72,7 +72,7 @@
#define REPLY_MAX_LEN 1024
#endif
uint8_t counter = 0;
#define _BUFFERSIZE 100
extern void tcp_debug_print_pcbs(void);
@ -82,7 +82,6 @@ static uint16_t count = 0;
static uint16_t replyCount = 0;
static cmd_spi_state_t state = SPI_CMD_IDLE;
int receivedChars = 0;
#define _BUFFERSIZE 100
static uint8_t _receiveBuffer[_BUFFERSIZE];
bool startReply = false;
bool end_write = false; //TODO only for debug
@ -159,8 +158,6 @@ cmd_resetStatSpi(int argc, char* argv[], void* ctx)
#define RETURN_ERR(e) return (e==WL_SUCCESS) ? WIFI_SPI_ACK : WIFI_SPI_ERR;
#define RESET_USART_CSR(usart) usart->cr = AVR32_USART_CR_RSTSTA_MASK;
tSpiMsg spiMsgBuf[MAX_CMD_PIPE_SIZE];
unsigned char indexCmdPipe = 0;
int result = WL_CONNECT_FAILED; //Store the result of the last operation
void* mapSockTCP[MAX_SOCK_NUM];
@ -196,6 +193,11 @@ void clearMapSockTcp(uint8_t sock)
mapSockTCP[sock] = NULL;
}
void initMapSockTcp()
{
memset(mapSockTCP, 0, sizeof(void*)*MAX_SOCK_NUM);
}
/**
* Calculate bitrate based on number of bytes transmitted and elapsed time
*/
@ -1014,9 +1016,13 @@ cmd_spi_state_t get_client_state_tcp_cmd_cb(char* recv, char* reply, void* ctx,
{
_state = getStateTcp(p, 1);
INFO_TCP("p=%p _ttcp=%p state:%d\n",
INFO_TCP_VER("p=%p _ttcp=%p state:%d\n",
p, ((struct ttcp*) p)->tpcb, _state);
}else {
INFO_TCP_VER("p=%p _ttcp=%p state(tpcb):%d state(lpcb):%d\n",
p, ((struct ttcp*) p)->tpcb,
((struct ttcp*) p)->tpcb->state,
((struct ttcp*) p)->lpcb->state);
_state = getStateTcp(p, 1);
}
}
@ -1380,6 +1386,8 @@ void spi_poll(struct netif* netif) {
{
state = SPI_CMD_INPROGRESS;
count = receivedChars-offset;
if (count >= CMD_MAX_LEN)
count = CMD_MAX_LEN;
memcpy(buf, &_receiveBuffer[offset], count);
DISABLE_SPI_INT();
@ -1637,6 +1645,10 @@ int initSpi()
init_spi_cmds();
memset(_receiveBuffer, 0, _BUFFERSIZE);
memset(buf, 0, CMD_MAX_LEN);
memset(reply, 0, REPLY_MAX_LEN);
initMapSockTcp();
init_pBuf();

View File

@ -39,7 +39,6 @@ typedef enum {
#define TIMEOUT_SPI 200
//#define TIMEOUT_SENT_REPLY 1000
#define MAX_CMD_PIPE_SIZE 5
#define DUMMY_DATA 0xFF
typedef int (*cmd_spi_cb_t)(int numParam, char* buf, void* ctx);

View File

@ -297,12 +297,13 @@ static err_t atcp_accept_cb(void *arg, struct tcp_pcb *newpcb, err_t err) {
*/
static int atcp_start(struct ttcp* ttcp) {
err_t err = ERR_OK;
ttcp->tpcb = tcp_new();
if (ttcp->tpcb == NULL) {
WARN("TTCP [%p]: could not allocate pcb\n", ttcp);
return -1;
}
INFO_TCP("tcp:%x\n", ttcp->tpcb);
ttcp->payload = malloc(ttcp->buflen);
if (ttcp->payload == NULL) {
WARN("TTCP [%p]: could not allocate payload\n", ttcp);

View File

@ -23,10 +23,10 @@
#define INFO_E (1<<0xE) // Error
#define INFO_WARN_FLAG (1<<0xF) // Warning
extern uint16_t enableDebug;
extern uint16_t verboseDebug;
#ifdef _INFO_DEBUG_
#define INFO_INIT(msg, args...) do { \
if (enableDebug & INFO_INIT_FLAG) printk("I-[%s] " msg , __func__ , ##args ); \
} while (0)
@ -35,6 +35,12 @@ if (enableDebug & INFO_INIT_FLAG) printk("I-[%s] " msg , __func__ , ##args ); \
if (enableDebug & INFO_TCP_FLAG) printk("I-[%s] " msg , __func__ , ##args ); \
} while (0)
#define INFO_TCP_VER(msg, args...) do { \
if ((enableDebug & INFO_TCP_FLAG)&&(verboseDebug & INFO_TCP_FLAG)) \
printk("I-[%s] " msg , __func__ , ##args ); \
} while (0)
#define INFO_SPI(msg, args...) do { \
if (enableDebug & INFO_SPI_FLAG) printk("I-[%s] " msg , __func__ , ##args ); \
} while (0)
@ -42,7 +48,13 @@ if (enableDebug & INFO_SPI_FLAG) printk("I-[%s] " msg , __func__ , ##args ); \
#define INFO_UTIL(msg, args...) do { \
if (enableDebug & INFO_UTIL_FLAG) printk("I-[%s] " msg , __func__ , ##args ); \
} while (0)
#else
#define INFO_INIT(msg, args...) do {}while(0);
#define INFO_TCP(msg, args...) do {}while(0);
#define INFO_TCP_VER(msg, args...) do { }while(0);
#define INFO_SPI(msg, args...) do {}while(0);
#define INFO_UTIL(msg, args...) do {}while(0);
#endif
#ifdef _APP_DEBUG_
#define INFO(msg, args...) do { \