brymen-dmm: style nits, apply comm param defaults, low battery warning
Rephrase how the default serial communication parameters get applied. Preset the variable to the default value and let optional user provided specs override these. This avoids an extra check which is difficult to read and highly redundant. Add a comment for raised awareness that a default port spec is undesirable because it's unreliable. Raise the severity of low battery messages. It's worth warning the user because measurements could be inaccurate. Reduce indentation in continuation lines of a long routine signature, and drop an empty line in a short struct while we are here.
This commit is contained in:
parent
648f32d119
commit
11addc897a
|
@ -111,7 +111,12 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
|
|||
|
||||
devices = NULL;
|
||||
|
||||
conn = serialcomm = NULL;
|
||||
/*
|
||||
* BEWARE! Default 'conn' is not desirable when the device cannot
|
||||
* reliably get detected. Insist that users specify the port.
|
||||
*/
|
||||
conn = NULL;
|
||||
serialcomm = "9600/8n1/dtr=1/rts=1";
|
||||
for (l = options; l; l = l->next) {
|
||||
src = l->data;
|
||||
switch (src->key) {
|
||||
|
@ -126,10 +131,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
|
|||
if (!conn)
|
||||
return NULL;
|
||||
|
||||
if (serialcomm)
|
||||
devices = brymen_scan(di, conn, serialcomm);
|
||||
else
|
||||
devices = brymen_scan(di, conn, "9600/8n1/dtr=1/rts=1");
|
||||
devices = brymen_scan(di, conn, serialcomm);
|
||||
|
||||
return devices;
|
||||
}
|
||||
|
|
|
@ -284,7 +284,7 @@ SR_PRIV int brymen_parse(const uint8_t *buf, float *floatval,
|
|||
analog->meaning->mqflags |= SR_MQFLAG_DC;
|
||||
|
||||
if (flags.is_low_batt)
|
||||
sr_info("Low battery!");
|
||||
sr_warn("Low battery!");
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ enum packet_len_status {
|
|||
|
||||
struct dev_context {
|
||||
struct sr_sw_limits sw_limits;
|
||||
|
||||
uint8_t buf[DMM_BUFSIZE];
|
||||
int bufoffset;
|
||||
int buflen;
|
||||
|
@ -66,9 +65,9 @@ SR_PRIV int brymen_parse(const uint8_t *buf, float *floatval,
|
|||
struct sr_datafeed_analog *analog, void *info);
|
||||
|
||||
SR_PRIV int brymen_stream_detect(struct sr_serial_dev_inst *serial,
|
||||
uint8_t *buf, size_t *buflen,
|
||||
packet_length_t get_packet_size,
|
||||
packet_valid_callback is_valid,
|
||||
uint64_t timeout_ms, int baudrate);
|
||||
uint8_t *buf, size_t *buflen,
|
||||
packet_length_t get_packet_size,
|
||||
packet_valid_callback is_valid,
|
||||
uint64_t timeout_ms, int baudrate);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue