From: Uwe Hermann Date: Tue, 1 Apr 2014 21:23:23 +0000 (+0200) Subject: chronovu-la: Fix byte order for LA16 samples sent to the bus. X-Git-Tag: libsigrok-0.3.0~94 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=05266f36a5d4cd9371983bb5f659266489327af2;p=libsigrok.git chronovu-la: Fix byte order for LA16 samples sent to the bus. --- diff --git a/hardware/chronovu-la/protocol.c b/hardware/chronovu-la/protocol.c index 28ac15be..5b4723c2 100644 --- a/hardware/chronovu-la/protocol.c +++ b/hardware/chronovu-la/protocol.c @@ -417,8 +417,8 @@ SR_PRIV int cv_read_block(struct dev_context *devc) SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int block) { - int i; - uint8_t sample, expected_sample; + int i, idx; + uint8_t sample, expected_sample, tmp8; struct sr_datafeed_packet packet; struct sr_datafeed_logic logic; int trigger_point; /* Relative trigger point (in this block). */ @@ -452,6 +452,16 @@ SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int block) } } + /* Swap low and high bytes of the 16-bit LA16 samples. */ + if (devc->prof->model == CHRONOVU_LA16) { + for (i = 0; i < BS; i += 2) { + idx = (block * BS) + i; + tmp8 = devc->final_buf[idx]; + devc->final_buf[idx] = devc->final_buf[idx + 1]; + devc->final_buf[idx + 1] = tmp8; + } + } + /* If no trigger was found, send one SR_DF_LOGIC packet. */ if (trigger_point == -1) { /* Send an SR_DF_LOGIC packet to the session bus. */