Przeglądaj źródła

Show detected protocol in raw view.

antirez 3 lat temu
rodzic
commit
de4d3eed5d
3 zmienionych plików z 22 dodań i 17 usunięć
  1. 16 15
      app.h
  2. 2 2
      signal.c
  3. 4 0
      view_raw_signal.c

+ 16 - 15
app.h

@@ -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;
@@ -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. */
@@ -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

+ 2 - 2
signal.c

@@ -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
@@ -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);

+ 4 - 0
view_raw_signal.c

@@ -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. */