X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fhardware%2Fbrymen-bm86x%2Fprotocol.c;h=17d1a905c66419a93ece6cd25ddb4677b8b69324;hb=803db07a1af036a5da65581ddbac23b7f84a4388;hp=b8e16a3f8d346c7f983f54a235ac764f57b7b69c;hpb=155b680da482cea2381becb73c51cfb838bff31e;p=libsigrok.git
diff --git a/src/hardware/brymen-bm86x/protocol.c b/src/hardware/brymen-bm86x/protocol.c
index b8e16a3f..17d1a905 100644
--- a/src/hardware/brymen-bm86x/protocol.c
+++ b/src/hardware/brymen-bm86x/protocol.c
@@ -17,13 +17,14 @@
* along with this program. If not, see .
*/
+#include
#include
#include
#include "protocol.h"
#define USB_TIMEOUT 500
-static char char_map[128] = {
+static const char char_map[128] = {
[0x20] = '-',
[0x5F] = '0',
[0x50] = '1',
@@ -72,7 +73,7 @@ static int brymen_bm86x_parse_digits(const unsigned char *buf, int length,
}
static void brymen_bm86x_parse(unsigned char *buf, float *floatval,
- struct sr_datafeed_analog *analog)
+ struct sr_datafeed_analog_old *analog)
{
char str[16], temp_unit;
int ret1, ret2, over_limit;
@@ -161,6 +162,9 @@ static void brymen_bm86x_parse(unsigned char *buf, float *floatval,
} else if (buf[9] & 0x04) {
analog[1].mq = SR_MQ_CURRENT;
analog[1].unit = SR_UNIT_AMPERE;
+ } else if (buf[9] & 0x08) {
+ analog[1].mq = SR_MQ_CURRENT;
+ analog[1].unit = SR_UNIT_PERCENTAGE;
} else if (buf[14] & 0x04) {
analog[1].mq = SR_MQ_FREQUENCY;
analog[1].unit = SR_UNIT_HERTZ;
@@ -191,7 +195,7 @@ static void brymen_bm86x_handle_packet(const struct sr_dev_inst *sdi,
{
struct dev_context *devc;
struct sr_datafeed_packet packet;
- struct sr_datafeed_analog analog[2];
+ struct sr_datafeed_analog_old analog[2];
float floatval[2];
devc = sdi->priv;
@@ -209,7 +213,7 @@ static void brymen_bm86x_handle_packet(const struct sr_dev_inst *sdi,
analog[0].num_samples = 1;
analog[0].data = &floatval[0];
analog[0].channels = g_slist_append(NULL, sdi->channels->data);
- packet.type = SR_DF_ANALOG;
+ packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog[0];
sr_session_send(sdi, &packet);
g_slist_free(analog[0].channels);
@@ -220,7 +224,7 @@ static void brymen_bm86x_handle_packet(const struct sr_dev_inst *sdi,
analog[1].num_samples = 1;
analog[1].data = &floatval[1];
analog[1].channels = g_slist_append(NULL, sdi->channels->next->data);
- packet.type = SR_DF_ANALOG;
+ packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog[1];
sr_session_send(sdi, &packet);
g_slist_free(analog[1].channels);
@@ -254,7 +258,7 @@ static int brymen_bm86x_send_command(const struct sr_dev_inst *sdi)
}
if (ret != sizeof(buf)) {
- sr_err("Short packet: sent %d/%ld bytes.", ret, sizeof(buf));
+ sr_err("Short packet: sent %d/%zu bytes.", ret, sizeof(buf));
return SR_ERR;
}
@@ -290,7 +294,7 @@ static int brymen_bm86x_read_interrupt(const struct sr_dev_inst *sdi)
}
if (transferred != sizeof(buf)) {
- sr_err("Short packet: received %d/%d bytes.", transferred, sizeof(buf));
+ sr_err("Short packet: received %d/%zu bytes.", transferred, sizeof(buf));
return SR_ERR;
}