@@ -397,7 +397,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
397397 struct sr_datafeed_logic logic ;
398398 uint32_t sample ;
399399 int num_bytes_read ;
400- unsigned int i , j , num_changroups ;
400+ unsigned int num_changroups ;
401401 gboolean received_a_byte ;
402402
403403 (void )fd ;
@@ -412,7 +412,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
412412 }
413413
414414 num_changroups = 0 ;
415- for (i = 0x20 ; i > 0x02 ; i >>= 1 ) {
415+ for (uint16_t i = 0x20 ; i > 0x02 ; i >>= 1 ) {
416416 if ((devc -> capture_flags & i ) == 0 ) {
417417 num_changroups ++ ;
418418 }
@@ -433,7 +433,8 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
433433 devc -> raw_sample_size );
434434
435435 if (devc -> raw_sample_size == num_changroups ) {
436- unsigned int samples_to_write , new_sample_buf_size ;
436+ unsigned int samples_to_write ;
437+ uint64_t new_sample_buf_size ;
437438
438439 devc -> cnt_rx_raw_samples ++ ;
439440 /*
@@ -458,8 +459,8 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
458459 sample &= ~(0x80
459460 << (devc -> raw_sample_size -
460461 1 ) * 8 );
461- devc -> rle_count = sample ;
462- sr_dbg ("RLE count: %u." ,
462+ devc -> rle_count + = sample ;
463+ sr_dbg ("RLE count: %" PRIu64 ,
463464 devc -> rle_count );
464465 devc -> raw_sample_size = 0 ;
465466
@@ -490,9 +491,9 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
490491 * expecting a full 32-bit sample, based on
491492 * the number of channels.
492493 */
493- j = 0 ;
494+ unsigned int j = 0 ;
494495 uint8_t tmp_sample [4 ] = { 0 , 0 , 0 , 0 };
495- for (i = 0 ; i < 4 ; i ++ ) {
496+ for (unsigned int i = 0 ; i < 4 ; i ++ ) {
496497 if (((devc -> capture_flags >> 2 ) &
497498 (1 << i )) == 0 ) {
498499 /*
@@ -518,7 +519,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
518519 devc -> cnt_samples + samples_to_write );
519520
520521 if (devc -> sample_buf_size < new_sample_buf_size ) {
521- unsigned int old_size = devc -> sample_buf_size ;
522+ uint64_t old_size = devc -> sample_buf_size ;
522523 new_sample_buf_size *= 2 ;
523524 devc -> sample_buf = g_try_realloc (
524525 devc -> sample_buf , new_sample_buf_size );
@@ -542,7 +543,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
542543 devc -> trigger_rle_at_smpl_from_end =
543544 devc -> cnt_samples ;
544545
545- for (i = 0 ; i < samples_to_write ; i ++ )
546+ for (uint64_t i = 0 ; i < samples_to_write ; i ++ )
546547 memcpy (devc -> sample_buf +
547548 (devc -> cnt_samples + i ) * 4 ,
548549 devc -> raw_sample , 4 );
@@ -570,7 +571,8 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
570571 * we've acquired all the samples we asked for -- we're done.
571572 * Send the (properly-ordered) buffer to the frontend.
572573 */
573- sr_dbg ("Received %d bytes, %d raw samples, %d decompressed samples." ,
574+ sr_dbg ("Received %d bytes, %d raw samples, %" PRIu64
575+ " decompressed samples." ,
574576 devc -> cnt_rx_bytes , devc -> cnt_rx_raw_samples ,
575577 devc -> cnt_samples );
576578
@@ -591,7 +593,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
591593 * The OLS sends its sample buffer backwards.
592594 * Flip it back before sending it on the session bus.
593595 */
594- for (i = 0 ; i < devc -> cnt_samples / 2 ; i ++ ) {
596+ for (uint64_t i = 0 ; i < devc -> cnt_samples / 2 ; i ++ ) {
595597 uint8_t temp [4 ];
596598 memcpy (temp , & devc -> sample_buf [4 * i ], 4 );
597599 memmove (& devc -> sample_buf [4 * i ],
@@ -803,7 +805,18 @@ SR_PRIV int ols_prepare_acquisition(const struct sr_dev_inst *sdi)
803805 devc -> capture_flags &= ~0x3c ;
804806 devc -> capture_flags |= ~(changroup_mask << 2 ) & 0x3c ;
805807
806- /* RLE mode is always zero, for now. */
808+ /*
809+ * Demon Core supports RLE mode 3. In this mode, an arbitrary number of
810+ * consecutive RLE messages can occur. The value is only sent whenever
811+ * it changes. In contrast, mode 0 repeats the value after every RLE
812+ * message, even if it didn't change.
813+ */
814+ if (devc -> device_flags & DEVICE_FLAG_IS_DEMON_CORE )
815+ devc -> capture_flags |= CAPTURE_FLAG_RLEMODE0 |
816+ CAPTURE_FLAG_RLEMODE1 ;
817+ else
818+ devc -> capture_flags &=
819+ ~(CAPTURE_FLAG_RLEMODE0 | CAPTURE_FLAG_RLEMODE1 );
807820
808821 if (ols_send_longdata (serial , CMD_SET_FLAGS , devc -> capture_flags ) != SR_OK )
809822 return SR_ERR ;
0 commit comments