return 1;
}
- result = 0;
- offset = 0;
+ result = offset = 0;
while (1) {
chunksize = fread(buf, 1, 4096, fw);
if (chunksize == 0)
break;
err = libusb_control_transfer(hdl, LIBUSB_REQUEST_TYPE_VENDOR |
- LIBUSB_ENDPOINT_OUT, 0xa0, offset, 0x0000,
- buf, chunksize, 100);
+ LIBUSB_ENDPOINT_OUT, 0xa0, offset,
+ 0x0000, buf, chunksize, 100);
if (err < 0) {
g_warning("Unable to send firmware to device: %d", err);
result = 1;
#include <termios.h>
#include <stdlib.h>
#include <glib.h>
-
-#include "sigrok.h"
-
-
+#include <sigrok.h>
char *serial_port_glob[] = {
/* Linux */
"/dev/ttys*",
"/dev/tty.USB-*",
"/dev/tty.Modem-*",
- NULL
+ NULL,
};
-
GSList *list_serial_ports(void)
{
glob_t g;
unsigned int i, j;
ports = NULL;
- for(i = 0; serial_port_glob[i]; i++)
- {
- if(!glob(serial_port_glob[i], 0, NULL, &g))
- {
- for(j = 0; j < g.gl_pathc; j++)
- ports = g_slist_append(ports, strdup(g.gl_pathv[j]));
+ for (i = 0; serial_port_glob[i]; i++) {
+ if (!glob(serial_port_glob[i], 0, NULL, &g)) {
+ for (j = 0; j < g.gl_pathc; j++)
+ ports = g_slist_append(ports,
+ strdup(g.gl_pathv[j]));
globfree(&g);
}
}
return ports;
}
-
int serial_open(const char *pathname, int flags)
{
-
return open(pathname, flags);
}
-
int serial_close(int fd)
{
-
return close(fd);
}
-
void *serial_backup_params(int fd)
{
struct termios *term;
return term;
}
-
void serial_restore_params(int fd, void *backup)
{
-
- tcsetattr(fd, TCSADRAIN, (struct termios *) backup);
-
+ tcsetattr(fd, TCSADRAIN, (struct termios *)backup);
}
-
/* flowcontrol 1 = rts/cts 2 = xon/xoff */
-int serial_set_params(int fd, int speed, int bits, int parity, int stopbits, int flowcontrol)
+int serial_set_params(int fd, int speed, int bits, int parity, int stopbits,
+ int flowcontrol)
{
struct termios term;
- /* only supporting what we need really -- currently just the OLS driver */
- if(speed != 115200 || bits != 8 || parity != 0 || stopbits != 1 || flowcontrol != 2)
+ /* Only supporting what we need really, currently the OLS driver. */
+ if (speed != 115200 || bits != 8 || parity != 0 || stopbits != 1
+ || flowcontrol != 2)
return SIGROK_ERR;
- if(tcgetattr(fd, &term) < 0)
+ if (tcgetattr(fd, &term) < 0)
return SIGROK_ERR;
- if(cfsetispeed(&term, B115200) < 0)
+ if (cfsetispeed(&term, B115200) < 0)
return SIGROK_ERR;
term.c_cflag &= ~CSIZE;
term.c_cflag |= CS8;
term.c_cflag &= ~CSTOPB;
term.c_cflag |= IXON | IXOFF;
term.c_iflag |= IGNPAR;
- if(tcsetattr(fd, TCSADRAIN, &term) < 0)
+ if (tcsetattr(fd, TCSADRAIN, &term) < 0)
return SIGROK_ERR;
return SIGROK_OK;
}
-
-
static int hw_init(char *deviceinfo)
{
-
}
-
static int hw_opendev(int device_index)
{
-
}
-
static void hw_closedev(int device_index)
{
-
}
-
static void hw_cleanup(void)
{
-
}
-
static char *hw_get_identifier(int device_index)
{
-
}
-
static char *hw_get_device_info(int device_index, int device_info_id)
{
-
}
-
static int hw_get_status(int device_index)
{
-
}
-
static int *hw_get_capabilities(void)
{
-
}
-
static int hw_set_configuration(int device_index, int capability, char *value)
{
-
}
-
static int hw_start_acquisition(int device_index, gpointer session_device_id)
{
-
}
-
static void hw_stop_acquisition(int device_index, gpointer session_device_id)
{
-
}
-
-
struct device_plugin skeleton_plugin_info = {
"skeleton",
1,
hw_init,
hw_cleanup,
-
hw_opendev,
hw_closedev,
hw_get_device_info,
hw_get_capabilities,
hw_set_configuration,
hw_start_acquisition,
- hw_stop_acquisition
+ hw_stop_acquisition,
};
-