@@ -379,7 +379,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
379379 struct sr_datafeed_logic logic ;
380380 uint32_t sample ;
381381 int num_bytes_read ;
382- unsigned int i , j , num_changroups ;
382+ unsigned int num_changroups ;
383383 gboolean received_a_byte ;
384384
385385 (void )fd ;
@@ -394,7 +394,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
394394 }
395395
396396 num_changroups = 0 ;
397- for (i = 0x20 ; i > 0x02 ; i >>= 1 ) {
397+ for (uint16_t i = 0x20 ; i > 0x02 ; i >>= 1 ) {
398398 if ((devc -> capture_flags & i ) == 0 ) {
399399 num_changroups ++ ;
400400 }
@@ -431,8 +431,8 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
431431 if (devc -> raw_sample [devc -> raw_sample_size - 1 ] & 0x80 ) {
432432 /* Clear the high bit. */
433433 sample &= ~(0x80 << (devc -> raw_sample_size - 1 ) * 8 );
434- devc -> rle_count = sample ;
435- sr_dbg ("RLE count: %u." , devc -> rle_count );
434+ devc -> rle_count + = sample ;
435+ sr_dbg ("RLE count: %" PRIu64 , devc -> rle_count );
436436 devc -> raw_sample_size = 0 ;
437437
438438 if (devc -> trigger_at_smpl != OLS_NO_TRIGGER
@@ -458,9 +458,9 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
458458 * expecting a full 32-bit sample, based on
459459 * the number of channels.
460460 */
461- j = 0 ;
461+ unsigned int j = 0 ;
462462 uint8_t tmp_sample [4 ] = {0 ,0 ,0 ,0 };
463- for (i = 0 ; i < 4 ; i ++ ) {
463+ for (unsigned int i = 0 ; i < 4 ; i ++ ) {
464464 if (((devc -> capture_flags >> 2 ) & (1 << i )) == 0 ) {
465465 /*
466466 * This channel group was
@@ -476,11 +476,11 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
476476 devc -> raw_sample [0 ]);
477477 }
478478
479- unsigned int samples_to_write = devc -> rle_count + 1 ;
480- unsigned int new_sample_buf_size =
479+ uint64_t samples_to_write = devc -> rle_count + 1 ;
480+ uint64_t new_sample_buf_size =
481481 4 * MAX (devc -> limit_samples , devc -> cnt_samples + samples_to_write );
482482 if (devc -> sample_buf_size < new_sample_buf_size ) {
483- unsigned int old_size = devc -> sample_buf_size ;
483+ uint64_t old_size = devc -> sample_buf_size ;
484484 new_sample_buf_size *= 2 ;
485485 devc -> sample_buf = g_try_realloc (devc -> sample_buf , new_sample_buf_size );
486486 devc -> sample_buf_size = new_sample_buf_size ;
@@ -500,7 +500,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
500500 && (unsigned int )devc -> trigger_at_smpl == devc -> cnt_rx_raw_samples )
501501 devc -> trigger_rle_at_smpl_from_end = devc -> cnt_samples ;
502502
503- for (i = 0 ; i < samples_to_write ; i ++ )
503+ for (uint64_t i = 0 ; i < samples_to_write ; i ++ )
504504 memcpy (devc -> sample_buf + (devc -> cnt_samples + i ) * 4 , devc -> raw_sample ,
505505 4 );
506506
@@ -524,7 +524,8 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
524524 * we've acquired all the samples we asked for -- we're done.
525525 * Send the (properly-ordered) buffer to the frontend.
526526 */
527- sr_dbg ("Received %d bytes, %d raw samples, %d decompressed samples." ,
527+ sr_dbg (
528+ "Received %d bytes, %d raw samples, %" PRIu64 " decompressed samples." ,
528529 devc -> cnt_rx_bytes , devc -> cnt_rx_raw_samples ,
529530 devc -> cnt_samples );
530531
@@ -543,7 +544,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
543544 * The OLS sends its sample buffer backwards.
544545 * Flip it back before sending it on the session bus.
545546 */
546- for (i = 0 ; i < devc -> cnt_samples /2 ; i ++ ) {
547+ for (uint64_t i = 0 ; i < devc -> cnt_samples /2 ; i ++ ) {
547548 uint8_t temp [4 ];
548549 memcpy (temp , & devc -> sample_buf [4 * i ], 4 );
549550 memmove (& devc -> sample_buf [4 * i ],
@@ -726,7 +727,16 @@ SR_PRIV int ols_prepare_acquisition(const struct sr_dev_inst *sdi) {
726727 devc -> capture_flags &= ~0x3c ;
727728 devc -> capture_flags |= ~(changroup_mask << 2 ) & 0x3c ;
728729
729- /* RLE mode is always zero, for now. */
730+ /*
731+ * Demon Core supports RLE mode 3. In this mode, an arbitrary number of
732+ * consecutive RLE messages can occur. The value is only sent whenever
733+ * it changes. In contrast, mode 0 repeats the value after every RLE
734+ * message, even if it didn't change.
735+ */
736+ if (devc -> device_flags & DEVICE_FLAG_IS_DEMON_CORE )
737+ devc -> capture_flags |= CAPTURE_FLAG_RLEMODE0 | CAPTURE_FLAG_RLEMODE1 ;
738+ else
739+ devc -> capture_flags &= ~(CAPTURE_FLAG_RLEMODE0 | CAPTURE_FLAG_RLEMODE1 );
730740
731741 RETURN_ON_ERROR (ols_send_longdata (serial , CMD_SET_FLAGS , devc -> capture_flags ));
732742
0 commit comments