X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fdreamsourcelab-dslogic%2Fprotocol.c;h=bb98d61a4b4f467f4eafa5cfb5d487b6a20f79ac;hb=7f0463840ab5d6a85daaa76850558d2b71e596cf;hp=90b773d9cf970fe34d48193cea23de0792d046f5;hpb=55584d38ddd52ab0952faed16b5aeff21ddcca34;p=libsigrok.git diff --git a/src/hardware/dreamsourcelab-dslogic/protocol.c b/src/hardware/dreamsourcelab-dslogic/protocol.c index 90b773d9..bb98d61a 100644 --- a/src/hardware/dreamsourcelab-dslogic/protocol.c +++ b/src/hardware/dreamsourcelab-dslogic/protocol.c @@ -568,7 +568,9 @@ SR_PRIV int dslogic_dev_open(struct sr_dev_inst *sdi, struct sr_dev_driver *di) if ((sdi->status == SR_ST_INITIALIZING) || (sdi->status == SR_ST_INACTIVE)) { /* Check device by its physical USB bus/port address. */ - usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)); + if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0) + continue; + if (strcmp(sdi->connection_id, connection_id)) /* This is not the one. */ continue; @@ -738,7 +740,7 @@ static void deinterleave_buffer(const uint8_t *src, size_t length, const uint16_t m = channel_mask >> channel; if (!m) break; - if ((m & 1) && ((*word_ptr++ >> bit) & 1ULL)) + if ((m & 1) && ((*word_ptr++ >> bit) & UINT64_C(1))) sample |= 1 << channel; } *dst_ptr++ = sample; @@ -774,7 +776,6 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer) (DSLOGIC_ATOMIC_BYTES * channel_count); gboolean packet_has_error = FALSE; - struct sr_datafeed_packet packet; unsigned int num_samples; int trigger_offset; @@ -854,9 +855,7 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer) devc->sent_samples += trigger_offset; /* Trigger position. */ devc->trigger_pos = 0; - packet.type = SR_DF_TRIGGER; - packet.payload = NULL; - sr_session_send(sdi, &packet); + std_session_send_df_trigger(sdi); /* Post trigger samples. */ num_samples -= trigger_offset; send_data(sdi, devc->deinterleave_buffer @@ -914,6 +913,8 @@ static size_t get_buffer_size(const struct sr_dev_inst *sdi) */ const size_t block_size = enabled_channel_count(sdi) * 512; const size_t s = 10 * to_bytes_per_ms(sdi); + if (!block_size) + return s; return ((s + block_size - 1) / block_size) * block_size; } @@ -1016,8 +1017,8 @@ static void LIBUSB_CALL trigger_receive(struct libusb_transfer *transfer) } else if (transfer->status == LIBUSB_TRANSFER_COMPLETED && transfer->actual_length == sizeof(struct dslogic_trigger_pos)) { tpos = (struct dslogic_trigger_pos *)transfer->buffer; - sr_info("tpos real_pos %d ram_saddr %d cnt %d", tpos->real_pos, - tpos->ram_saddr, tpos->remain_cnt); + sr_info("tpos real_pos %d ram_saddr %d cnt_h %d cnt_l %d", tpos->real_pos, + tpos->ram_saddr, tpos->remain_cnt_h, tpos->remain_cnt_l); devc->trigger_pos = tpos->real_pos; g_free(tpos); start_transfers(sdi);