]> sigrok.org Git - libsigrok.git/blobdiff - src/input/protocoldata.c
output/csv: use intermediate time_t var, silence compiler warning
[libsigrok.git] / src / input / protocoldata.c
index 6be96f1863c9d9a432f0f55e23f5db711e127a5d..905e33e4b2a3bbb2836ada750b4e42e2d94f576c 100644 (file)
@@ -607,7 +607,7 @@ static int assign_bit_widths(struct context *inc)
                bit_times_total += bit_time_int;
                sr_spew("Bit %zu, width %" PRIu64 ".", idx, bit_time_int);
        }
-       sr_dbg("Maximum waveform width: %zu slots, %.2f / %zu samples.",
+       sr_dbg("Maximum waveform width: %zu slots, %.2f / %" PRIu64 " samples.",
                inc->max_frame_bits, bit_edge, bit_times_total);
 
        return SR_OK;
@@ -713,11 +713,9 @@ static int send_idle_capture(struct context *inc)
        if (ret != SR_OK)
                return ret;
        count *= inc->curr_opts.samples_per_bit;
-       while (count--) {
-               ret = feed_queue_logic_submit(inc->feed_logic, &data, sizeof(data));
-               if (ret != SR_OK)
-                       return ret;
-       }
+       ret = feed_queue_logic_submit_one(inc->feed_logic, &data, count);
+       if (ret != SR_OK)
+               return ret;
 
        return SR_OK;
 }
@@ -737,11 +735,9 @@ static int send_idle_interframe(struct context *inc)
        ret = handler->get_idle_interframe(inc, &count, &data);
        if (ret != SR_OK)
                return ret;
-       while (count--) {
-               ret = feed_queue_logic_submit(inc->feed_logic, &data, sizeof(data));
-               if (ret != SR_OK)
-                       return ret;
-       }
+       ret = feed_queue_logic_submit_one(inc->feed_logic, &data, count);
+       if (ret != SR_OK)
+               return ret;
 
        return SR_OK;
 }
@@ -752,16 +748,17 @@ static int send_frame(struct sr_input *in)
        struct context *inc;
        size_t count, index;
        uint8_t data;
+       int ret;
 
        inc = in->priv;
 
        for (index = 0; index < inc->top_frame_bits; index++) {
                data = inc->sample_levels[index];
                count = inc->sample_widths[index];
-               while (count--) {
-                       feed_queue_logic_submit(inc->feed_logic,
-                               &data, sizeof(data));
-               }
+               ret = feed_queue_logic_submit_one(inc->feed_logic,
+                       &data, count);
+               if (ret != SR_OK)
+                       return ret;
        }
 
        return SR_OK;
@@ -882,7 +879,7 @@ static int uart_check_opts(struct context *inc)
        total_bits += fmt_opts->stopbit_count;
        total_bits += fmt_opts->half_stopbit ? 1 : 0;
        total_bits += UART_ADD_IDLEBITS;
-       sr_dbg("UART frame: total bits %lu.", total_bits);
+       sr_dbg("UART frame: total bits %zu.", total_bits);
        if (total_bits > UART_MAX_WAVELEN)
                return SR_ERR_DATA;
        inc->max_frame_bits = total_bits;
@@ -1553,7 +1550,7 @@ static int spi_check_opts(struct context *inc)
        total_bits += 2 * fmt_opts->databit_count;
        total_bits += 3;
 
-       sr_dbg("SPI frame: total bits %lu.", total_bits);
+       sr_dbg("SPI frame: total bits %zu.", total_bits);
        if (total_bits > SPI_MAX_WAVELEN)
                return SR_ERR_DATA;
        inc->max_frame_bits = total_bits;
@@ -2173,7 +2170,7 @@ static int i2c_check_opts(struct context *inc)
        total_bits *= I2C_BITTIME_QUANTA;
        total_bits += I2C_ADD_IDLESLOTS;
 
-       sr_dbg("I2C frame: total bits %lu.", total_bits);
+       sr_dbg("I2C frame: total bits %zu.", total_bits);
        if (total_bits > I2C_MAX_WAVELEN)
                return SR_ERR_DATA;
        inc->max_frame_bits = total_bits;
@@ -2411,10 +2408,14 @@ static int i2c_get_idle_interframe(struct context *inc,
        size_t *samplecount, uint8_t *sample)
 {
 
-       /* Describe four bit times, re-use the current pin levels. */
+       /*
+        * The space around regular bytes already is sufficient. We
+        * don't need to generate an inter-frame gap, but the code is
+        * prepared to in case we want to in the future.
+        */
        if (samplecount) {
                *samplecount = inc->curr_opts.samples_per_bit;
-               *samplecount *= 4;
+               *samplecount *= 0;
        }
        if (sample)
                *sample = inc->samples.curr_levels;
@@ -2874,8 +2875,7 @@ static int process_textline(struct sr_input *in, char *line)
        struct context *inc;
        const struct proto_handler_t *handler;
        gboolean is_comm, is_pseudo;
-       char *word;
-       char *endp;
+       char *p, *word, *endp;
        unsigned long value;
        int ret;
 
@@ -2927,11 +2927,16 @@ static int process_textline(struct sr_input *in, char *line)
        /*
         * Non-empty non-comment lines carry protocol values.
         * (Empty lines are handled transparently when they get here.)
+        * Accept comma and semicolon separators for user convenience.
         * Convert text according to previously received instructions.
         * Pass the values to the protocol handler. Flush waveforms
         * when handlers state that their construction has completed.
         */
        sr_spew("got values line: %s", line);
+       for (p = line; *p; p++) {
+               if (*p == ',' || *p == ';')
+                       *p = ' ';
+       }
        while (line) {
                word = sr_text_next_word(line, &line);
                if (!word)