X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fbrymen-bm86x%2Fprotocol.c;h=a5531109d71913ad11bfbc88849ad2eae0f9e570;hb=15a5bfe4815f9991a9bb532c05d6244a1818a0e4;hp=74101518ce25fe6401a2571adc6b44a4ac17b336;hpb=6433156c3275df933e4bf6dcfb020c91fca0ae86;p=libsigrok.git diff --git a/src/hardware/brymen-bm86x/protocol.c b/src/hardware/brymen-bm86x/protocol.c index 74101518..a5531109 100644 --- a/src/hardware/brymen-bm86x/protocol.c +++ b/src/hardware/brymen-bm86x/protocol.c @@ -17,6 +17,7 @@ * along with this program. If not, see . */ +#include #include #include #include "protocol.h" @@ -72,7 +73,7 @@ static int brymen_bm86x_parse_digits(const unsigned char *buf, int length, } static void brymen_bm86x_parse(unsigned char *buf, float *floatval, - struct sr_datafeed_analog *analog) + struct sr_datafeed_analog_old *analog) { char str[16], temp_unit; int ret1, ret2, over_limit; @@ -194,7 +195,7 @@ static void brymen_bm86x_handle_packet(const struct sr_dev_inst *sdi, { struct dev_context *devc; struct sr_datafeed_packet packet; - struct sr_datafeed_analog analog[2]; + struct sr_datafeed_analog_old analog[2]; float floatval[2]; devc = sdi->priv; @@ -212,7 +213,7 @@ static void brymen_bm86x_handle_packet(const struct sr_dev_inst *sdi, analog[0].num_samples = 1; analog[0].data = &floatval[0]; analog[0].channels = g_slist_append(NULL, sdi->channels->data); - packet.type = SR_DF_ANALOG; + packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog[0]; sr_session_send(sdi, &packet); g_slist_free(analog[0].channels); @@ -223,14 +224,14 @@ static void brymen_bm86x_handle_packet(const struct sr_dev_inst *sdi, analog[1].num_samples = 1; analog[1].data = &floatval[1]; analog[1].channels = g_slist_append(NULL, sdi->channels->next->data); - packet.type = SR_DF_ANALOG; + packet.type = SR_DF_ANALOG_OLD; packet.payload = &analog[1]; sr_session_send(sdi, &packet); g_slist_free(analog[1].channels); } if (analog[0].mq != -1 || analog[1].mq != -1) - devc->num_samples++; + sr_sw_limits_update_samples_read(&devc->sw_limits, 1); } static int brymen_bm86x_send_command(const struct sr_dev_inst *sdi) @@ -257,7 +258,7 @@ static int brymen_bm86x_send_command(const struct sr_dev_inst *sdi) } if (ret != sizeof(buf)) { - sr_err("Short packet: sent %d/%ld bytes.", ret, sizeof(buf)); + sr_err("Short packet: sent %d/%zu bytes.", ret, sizeof(buf)); return SR_ERR; } @@ -307,7 +308,6 @@ SR_PRIV int brymen_bm86x_receive_data(int fd, int revents, void *cb_data) { struct sr_dev_inst *sdi; struct dev_context *devc; - int64_t time; (void)fd; (void)revents; @@ -327,20 +327,8 @@ SR_PRIV int brymen_bm86x_receive_data(int fd, int revents, void *cb_data) if (brymen_bm86x_read_interrupt(sdi)) return FALSE; - if (devc->limit_samples && devc->num_samples >= devc->limit_samples) { - sr_info("Requested number of samples reached, stopping."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); - return TRUE; - } - - if (devc->limit_msec) { - time = (g_get_monotonic_time() - devc->start_time) / 1000; - if (time > (int64_t)devc->limit_msec) { - sr_info("Requested time limit reached, stopping."); - sdi->driver->dev_acquisition_stop(sdi, cb_data); - return TRUE; - } - } + if (sr_sw_limits_check(&devc->sw_limits)) + sdi->driver->dev_acquisition_stop(sdi); return TRUE; }