Add debug output for mavlink sent and received frames.

debug.interactive_io can be used to pause after sending or receiving a packet.
This commit is contained in:
gardners 2013-09-01 17:33:32 +09:30 committed by Jeremy Lakeman
parent 6d273eb966
commit fa157500b3
4 changed files with 25 additions and 4 deletions

View File

@ -235,12 +235,14 @@ ATOM(bool_t, queues, 0, boolean,, "")
ATOM(bool_t, timing, 0, boolean,, "") ATOM(bool_t, timing, 0, boolean,, "")
ATOM(bool_t, io, 0, boolean,, "") ATOM(bool_t, io, 0, boolean,, "")
ATOM(bool_t, verbose_io, 0, boolean,, "") ATOM(bool_t, verbose_io, 0, boolean,, "")
ATOM(bool_t, interactive_io, 0, boolean,, "")
ATOM(bool_t, packetformats, 0, boolean,, "") ATOM(bool_t, packetformats, 0, boolean,, "")
ATOM(bool_t, gateway, 0, boolean,, "") ATOM(bool_t, gateway, 0, boolean,, "")
ATOM(bool_t, keyring, 0, boolean,, "") ATOM(bool_t, keyring, 0, boolean,, "")
ATOM(bool_t, security, 0, boolean,, "") ATOM(bool_t, security, 0, boolean,, "")
ATOM(bool_t, mdprequests, 0, boolean,, "") ATOM(bool_t, mdprequests, 0, boolean,, "")
ATOM(bool_t, mavlink, 0, boolean,, "") ATOM(bool_t, mavlink, 0, boolean,, "")
ATOM(bool_t, mavlink_payloads, 0, boolean,, "")
ATOM(bool_t, mavlinkfsm, 0, boolean,, "") ATOM(bool_t, mavlinkfsm, 0, boolean,, "")
ATOM(bool_t, peers, 0, boolean,, "") ATOM(bool_t, peers, 0, boolean,, "")
ATOM(bool_t, overlayframes, 0, boolean,, "") ATOM(bool_t, overlayframes, 0, boolean,, "")

2
log.h
View File

@ -107,6 +107,8 @@ void logConfigChanged();
int logDump(int level, struct __sourceloc whence, char *name, const unsigned char *addr, size_t len); int logDump(int level, struct __sourceloc whence, char *name, const unsigned char *addr, size_t len);
ssize_t get_self_executable_path(char *buf, size_t len); ssize_t get_self_executable_path(char *buf, size_t len);
int log_backtrace(int level, struct __sourceloc whence); int log_backtrace(int level, struct __sourceloc whence);
void logServalPacket(int level, struct __sourceloc __whence, const char *message, const unsigned char *packet, size_t len);
struct strbuf; struct strbuf;
#define __HERE__ ((struct __sourceloc){ .file = __FILE__, .line = __LINE__, .function = __FUNCTION__ }) #define __HERE__ ((struct __sourceloc){ .file = __FILE__, .line = __LINE__, .function = __FUNCTION__ })

View File

@ -48,7 +48,6 @@ struct sockaddr_in sock_any_addr;
struct profile_total sock_any_stats; struct profile_total sock_any_stats;
static void overlay_interface_poll(struct sched_ent *alarm); static void overlay_interface_poll(struct sched_ent *alarm);
static void logServalPacket(int level, struct __sourceloc __whence, const char *message, const unsigned char *packet, size_t len);
static int re_init_socket(int interface_index); static int re_init_socket(int interface_index);
#define DEBUG_packet_visualise(M,P,N) logServalPacket(LOG_LEVEL_DEBUG, __WHENCE__, (M), (P), (N)) #define DEBUG_packet_visualise(M,P,N) logServalPacket(LOG_LEVEL_DEBUG, __WHENCE__, (M), (P), (N))
@ -1128,8 +1127,7 @@ void overlay_interface_discover(struct sched_ent *alarm)
return; return;
} }
static void void logServalPacket(int level, struct __sourceloc __whence, const char *message, const unsigned char *packet, size_t len) {
logServalPacket(int level, struct __sourceloc __whence, const char *message, const unsigned char *packet, size_t len) {
struct mallocbuf mb = STRUCT_MALLOCBUF_NULL; struct mallocbuf mb = STRUCT_MALLOCBUF_NULL;
if (!message) message="<no message>"; if (!message) message="<no message>";
if (serval_packetvisualise_xpf(XPRINTF_MALLOCBUF(&mb), message, packet, len) == -1) if (serval_packetvisualise_xpf(XPRINTF_MALLOCBUF(&mb), message, packet, len) == -1)

21
slip.c
View File

@ -21,6 +21,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "conf.h" #include "conf.h"
#include "log.h" #include "log.h"
#define DEBUG_packet_visualise(M,P,N) logServalPacket(LOG_LEVEL_DEBUG, __WHENCE__, (M), (P), (N))
/* SLIP-style escape characters used for serial packet radio interfaces */ /* SLIP-style escape characters used for serial packet radio interfaces */
#define SLIP_END 0xc0 #define SLIP_END 0xc0
#define SLIP_ESC 0xdb #define SLIP_ESC 0xdb
@ -70,7 +72,15 @@ int slip_encode(int format,
if (config.debug.mavlink) { if (config.debug.mavlink) {
DEBUGF("Wrote %d byte packet as MAVLink frames",src_bytes); DEBUGF("Wrote %d byte packet as MAVLink frames",src_bytes);
} }
if (config.debug.mavlink_payloads||config.debug.interactive_io) {
DEBUG_packet_visualise("Packet Sent",src,src_bytes);
}
if (config.debug.interactive_io) {
fprintf(stderr,"Press ENTER to continue..."); fflush(stderr);
char buffer[80];
if (!fgets(buffer,80,stdin))
FATAL_perror("calling fgets");
}
return dst_offset; return dst_offset;
} }
break; break;
@ -390,6 +400,15 @@ int slip_decode(struct slip_decode_state *state)
if (config.debug.mavlink) { if (config.debug.mavlink) {
DEBUGF("Read %d byte packet from MAVLink frames",state->packet_length); DEBUGF("Read %d byte packet from MAVLink frames",state->packet_length);
} }
if (config.debug.mavlink_payloads||config.debug.interactive_io) {
DEBUG_packet_visualise("Received packet",state->dst,state->packet_length);
}
if (config.debug.interactive_io) {
fprintf(stderr,"Press ENTER to continue..."); fflush(stderr);
char buffer[80];
if (!fgets(buffer,80,stdin))
FATAL_perror("calling fgets");
}
return 1; return 1;
} }
} }