Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Digitech QM1576 serial protocol parser The protocol #187

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mikemccauley
Copy link
Contributor

is described at https://www.airspayce.com/mikem/QM1578/protocol.txt
You can use this decoder with libsigrok and Digitech QM1578 via ESP32
Bluetooth-Serial converter available from the author at:
https://www.airspayce.com/mikem/QM1578/QM1578BluetoothClient.ino which
connects to the QM1578 over Bluetooth LE, fetches the data stream and
sends it on the serial port to the host, where this driver can read it
with this command for example:

sigrok-cli --driver digitech-qm1578:conn=/dev/ttyUSB1 --continuous

is described at https://www.airspayce.com/mikem/QM1578/protocol.txt
You can use this decoder with libsigrok and Digitech QM1578 via ESP32
Bluetooth-Serial converter available from the author at:
https://www.airspayce.com/mikem/QM1578/QM1578BluetoothClient.ino which
connects to the QM1578 over Bluetooth LE, fetches the data stream and
sends it on the serial port to the host, where this driver can read it
with this command for example:

sigrok-cli --driver digitech-qm1578:conn=/dev/ttyUSB1 --continuous
src/dmm/qm1578.c Outdated
case 0x05: return -3; /* For amps */
case 0x06: return -3; /* For volts */
default:
sr_dbg("Unknown multiplier: 0x%02x.", buf[11]);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please indent your code, more info: https://www2.cs.arizona.edu/~mccann/indent_c.html

src/dmm/qm1578.c Outdated

/* On overload, digits 4 to 1 are: 0x0b 0x0a 0x00 0x0b */
if (buf[8] == 0x0b)
return INFINITY;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed indention

src/dmm/qm1578.c Outdated
Comment on lines 82 to 85
digit = buf[8 - i];
if (digit < 0 || digit > 9)
continue;
val = 10.0 * val + digit;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add indent to indicate this board in inside the for loop

src/dmm/qm1578.c Outdated
* and just use the presence of the trailing record separator
*/
if (buf[14] != 0x0d)
return FALSE;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

src/dmm/qm1578.c Outdated
Comment on lines 121 to 136
if (buf[13] & 0x10)
analog->meaning->mqflags |= SR_MQFLAG_AUTORANGE;
if (buf[13] & 0x40)
analog->meaning->mqflags |= SR_MQFLAG_DC;
if (buf[13] & 0x80)
analog->meaning->mqflags |= SR_MQFLAG_AC;
if (buf[13] & 0x20)
analog->meaning->mqflags |= SR_MQFLAG_RELATIVE;
if (buf[12] & 0x40)
analog->meaning->mqflags |= SR_MQFLAG_HOLD;
if ((buf[13] & 0x0c) == 0x0c)
analog->meaning->mqflags |= SR_MQFLAG_MAX;
if ((buf[13] & 0x0c) == 0x08)
analog->meaning->mqflags |= SR_MQFLAG_MIN;
if ((buf[13] & 0x0c) == 0x0c)
analog->meaning->mqflags |= SR_MQFLAG_AVG;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

src/dmm/qm1578.c Outdated
Comment on lines 172 to 174
analog->meaning->mq = SR_MQ_CURRENT;
analog->meaning->unit = SR_UNIT_AMPERE;
analog->meaning->mqflags |= SR_MQFLAG_AC | SR_MQFLAG_RMS;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

src/dmm/qm1578.c Outdated
Comment on lines 177 to 179
analog->meaning->mq = SR_MQ_VOLTAGE;
analog->meaning->unit = SR_UNIT_VOLT;
analog->meaning->mqflags |= SR_MQFLAG_DIODE;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

src/dmm/qm1578.c Outdated
Comment on lines 182 to 191
if (buf[10] == 0x04)
{
analog->meaning->mq = SR_MQ_FREQUENCY;
analog->meaning->unit = SR_UNIT_HERTZ;
}
else
{
analog->meaning->mq = SR_MQ_DUTY_CYCLE;
analog->meaning->unit = SR_UNIT_PERCENTAGE;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto, you did it for internal if/else but forgot for external one

src/dmm/qm1578.c Outdated
Comment on lines 194 to 195
analog->meaning->mq = SR_MQ_CONTINUITY;
analog->meaning->unit = SR_UNIT_OHM;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

src/dmm/qm1578.c Outdated
val *= powf(10, exponent);

if (buf[12] & 0x80)
val = -val;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@mikemccauley
Copy link
Contributor Author

Thanks for your review.
I was using a default C indent of 4 spaces, and with a TAB width of 8. Fixed now I hope and a new commit has been added.

@acassis
Copy link

acassis commented Jun 30, 2022

Thanks for your review. I was using a default C indent of 4 spaces, and with a TAB width of 8. Fixed now I hope and a new commit has been added.

Perfect! If you want please squash these commits, but I will already give an approval

@mikemccauley
Copy link
Contributor Author

Thanks for your help and efforts.
I wont get a chance to squash for some time, and have no personal need for that.
Cheers.

@abraxa
Copy link
Member

abraxa commented Aug 19, 2024

Merged as https://sigrok.org/gitaction?p=libsigrok.git;a=commit;h=46caa76de9b44c4f72287bb6e7443836e7fe414c, thank you!

Can you please add a wiki page for this device ( https://sigrok.org/wiki/Supported_hardware#Multimeters ) and add your information there so that it won't ever get lost?

Especially the contents of https://www.airspayce.com/mikem/QM1578/protocol.txt, the arduino sketch and instructions on how to build/flash/use the arduino sketch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants