26 #include "sigrok-internal.h"
28 #define NUM_PACKETS 2048
29 #define PACKET_SIZE 4096
30 #define DEFAULT_NUM_PROBES 8
43 static uint64_t divcount_to_samplerate(uint8_t divcount)
46 return 0xffffffffffffffffULL;
48 return SR_MHZ(100) / (divcount + 1);
51 static int format_match(
const char *filename)
57 sr_err(
"la8 in: %s: filename was NULL", __func__);
62 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
63 sr_err(
"la8 in: %s: input file '%s' does not exist",
69 if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) {
70 sr_err(
"la8 in: %s: input file '%s' not a regular file",
77 ret = stat(filename, &stat_buf);
79 sr_err(
"la8 in: %s: Error getting file size of '%s'",
83 if (stat_buf.st_size != (8 * 1024 * 1024 + 5)) {
84 sr_dbg(
"la8 in: %s: File size must be exactly 8388613 bytes ("
85 "it actually is %d bytes in size), so this is not a "
86 "ChronoVu LA8 file.", __func__, stat_buf.st_size);
101 num_probes = strtoul(in->
param, NULL, 10);
102 if (num_probes < 1) {
103 sr_err(
"la8 in: %s: strtoul failed", __func__);
113 for (i = 0; i < num_probes; i++) {
122 static int loadfile(
struct sr_input *in,
const char *filename)
128 int i, fd, size, num_probes;
132 if ((fd = open(filename, O_RDONLY)) == -1) {
133 sr_err(
"la8 in: %s: file open failed", __func__);
137 num_probes = g_slist_length(in->
vdev->
probes);
143 samplerate = divcount_to_samplerate(divcount);
144 if (samplerate == 0xffffffffffffffffULL) {
148 sr_dbg(
"la8 in: %s: samplerate is %" PRIu64, __func__, samplerate);
151 sr_dbg(
"la8 in: %s: sending SR_DF_HEADER packet", __func__);
153 packet.payload = &header;
154 header.feed_version = 1;
155 gettimeofday(&header.starttime, NULL);
156 header.num_logic_probes = num_probes;
157 header.samplerate = samplerate;
163 sr_dbg(
"la8 in: %s: sending SR_DF_LOGIC data packets", __func__);
165 packet.payload = &logic;
166 logic.unitsize = (num_probes + 7) / 8;
179 sr_dbg(
"la8 in: %s: sending SR_DF_END", __func__);
181 packet.payload = NULL;
188 .
id =
"chronovu-la8",
189 .description =
"ChronoVu LA8",