~awe/phablet-extras/ofono-socket-exit

« back to all changes in this revision

Viewing changes to gril/gril.h

  • Committer: Tarmac
  • Author(s): Tony Espy
  • Date: 2013-06-15 00:02:41 UTC
  • mfrom: (38.2.13 ofono-debug-refactor)
  • Revision ID: tarmac-20130615000241-n6lmwvw9gpw80gsx
[gril/rilmodem] Add conditional build-time logic to RIL command tracing, and low-level gril logging.

Approved by Ricardo Salveti, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
 
55
55
typedef void (*GRilNotifyFunc)(struct ril_msg *message, gpointer user_data);
56
56
 
 
57
/**
 
58
 * TRACE:
 
59
 * @fmt: format string
 
60
 * @arg...: list of arguments
 
61
 *
 
62
 * Simple macro around ofono_debug() used for tracing RIL messages
 
63
 * name it is called in.
 
64
 */
 
65
#define G_RIL_TRACE(gril, fmt, arg...) do {     \
 
66
        if (g_ril_get_trace(gril))              \
 
67
                ofono_debug(fmt, ## arg);       \
 
68
} while (0)
 
69
 
 
70
#define RIL_PRINT_BUF_SIZE 8096
 
71
static char print_buf[RIL_PRINT_BUF_SIZE] __attribute__((used));
 
72
 
 
73
#define g_ril_print_request(gril, token, req)                   \
 
74
        G_RIL_TRACE(gril, "[%04d]> %s %s", token, ril_request_id_to_string(req), print_buf)
 
75
#define g_ril_print_request_no_args(gril, token, req)                   \
 
76
        G_RIL_TRACE(gril, "[%04d]> %s", token, ril_request_id_to_string(req))
 
77
#define g_ril_print_response(gril, message)           \
 
78
        G_RIL_TRACE(gril, "[%04d]< %s %s", message->serial_no,                  \
 
79
                        ril_request_id_to_string(message->req), print_buf)
 
80
#define g_ril_print_response_no_args(gril, message)             \
 
81
        G_RIL_TRACE(gril, "[%04d]< %s", message->serial_no,     \
 
82
                        ril_request_id_to_string(message->req))
 
83
 
 
84
#define g_ril_append_print_buf(gril, x...)  do {    \
 
85
        if (g_ril_get_trace(gril))                  \
 
86
                sprintf(print_buf, x);              \
 
87
} while (0)
 
88
 
 
89
#define g_ril_print_unsol(gril, message)                                        \
 
90
        G_RIL_TRACE(gril, "[UNSOL]< %s %s", ril_unsol_request_to_string(message->req), \
 
91
                        print_buf)
 
92
#define g_ril_print_unsol_no_args(gril, message)                                \
 
93
        G_RIL_TRACE(gril, "[UNSOL]< %s", ril_unsol_request_to_string(message->req))
 
94
 
57
95
GRil *g_ril_new();
58
96
 
59
97
GIOChannel *g_ril_get_channel(GRil *ril);
70
108
gboolean g_ril_set_disconnect_function(GRil *ril, GRilDisconnectFunc disconnect,
71
109
                                        gpointer user_data);
72
110
 
 
111
gboolean g_ril_get_trace(GRil *ril);
 
112
gboolean g_ril_set_trace(GRil *ril, gboolean trace);
 
113
 
73
114
/*!
74
115
 * If the function is not NULL, then on every read/write from the GIOChannel
75
116
 * provided to GRil the logging function will be called with the
76
117
 * input/output string and user data
77
118
 */
78
 
gboolean g_ril_set_debug(GRil *ril, GRilDebugFunc func, gpointer user_data);
 
119
gboolean g_ril_set_debugf(GRil *ril, GRilDebugFunc func, gpointer user_data);
79
120
 
80
121
/*!
81
122
 * Queue an RIL request for execution.  The request contents are given