#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+#ifndef _WIN32
#include <termios.h>
+#endif
#include <string.h>
#include <sys/time.h>
#include <inttypes.h>
+#ifdef _WIN32
+/* TODO */
+#else
#include <arpa/inet.h>
+#endif
#include <glib.h>
#include <sigrok.h>
* respond with g_poll().
*/
g_message("probing %s...", (char *)l->data);
+#ifdef _WIN32
+ // FIXME
+ // hdl = serial_open(l->data, 0);
+#else
fd = serial_open(l->data, O_RDWR | O_NONBLOCK);
+#endif
if (fd != -1) {
serial_params[devcnt] = serial_backup_params(fd);
serial_set_params(fd, 115200, 8, 0, 1, 2);
free(l->data);
}
- /* 2ms should do (enough time for 28 bytes to go over the bus). */
- usleep(2000);
+ /* 2ms isn't enough for reliable transfer with pl2303, let's try 10 */
+ usleep(10000);
final_devcnt = 0;
g_poll(fds, devcnt, 1);
flag_reg &= ~FLAG_DEMUX;
divider = (CLOCK_RATE / samplerate) - 1;
}
+#ifdef _WIN32
+ // FIXME
+ // divider = htonl(divider);
+#else
divider = htonl(divider);
+#endif
g_message("setting samplerate to %" PRIu64 " Hz (divider %u, demux %s)",
samplerate, divider, flag_reg & FLAG_DEMUX ? "on" : "off");
} else if (capability == HWCAP_PROBECONFIG) {
ret = configure_probes((GSList *) value);
} else if (capability == HWCAP_LIMIT_SAMPLES) {
- limit_samples = strtoull(value, NULL, 10);
+ tmp_u64 = value;
+ limit_samples = *tmp_u64;
ret = SIGROK_OK;
} else if (capability == HWCAP_CAPTURE_RATIO) {
capture_ratio = strtol(value, NULL, 10);
* This is the main loop telling us a timeout was reached, or
* we've acquired all the samples we asked for -- we're done.
*/
+#ifndef _WIN32
+ /* TODO: Move to serial.c? */
tcflush(fd, TCIOFLUSH);
+#endif
serial_close(fd);
packet.type = DF_END;
packet.length = 0;