LOG_DATA = 0x14,
LOG_START = 0x18,
LOG_END = 0x19,
-} PacketType;
+} packet_type;
static gboolean appa_55ii_checksum(const uint8_t *buf)
{
return flags;
}
-static float appa_55ii_temp(const uint8_t *buf, int probe)
+static float appa_55ii_temp(const uint8_t *buf, int ch)
{
const uint8_t *ptr;
int16_t temp;
uint8_t flags;
- ptr = buf + 4 + 14 + 3 * probe;
+ ptr = buf + 4 + 14 + 3 * ch;
temp = RL16(ptr);
flags = ptr[2];
static void appa_55ii_live_data(struct sr_dev_inst *sdi, const uint8_t *buf)
{
- struct dev_context *devc = sdi->priv;
+ struct dev_context *devc;
struct sr_datafeed_packet packet;
struct sr_datafeed_analog analog;
- struct sr_probe *probe;
+ struct sr_channel *ch;
float values[APPA_55II_NUM_PROBES], *val_ptr;
int i;
+ devc = sdi->priv;
+
if (devc->data_source != DATA_SOURCE_LIVE)
return;
analog.data = values;
for (i = 0; i < APPA_55II_NUM_PROBES; i++) {
- probe = g_slist_nth_data(sdi->probes, i);
- if (!probe->enabled)
+ ch = g_slist_nth_data(sdi->channels, i);
+ if (!ch->enabled)
continue;
- analog.probes = g_slist_append(analog.probes, probe);
+ analog.channels = g_slist_append(analog.channels, ch);
*val_ptr++ = appa_55ii_temp(buf, i);
}
packet.type = SR_DF_ANALOG;
packet.payload = &analog;
sr_session_send(devc->session_cb_data, &packet);
- g_slist_free(analog.probes);
+ g_slist_free(analog.channels);
devc->num_samples++;
}
{
struct dev_context *devc;
struct sr_datafeed_packet packet;
- struct sr_datafeed_analog analog = { 0 };
- struct sr_probe *probe;
+ struct sr_datafeed_analog analog;
+ struct sr_channel *ch;
float values[APPA_55II_NUM_PROBES], *val_ptr;
const uint8_t *buf;
int16_t temp;
buf = devc->log_buf + offset;
val_ptr = values;
- /* FIXME: timestamp should be sent in the packet */
+ /* FIXME: Timestamp should be sent in the packet. */
sr_dbg("Timestamp: %02d:%02d:%02d", buf[2], buf[3], buf[4]);
memset(&analog, 0, sizeof(analog));
for (i = 0; i < APPA_55II_NUM_PROBES; i++) {
temp = RL16(buf + 12 + 2 * i);
- probe = g_slist_nth_data(sdi->probes, i);
- if (!probe->enabled)
+ ch = g_slist_nth_data(sdi->channels, i);
+ if (!ch->enabled)
continue;
- analog.probes = g_slist_append(analog.probes, probe);
+ analog.channels = g_slist_append(analog.channels, ch);
*val_ptr++ = temp == 0x7FFF ? INFINITY : (float)temp / 10;
}
packet.type = SR_DF_ANALOG;
packet.payload = &analog;
sr_session_send(devc->session_cb_data, &packet);
- g_slist_free(analog.probes);
+ g_slist_free(analog.channels);
devc->num_samples++;
devc->log_buf_len -= 20;
if (devc->data_source != DATA_SOURCE_MEMORY)
return;
- ptr = buf + 4;;
+ ptr = buf + 4;
size = buf[3];
while (size > 0) {
s = MIN(size, sizeof(devc->log_buf) - devc->log_buf_len);
/* Skip broken packet. */
return buf + 4 + buf[3] + 1;
- switch ((PacketType) buf[2]) {
+ switch ((packet_type)buf[2]) {
case LIVE_DATA:
appa_55ii_live_data(sdi, buf);
break;
case LOG_END:
appa_55ii_log_end(sdi);
break;
+ default:
+ sr_warn("Invalid packet type: 0x%02x.", buf[2]);
+ break;
}
return buf + 4 + buf[3] + 1;
time = (g_get_monotonic_time() - devc->start_time) / 1000;
if (time > (int64_t)devc->limit_msec) {
sr_info("Requested time limit reached.");
- sdi->driver->dev_acquisition_stop(sdi, devc->session_cb_data);
+ sdi->driver->dev_acquisition_stop(sdi,
+ devc->session_cb_data);
return TRUE;
}
}