mirror of https://github.com/ARMmbed/mbed-os.git
ATCmdParser: Added namespace std for va_list
parent
3d5ec6626f
commit
f55b929de9
|
@ -21,6 +21,9 @@
|
||||||
#include "ATCmdParser.h"
|
#include "ATCmdParser.h"
|
||||||
#include "mbed_poll.h"
|
#include "mbed_poll.h"
|
||||||
#include "mbed_debug.h"
|
#include "mbed_debug.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef LF
|
#ifdef LF
|
||||||
#undef LF
|
#undef LF
|
||||||
|
@ -102,7 +105,7 @@ int ATCmdParser::read(char *data, int size)
|
||||||
|
|
||||||
|
|
||||||
// printf/scanf handling
|
// printf/scanf handling
|
||||||
int ATCmdParser::vprintf(const char *format, va_list args)
|
int ATCmdParser::vprintf(const char *format, std::va_list args)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (vsprintf(_buffer, format, args) < 0) {
|
if (vsprintf(_buffer, format, args) < 0) {
|
||||||
|
@ -118,7 +121,7 @@ int ATCmdParser::vprintf(const char *format, va_list args)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ATCmdParser::vscanf(const char *format, va_list args)
|
int ATCmdParser::vscanf(const char *format, std::va_list args)
|
||||||
{
|
{
|
||||||
// Since format is const, we need to copy it into our buffer to
|
// Since format is const, we need to copy it into our buffer to
|
||||||
// add the line's null terminator and clobber value-matches with asterisks.
|
// add the line's null terminator and clobber value-matches with asterisks.
|
||||||
|
@ -181,7 +184,7 @@ int ATCmdParser::vscanf(const char *format, va_list args)
|
||||||
|
|
||||||
|
|
||||||
// Command parsing with line handling
|
// Command parsing with line handling
|
||||||
bool ATCmdParser::vsend(const char *command, va_list args)
|
bool ATCmdParser::vsend(const char *command, std::va_list args)
|
||||||
{
|
{
|
||||||
// Create and send command
|
// Create and send command
|
||||||
if (vsprintf(_buffer, command, args) < 0) {
|
if (vsprintf(_buffer, command, args) < 0) {
|
||||||
|
@ -205,7 +208,7 @@ bool ATCmdParser::vsend(const char *command, va_list args)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ATCmdParser::vrecv(const char *response, va_list args)
|
bool ATCmdParser::vrecv(const char *response, std::va_list args)
|
||||||
{
|
{
|
||||||
restart:
|
restart:
|
||||||
_aborted = false;
|
_aborted = false;
|
||||||
|
@ -331,7 +334,7 @@ restart:
|
||||||
// Mapping to vararg functions
|
// Mapping to vararg functions
|
||||||
int ATCmdParser::printf(const char *format, ...)
|
int ATCmdParser::printf(const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
std::va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
int res = vprintf(format, args);
|
int res = vprintf(format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
@ -340,7 +343,7 @@ int ATCmdParser::printf(const char *format, ...)
|
||||||
|
|
||||||
int ATCmdParser::scanf(const char *format, ...)
|
int ATCmdParser::scanf(const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
std::va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
int res = vscanf(format, args);
|
int res = vscanf(format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
@ -349,7 +352,7 @@ int ATCmdParser::scanf(const char *format, ...)
|
||||||
|
|
||||||
bool ATCmdParser::send(const char *command, ...)
|
bool ATCmdParser::send(const char *command, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
std::va_list args;
|
||||||
va_start(args, command);
|
va_start(args, command);
|
||||||
bool res = vsend(command, args);
|
bool res = vsend(command, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
@ -358,7 +361,7 @@ bool ATCmdParser::send(const char *command, ...)
|
||||||
|
|
||||||
bool ATCmdParser::recv(const char *response, ...)
|
bool ATCmdParser::recv(const char *response, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
std::va_list args;
|
||||||
va_start(args, response);
|
va_start(args, response);
|
||||||
bool res = vrecv(response, args);
|
bool res = vrecv(response, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
|
@ -202,7 +202,7 @@ public:
|
||||||
*/
|
*/
|
||||||
bool send(const char *command, ...) MBED_PRINTF_METHOD(1, 2);
|
bool send(const char *command, ...) MBED_PRINTF_METHOD(1, 2);
|
||||||
|
|
||||||
bool vsend(const char *command, va_list args);
|
bool vsend(const char *command, std::va_list args);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receive an AT response
|
* Receive an AT response
|
||||||
|
@ -220,7 +220,7 @@ public:
|
||||||
*/
|
*/
|
||||||
bool recv(const char *response, ...) MBED_SCANF_METHOD(1, 2);
|
bool recv(const char *response, ...) MBED_SCANF_METHOD(1, 2);
|
||||||
|
|
||||||
bool vrecv(const char *response, va_list args);
|
bool vrecv(const char *response, std::va_list args);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a single byte to the underlying stream
|
* Write a single byte to the underlying stream
|
||||||
|
@ -265,7 +265,7 @@ public:
|
||||||
*/
|
*/
|
||||||
int printf(const char *format, ...) MBED_PRINTF_METHOD(1, 2);
|
int printf(const char *format, ...) MBED_PRINTF_METHOD(1, 2);
|
||||||
|
|
||||||
int vprintf(const char *format, va_list args);
|
int vprintf(const char *format, std::va_list args);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Direct scanf on underlying stream
|
* Direct scanf on underlying stream
|
||||||
|
@ -277,7 +277,7 @@ public:
|
||||||
*/
|
*/
|
||||||
int scanf(const char *format, ...) MBED_SCANF_METHOD(1, 2);
|
int scanf(const char *format, ...) MBED_SCANF_METHOD(1, 2);
|
||||||
|
|
||||||
int vscanf(const char *format, va_list args);
|
int vscanf(const char *format, std::va_list args);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attach a callback for out-of-band data
|
* Attach a callback for out-of-band data
|
||||||
|
|
Loading…
Reference in New Issue