strcmp(buf + 9, " mA") does not work because buf is CR-terminated,
while " mA" is NUL-terminated.
Drop ambiguities arising from the termination of the strings, and
only compare the characters we care about, using strncmp().
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
When the parser found a space, it treated it as an invalid digit
and discarded the whole packet. This behavior was incorrect on
2000 count devices, where the first digit can be sent as a space
rather than a '0'.
Convert spaces to '0' and parse them as usual.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Prepare the tekpower-dmm driver to be able to support various simple
serial port based DMMs.
Also, make a 'tekpower-tp4000zc' "first-class" driver which is currently
the only user of this generic driver.
The demo driver was using sr_session_source_add_channel() to add
a poll source, but was relying on sr_session_run_poll() to call
sr_session_source_remove(). This, coupled with the design of the
driver caused errors once the samples were collected.
The error stream was most likely related to failing to properly close
one of the channels.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
This is the first step in fixing the demo driver: figuring out what is
being called and what is not _and_ have it show up in the logs.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Options in addition to the usual "9600/8n1" syntax start with a
slash, and take the form of key=value, where different options are
also separated by slashes. For example:
"9600/8n1/rts=0/dtr=1"
This sets RTS low and DTR high.
The packet mode byte is akin to a signature. If that is invalid, there's
no point in calculating the checksum, so check the mode first.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Serial detection was using serial_readline, which stripped carriage
return from the packets. This made for a very unreliable detection
mechanism.
Switch to a timeout-based detection mechanism that parses the data
as it comes in. This also allows us to stop parsing once we found
our first valid packet.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>