2 * This file is part of the sigrok project.
4 * Copyright (C) 2010 Bert Vermeulen <bert@biot.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <sys/types.h>
27 #define CHUNKSIZE 4096
29 static int format_match(const char *filename)
35 static int in_loadfile(const char *filename)
37 struct datafeed_header header;
38 struct datafeed_packet packet;
39 struct device *device;
40 char buffer[CHUNKSIZE];
41 int fd, size, num_probes;
43 if ((fd = open(filename, O_RDONLY)) == -1)
46 /* TODO: Number of probes is hardcoded to 8. */
48 device = device_new(NULL, 0, num_probes);
50 header.feed_version = 1;
51 header.num_probes = num_probes;
52 header.protocol_id = PROTO_RAW;
53 header.samplerate = 0;
54 gettimeofday(&header.starttime, NULL);
55 packet.type = DF_HEADER;
56 packet.length = sizeof(struct datafeed_header);
57 packet.payload = &header;
58 session_bus(device, &packet);
60 packet.type = DF_LOGIC;
62 packet.payload = buffer;
63 while ((size = read(fd, buffer, CHUNKSIZE)) > 0) {
65 session_bus(device, &packet);
71 session_bus(device, &packet);
76 struct input_format input_binary = {