X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=input%2Finput_chronovu_la8.c;h=adab9226c93627d6c61c6f5071db78b53a848132;hb=c37d2b1ba12b62d63590509879bf58adf842896d;hp=dc6a011777c70176c23da33aa088d52f419722ff;hpb=b08024a8363c7a019bebc05a25e2689e774326e8;p=libsigrok.git diff --git a/input/input_chronovu_la8.c b/input/input_chronovu_la8.c index dc6a0117..adab9226 100644 --- a/input/input_chronovu_la8.c +++ b/input/input_chronovu_la8.c @@ -77,7 +77,8 @@ static int format_match(const char *filename) static int init(struct sr_input *in) { - int num_probes; + int num_probes, i; + char name[SR_MAX_PROBENAME_LEN + 1]; if (in->param && in->param[0]) { num_probes = strtoul(in->param, NULL, 10); @@ -90,7 +91,13 @@ static int init(struct sr_input *in) } /* Create a virtual device. */ - in->vdevice = sr_device_new(NULL, 0, num_probes); + in->vdevice = sr_device_new(NULL, 0); + + for (i = 0; i < num_probes; i++) { + snprintf(name, SR_MAX_PROBENAME_LEN, "%d", i); + /* TODO: Check return value. */ + sr_device_probe_add(in->vdevice, name); + } return SR_OK; } @@ -99,6 +106,7 @@ static int loadfile(struct sr_input *in, const char *filename) { struct sr_datafeed_header header; struct sr_datafeed_packet packet; + struct sr_datafeed_logic logic; uint8_t buf[PACKET_SIZE], divcount; int i, fd, size, num_probes; uint64_t samplerate; @@ -125,14 +133,11 @@ static int loadfile(struct sr_input *in, const char *filename) /* Send header packet to the session bus. */ sr_dbg("la8input: %s: sending SR_DF_HEADER packet", __func__); packet.type = SR_DF_HEADER; - packet.length = sizeof(struct sr_datafeed_header); - packet.unitsize = 0; packet.payload = &header; header.feed_version = 1; gettimeofday(&header.starttime, NULL); header.num_logic_probes = num_probes; header.num_analog_probes = 0; - header.protocol_id = SR_PROTO_RAW; header.samplerate = samplerate; sr_session_bus(in->vdevice, &packet); @@ -141,14 +146,15 @@ static int loadfile(struct sr_input *in, const char *filename) /* Send data packets to the session bus. */ sr_dbg("la8input: %s: sending SR_DF_LOGIC data packets", __func__); packet.type = SR_DF_LOGIC; - packet.unitsize = (num_probes + 7) / 8; - packet.payload = buf; + packet.payload = &logic; + logic.unitsize = (num_probes + 7) / 8; + logic.data = buf; /* Send 8MB of total data to the session bus in small chunks. */ for (i = 0; i < NUM_PACKETS; i++) { /* TODO: Handle errors, handle incomplete reads. */ size = read(fd, buf, PACKET_SIZE); - packet.length = PACKET_SIZE; + logic.length = PACKET_SIZE; sr_session_bus(in->vdevice, &packet); } close(fd); /* FIXME */ @@ -156,8 +162,6 @@ static int loadfile(struct sr_input *in, const char *filename) /* Send end packet to the session bus. */ sr_dbg("la8input: %s: sending SR_DF_END", __func__); packet.type = SR_DF_END; - packet.length = 0; - packet.unitsize = 0; packet.payload = NULL; sr_session_bus(in->vdevice, &packet);