]> sigrok.org Git - libsigrok.git/blobdiff - src/input/binary.c
input/binary: align sr_session_send() chunks to unit size
[libsigrok.git] / src / input / binary.c
index 223efd88089bd1fa78f2eeaec0f429cab01829ec..51a64d099039c6ac859e3e6868f39c71e8ff0cbb 100644 (file)
@@ -29,7 +29,7 @@
 
 #define LOG_PREFIX "input/binary"
 
-#define MAX_CHUNK_SIZE       4096
+#define CHUNK_SIZE           (4 * 1024 * 1024)
 #define DEFAULT_NUM_CHANNELS 8
 #define DEFAULT_SAMPLERATE   0
 
@@ -102,7 +102,9 @@ static int process_buffer(struct sr_input *in)
 
        for (i = 0; i < chunk_size; i += chunk) {
                logic.data = in->buf->str + i;
-               chunk = MIN(MAX_CHUNK_SIZE, chunk_size - i);
+               chunk = MIN(CHUNK_SIZE, chunk_size - i);
+               chunk /= logic.unitsize;
+               chunk *= logic.unitsize;
                logic.length = chunk;
                sr_session_send(in->sdi, &packet);
        }
@@ -174,7 +176,7 @@ static const struct sr_option *get_options(void)
 SR_PRIV struct sr_input_module input_binary = {
        .id = "binary",
        .name = "Binary",
-       .desc = "Raw binary",
+       .desc = "Raw binary logic data",
        .exts = NULL,
        .options = get_options,
        .init = init,