Skip to content

Commit

Permalink
Show detected protocol in raw view.
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Jan 4, 2023
1 parent 864cb66 commit de4d3ee
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
31 changes: 16 additions & 15 deletions app.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ struct ProtoViewTxRx {

typedef struct ProtoViewTxRx ProtoViewTxRx;

/* This stucture is filled by the decoder for specific protocols with the
* informations about the message. ProtoView will display such information
* in the message info view. */
#define PROTOVIEW_MSG_STR_LEN 16
typedef struct ProtoViewMsgInfo {
char name[PROTOVIEW_MSG_STR_LEN]; /* Protocol name and version. */
char raw[PROTOVIEW_MSG_STR_LEN]; /* Protocol specific raw representation.*/
/* The following is what the decoder wants to show to user. Each decoder
* can use the number of fileds it needs. */
char info1[16]; /* Protocol specific decoded string, line 1. */
char info2[16]; /* Protocol specific decoded string, line 2. */
char info3[16]; /* Protocol specific decoded string, line 3. */
uint64_t len; /* Bits consumed from the stream. */
} ProtoViewMsgInfo;

struct ProtoViewApp {
/* GUI */
Gui *gui;
Expand All @@ -80,6 +95,7 @@ struct ProtoViewApp {
int running; /* Once false exists the app. */
uint32_t signal_bestlen; /* Longest coherent signal observed so far. */
bool signal_decoded; /* Was the current signal decoded? */
ProtoViewMsgInfo signal_info; /* Decoded message, if signal_decoded true. */

/* Raw view apps state. */
uint32_t us_scale; /* microseconds per pixel. */
Expand All @@ -91,21 +107,6 @@ struct ProtoViewApp {
ProtoViewModulations table. */
};

/* This stucture is filled by the decoder for specific protocols with the
* informations about the message. ProtoView will display such information
* in the message info view. */
#define PROTOVIEW_MSG_STR_LEN 16
typedef struct ProtoViewMsgInfo {
char name[PROTOVIEW_MSG_STR_LEN]; /* Protocol name and version. */
char raw[PROTOVIEW_MSG_STR_LEN]; /* Protocol specific raw representation.*/
/* The following is what the decoder wants to show to user. Each decoder
* can use the number of fileds it needs. */
char info1[16]; /* Protocol specific decoded string, line 1. */
char info2[16]; /* Protocol specific decoded string, line 2. */
char info3[16]; /* Protocol specific decoded string, line 3. */
uint64_t len; /* Bits consumed from the stream. */
} ProtoViewMsgInfo;

typedef struct ProtoViewDecoder {
const char *name; /* Protocol name. */
/* The decode function takes a buffer that is actually a bitmap, with
Expand Down
4 changes: 2 additions & 2 deletions signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,11 @@ void scan_for_signal(ProtoViewApp *app) {

uint32_t i = 0;
while (i < copy->total-1) {
ProtoViewMsgInfo info;
uint32_t thislen = search_coherent_signal(copy,i);

/* For messages that are long enough, attempt decoding. */
if (thislen > minlen) {

ProtoViewMsgInfo info;
initialize_msg_info(&info);
uint32_t saved_idx = copy->idx; /* Save index, see later. */
/* decode_signal() expects the detected signal to start
Expand All @@ -157,6 +156,7 @@ void scan_for_signal(ProtoViewApp *app) {
if (thislen > app->signal_bestlen ||
(app->signal_decoded == false && decoded))
{
app->signal_info = info;
app->signal_bestlen = thislen;
app->signal_decoded = decoded;
raw_samples_copy(DetectedSamples,copy);
Expand Down
4 changes: 4 additions & 0 deletions view_raw_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ void render_view_raw_pulses(Canvas *const canvas, ProtoViewApp *app) {
(unsigned long)DetectedSamples->short_pulse_dur);
canvas_set_font(canvas, FontSecondary);
canvas_draw_str_with_border(canvas, 97, 63, buf, ColorWhite, ColorBlack);
if (app->signal_decoded) {
canvas_set_font(canvas, FontPrimary);
canvas_draw_str_with_border(canvas, 1, 61, app->signal_info.name, ColorWhite, ColorBlack);
}
}

/* Handle input for the raw pulses view. */
Expand Down

0 comments on commit de4d3ee

Please sign in to comment.