Include debug.h for xerr/xinfo/xwarn caller

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2021-05-24 15:31:54 +08:00 committed by Masayuki Ishikawa
parent 98de0d6a68
commit 82ed7bf5b1
2 changed files with 36 additions and 32 deletions

View File

@ -43,6 +43,7 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <debug.h>
#include <errno.h>
#include <fcntl.h>
#include <poll.h>
@ -72,7 +73,7 @@ struct chat_app
/* Private fields */
int argc; /* number of command-line arguments */
FAR char** argv; /* command-line arguments */
FAR char **argv; /* command-line arguments */
char tty[CHAT_TTYNAME_SIZE]; /* modem TTY device node */
FAR const char *script; /* raw chat script - input to the parser */
bool script_dynalloc; /* true if the script should be freed */
@ -156,8 +157,8 @@ static int chat_script_preset(FAR struct chat_app *priv, int script_number)
return ret;
}
static int chat_script_read(FAR struct chat_app* priv,
FAR const char* filepath)
static int chat_script_read(FAR struct chat_app *priv,
FAR const char *filepath)
{
FAR char *scriptp;
size_t spare_size = CONFIG_EXAMPLES_CHAT_SIZE - 1;
@ -217,7 +218,7 @@ static int chat_script_read(FAR struct chat_app* priv,
return ret;
}
static int chat_parse_args(FAR struct chat_app* priv)
static int chat_parse_args(FAR struct chat_app *priv)
{
/* -d TTY device node (non-Linux feature)
* -e echo to stderr
@ -251,11 +252,12 @@ static int chat_parse_args(FAR struct chat_app* priv)
switch (priv->argv[i][1])
{
case 'd':
/* set the TTY device node */
strncpy(priv->tty,
(FAR char*) priv->argv[i] + 2,
CHAT_TTYNAME_SIZE-1);
(FAR char *)priv->argv[i] + 2,
CHAT_TTYNAME_SIZE - 1);
break;
case 'e':
@ -264,11 +266,11 @@ static int chat_parse_args(FAR struct chat_app* priv)
case 'f':
ret = chat_script_read(priv,
(FAR char*) priv->argv[i] + 2);
(FAR char *)priv->argv[i] + 2);
break;
case 'p':
numarg = strtol((FAR char*) priv->argv[i] + 2,
numarg = strtol((FAR char *)priv->argv[i] + 2,
NULL, 10);
if (errno < 0)
{
@ -280,7 +282,7 @@ static int chat_parse_args(FAR struct chat_app* priv)
break;
case 't':
numarg = strtol((FAR char*) priv->argv[i] + 2,
numarg = strtol((FAR char *)priv->argv[i] + 2,
NULL, 10);
if (errno < 0 || numarg < 0)
@ -320,7 +322,7 @@ static int chat_parse_args(FAR struct chat_app* priv)
*
****************************************************************************/
int main(int argc, FAR char** argv)
int main(int argc, FAR char **argv)
{
struct chat_app priv;
int ret;
@ -333,10 +335,10 @@ int main(int argc, FAR char** argv)
priv.ctl.timeout = CONFIG_EXAMPLES_CHAT_TIMEOUT_SECONDS;
priv.script = NULL;
priv.script_dynalloc = false;
strncpy(priv.tty, CONFIG_EXAMPLES_CHAT_TTY_DEVNODE, CHAT_TTYNAME_SIZE-1);
strncpy(priv.tty, CONFIG_EXAMPLES_CHAT_TTY_DEVNODE, CHAT_TTYNAME_SIZE - 1);
_info("parsing the arguments\n");
ret = chat_parse_args((FAR struct chat_app*) &priv);
ret = chat_parse_args((FAR struct chat_app *)&priv);
if (ret < 0)
{
_info("Command line parsing failed: code %d, errno %d\n", ret, errno);
@ -370,7 +372,7 @@ int main(int argc, FAR char** argv)
goto with_tty_dev;
}
ret = chat((FAR struct chat_ctl*) &priv.ctl, priv.script);
ret = chat((FAR struct chat_ctl *)&priv.ctl, priv.script);
with_tty_dev:
close(priv.ctl.fd);

View File

@ -43,6 +43,7 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <debug.h>
#include <errno.h>
#include <fcntl.h>
#include <poll.h>
@ -79,12 +80,12 @@
* Private Data
****************************************************************************/
static int ubloxmodem_help (FAR struct ubloxmodem_cxt* cxt);
static int ubloxmodem_on (FAR struct ubloxmodem_cxt* cxt);
static int ubloxmodem_off (FAR struct ubloxmodem_cxt* cxt);
static int ubloxmodem_reset (FAR struct ubloxmodem_cxt* cxt);
static int ubloxmodem_status(FAR struct ubloxmodem_cxt* cxt);
static int ubloxmodem_at (FAR struct ubloxmodem_cxt* cxt);
static int ubloxmodem_help (FAR struct ubloxmodem_cxt *cxt);
static int ubloxmodem_on (FAR struct ubloxmodem_cxt *cxt);
static int ubloxmodem_off (FAR struct ubloxmodem_cxt *cxt);
static int ubloxmodem_reset (FAR struct ubloxmodem_cxt *cxt);
static int ubloxmodem_status(FAR struct ubloxmodem_cxt *cxt);
static int ubloxmodem_at (FAR struct ubloxmodem_cxt *cxt);
/* Mapping of command indices (@ubloxmodem_cmd@ implicit from the position in
* the list) to tuples containing the command handler and descriptive
@ -124,7 +125,8 @@ static int make_nonblock(int fd)
static int ubloxmodem_open_tty(void)
{
int fd, ret;
int fd;
int ret;
fd = open(CONFIG_SYSTEM_UBLOXMODEM_TTY_DEVNODE, O_RDWR);
if (fd < 0)
@ -144,7 +146,7 @@ static int ubloxmodem_open_tty(void)
return fd;
}
static int chat_readb(int fd, FAR char* dst, int timeout_ms)
static int chat_readb(int fd, FAR char *dst, int timeout_ms)
{
struct pollfd fds;
int ret;
@ -170,7 +172,7 @@ static int chat_readb(int fd, FAR char* dst, int timeout_ms)
return 0;
}
static int chat_match_response(int fd, FAR char* response, int timeout_ms)
static int chat_match_response(int fd, FAR char *response, int timeout_ms)
{
char c;
int ret;
@ -203,7 +205,7 @@ static int chat_match_response(int fd, FAR char* response, int timeout_ms)
return 0;
}
static int chat_single(int fd, FAR char* cmd, FAR char* resp)
static int chat_single(int fd, FAR char *cmd, FAR char *resp)
{
int ret;
@ -238,7 +240,7 @@ static int chat_single(int fd, FAR char* cmd, FAR char* resp)
return ret;
}
static int ubloxmodem_help(FAR struct ubloxmodem_cxt* cxt)
static int ubloxmodem_help(FAR struct ubloxmodem_cxt *cxt)
{
int i;
@ -257,7 +259,7 @@ static int ubloxmodem_help(FAR struct ubloxmodem_cxt* cxt)
return 0;
}
static int ubloxmodem_on(FAR struct ubloxmodem_cxt* cxt)
static int ubloxmodem_on(FAR struct ubloxmodem_cxt *cxt)
{
int ret;
@ -271,7 +273,7 @@ static int ubloxmodem_on(FAR struct ubloxmodem_cxt* cxt)
return ret;
}
static int ubloxmodem_off(FAR struct ubloxmodem_cxt* cxt)
static int ubloxmodem_off(FAR struct ubloxmodem_cxt *cxt)
{
int ret;
@ -285,7 +287,7 @@ static int ubloxmodem_off(FAR struct ubloxmodem_cxt* cxt)
return ret;
}
static int ubloxmodem_reset(FAR struct ubloxmodem_cxt* cxt)
static int ubloxmodem_reset(FAR struct ubloxmodem_cxt *cxt)
{
int ret;
@ -299,7 +301,7 @@ static int ubloxmodem_reset(FAR struct ubloxmodem_cxt* cxt)
return ret;
}
static int ubloxmodem_status(FAR struct ubloxmodem_cxt* cxt)
static int ubloxmodem_status(FAR struct ubloxmodem_cxt *cxt)
{
int ret, i;
struct ubxmdm_status status;
@ -338,11 +340,11 @@ static int ubloxmodem_status(FAR struct ubloxmodem_cxt* cxt)
return ret;
}
static int ubloxmodem_at(FAR struct ubloxmodem_cxt* cxt)
static int ubloxmodem_at(FAR struct ubloxmodem_cxt *cxt)
{
int fd, ret;
FAR char* atcmd;
FAR char* resp;
FAR char *atcmd;
FAR char *resp;
atcmd = cxt->argv[2];
resp = cxt->argv[3];
@ -368,7 +370,7 @@ static int ubloxmodem_at(FAR struct ubloxmodem_cxt* cxt)
return ret;
}
static int ubloxmodem_parse(FAR struct ubloxmodem_cxt* cxt)
static int ubloxmodem_parse(FAR struct ubloxmodem_cxt *cxt)
{
int i;