From: Bert Vermeulen Date: Thu, 6 May 2010 02:55:58 +0000 (-0700) Subject: input: use dummy device when loading from file X-Git-Tag: libsigrok-0.1.0~523 X-Git-Url: https://sigrok.org/gitweb/?a=commitdiff_plain;h=db91a1c3c1e798610542b9749191fc89f15c5ccd;p=libsigrok.git input: use dummy device when loading from file --- diff --git a/input/input_binary.c b/input/input_binary.c index a6c6005a..27e8fa4d 100644 --- a/input/input_binary.c +++ b/input/input_binary.c @@ -37,37 +37,42 @@ static int format_match(char *filename) } -/* TODO: number of probes hardcoded to 8 */ static int in_loadfile(char *filename) { struct datafeed_header header; struct datafeed_packet packet; + struct device *device; char buffer[CHUNKSIZE]; - int fd, size; + int fd, size, num_probes; if( (fd = open(filename, O_RDONLY)) == -1) return SIGROK_ERR; + /* TODO: number of probes hardcoded to 8 */ + num_probes = 8; + device = device_new(NULL, 0, num_probes); + header.feed_version = 1; - header.num_probes = 8; + header.num_probes = num_probes; header.protocol_id = PROTO_RAW; header.samplerate = 0; gettimeofday(&header.starttime, NULL); packet.type = DF_HEADER; packet.length = sizeof(struct datafeed_header); packet.payload = &header; - session_bus(NULL, &packet); + session_bus(device, &packet); packet.type = DF_LOGIC8; packet.payload = buffer; while( (size = read(fd, buffer, CHUNKSIZE)) > 0) { packet.length = size; - session_bus(NULL, &packet); + session_bus(device, &packet); } close(fd); packet.type = DF_END; - session_bus(NULL, &packet); + packet.length = 0; + session_bus(device, &packet); return SIGROK_OK;