/*
* This file is part of the libsigrok project.
*
- * Copyright (C) 2016 danselmi <da@da>
+ * Copyright (C) 2016 Eva Kissling <eva.kissling@bluewin.ch>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/* LA subfunction command opcodes */
#define CMD_LA_DELAY 0x1F
-SR_PRIV int data_available(struct ipdbg_la_tcp *tcp)
+SR_PRIV gboolean data_available(struct ipdbg_la_tcp *tcp)
{
#ifdef __WIN32__
ioctlsocket(tcp->socket, FIONREAD, &bytes_available);
int status;
if (ioctl(tcp->socket, FIONREAD, &status) < 0) { // TIOCMGET
- sr_err("FIONREAD failed: %s\n", strerror(errno));
- return 0;
+ sr_err("FIONREAD failed: %s\n", g_strerror(errno));
+ return FALSE;
}
- return (status < 1) ? 0 : 1;
+ return (status < 1) ? FALSE : TRUE;
#endif // __WIN32__
}
struct ipdbg_la_tcp *tcp;
tcp = g_malloc0(sizeof(struct ipdbg_la_tcp));
-
tcp->address = NULL;
tcp->port = NULL;
tcp->socket = -1;
const uint8_t *buf, size_t len)
{
int out;
- out = send(tcp->socket, (char*)buf, len, 0);
+ out = send(tcp->socket, buf, len, 0);
if (out < 0) {
sr_err("Send error: %s", g_strerror(errno));
SR_PRIV int ipdbg_la_convert_trigger(const struct sr_dev_inst *sdi)
{
- struct ipdbg_la_dev_context *devc;
+ struct dev_context *devc;
struct sr_trigger *trigger;
struct sr_trigger_stage *stage;
struct sr_trigger_match *match;
SR_PRIV int ipdbg_la_receive_data(int fd, int revents, void *cb_data)
{
const struct sr_dev_inst *sdi;
- struct ipdbg_la_dev_context *devc;
+ struct dev_context *devc;
(void)fd;
(void)revents;
- sdi = (const struct sr_dev_inst *)cb_data;
+ sdi = cb_data;
if (!sdi)
return FALSE;
devc->raw_sample_buf =
g_try_malloc(devc->limit_samples * devc->DATA_WIDTH_BYTES);
if (!devc->raw_sample_buf) {
- sr_warn("Sample buffer malloc failed.");
+ sr_err("Sample buffer malloc failed.");
return FALSE;
}
}
return TRUE;
}
-SR_PRIV int ipdbg_la_send_delay(struct ipdbg_la_dev_context *devc,
+SR_PRIV int ipdbg_la_send_delay(struct dev_context *devc,
struct ipdbg_la_tcp *tcp)
{
devc->delay_value = (devc->limit_samples / 100.0) * devc->capture_ratio;
return SR_OK;
}
-SR_PRIV int ipdbg_la_send_trigger(struct ipdbg_la_dev_context *devc,
+SR_PRIV int ipdbg_la_send_trigger(struct dev_context *devc,
struct ipdbg_la_tcp *tcp)
{
uint8_t buf;
while (length--) {
uint8_t payload = *dataToSend++;
- if (payload == (uint8_t) CMD_RESET)
+ if (payload == CMD_RESET)
if (ipdbg_la_tcp_send(tcp, &escape, 1) != SR_OK)
sr_warn("Couldn't send escape");
- if (payload == (uint8_t) CMD_ESCAPE)
+ if (payload == CMD_ESCAPE)
if (ipdbg_la_tcp_send(tcp, &escape, 1) != SR_OK)
sr_warn("Couldn't send escape");
}
SR_PRIV void ipdbg_la_get_addrwidth_and_datawidth(
- struct ipdbg_la_tcp *tcp, struct ipdbg_la_dev_context *devc)
+ struct ipdbg_la_tcp *tcp, struct dev_context *devc)
{
uint8_t buf[8];
uint8_t read_cmd = CMD_GET_BUS_WIDTHS;
devc->trigger_edge_mask = g_malloc0(devc->DATA_WIDTH_BYTES);
}
-SR_PRIV struct ipdbg_la_dev_context *ipdbg_la_dev_new(void)
+SR_PRIV struct dev_context *ipdbg_la_dev_new(void)
{
- struct ipdbg_la_dev_context *devc;
+ struct dev_context *devc;
- devc = g_malloc0(sizeof(struct ipdbg_la_dev_context));
+ devc = g_malloc0(sizeof(struct dev_context));
devc->capture_ratio = 50;
return devc;