From: Gerhard Sittig Date: Sun, 23 Apr 2017 11:29:51 +0000 (+0200) Subject: asix-sigma: Fixed RLE decoder X-Git-Tag: libsigrok-0.5.0~49 X-Git-Url: https://sigrok.org/gitweb/?a=commitdiff_plain;h=a44b3b3f166e60e1023371f0cf47bbd68182f0bf;hp=42be2adb5ab329a0b22d9df392d8eca84d5d9acf;p=libsigrok.git asix-sigma: Fixed RLE decoder When "tsdiff < EVENTS_PER_CLUSTER" we don't want "tsdiff - EVENTS_PER_CLUSTER" (a negative number) to be treated as (int). Submitted-By: jry [ gsi: massaged for mainline submission ] --- diff --git a/src/hardware/asix-sigma/protocol.c b/src/hardware/asix-sigma/protocol.c index d2670b4c..94d1fed6 100644 --- a/src/hardware/asix-sigma/protocol.c +++ b/src/hardware/asix-sigma/protocol.c @@ -723,7 +723,7 @@ static void sigma_decode_dram_cluster(struct sigma_dram_cluster *dram_cluster, ts = sigma_dram_cluster_ts(dram_cluster); tsdiff = ts - ss->lastts; - ss->lastts = ts; + ss->lastts = ts + EVENTS_PER_CLUSTER; packet.type = SR_DF_LOGIC; packet.payload = &logic; @@ -741,7 +741,7 @@ static void sigma_decode_dram_cluster(struct sigma_dram_cluster *dram_cluster, * sample in the cluster happens at the time of the timestamp * and the remaining samples happen at timestamp +1...+6 . */ - for (ts = 0; ts < tsdiff - (EVENTS_PER_CLUSTER - 1); ts++) { + for (ts = 0; ts < tsdiff; ts++) { i = ts % 1024; samples[2 * i + 0] = ss->lastsample & 0xff; samples[2 * i + 1] = ss->lastsample >> 8; @@ -751,7 +751,7 @@ static void sigma_decode_dram_cluster(struct sigma_dram_cluster *dram_cluster, * end of submitting the padding samples, submit * the packet to Sigrok. */ - if ((i == 1023) || (ts == (tsdiff - EVENTS_PER_CLUSTER))) { + if ((i == 1023) || (ts == tsdiff - 1)) { logic.length = (i + 1) * logic.unitsize; sr_session_send(sdi, &packet); }