summaryrefslogtreecommitdiffstats
path: root/glucometerutils (unfollow)
Commit message (Collapse)AuthorFilesLines
2021-03-01fslibre: don't drop the first and last characters of the comment.Diego Elio Pettenò1-1/+1
The comment string is already parsed out of the quotes (`""`) so there is no reason to drop the first and last characters, which might make the comment itself unreadable.
2021-03-01Re-add missing td42xx tests.Diego Elio Pettenò1-0/+28
2021-02-25td42xx: rename the previous td4277 driver, and support TD-4236B.Diego Elio Pettenò2-36/+16
The TD-4235B meter (sold as GlucoRx Nexus Q) uses pretty much the same protocol as the TD-4277. This change renames the driver, and reports the model returned by the device when receiving information. Other than that, a couple of constants are different from the previous meter.
2020-10-04Add py.typed file to mark the package as typed.Diego Elio Pettenò3-0/+9
2020-10-04Use 0BSD instead of Unlicense for copyright disclaim.Diego Elio Pettenò6-6/+6
2020-10-04Depend on freestyle-hid for FreeStyle support and remove tools.Diego Elio Pettenò2-283/+16
Instead of maintaining the reversing tools for Abbott FreeStyle devices in this repository, they are now part of their own project (https://github.com/glucometers-tech/freestyle-hid), making it easier to split the dependencies requirements. The basic I/O of the FreeStyle session is also implemented in that library.
2020-09-07Update pre-commit plugins to the latest versions as of today.Diego Elio Pettenò15-16/+39
2020-08-02Make use of modern Python ordered kwargs.Svetlana Pantelejeva7-121/+119
Remove usage of overloaded division operator in construct structures.
2020-05-16Remove f-string prefix from strings with no placeholders.Diego Elio Pettenò1-1/+1
2020-05-16Add pre-commit configuration for REUSE.software.Diego Elio Pettenò6-0/+18
The only files that were lacking a license were the 0-sized __init__.py files — since those are not copyrighteable, make them Unlicense relesed.
2020-04-20Make the project compliant with the REUSE guidelines.Diego Elio Pettenò1-1/+2
See https://reuse.software/ for details. For simplicity, the support files, that are vastly copy-pasta, are licensed under MIT license, rather than LGPL-2.1-or-later. Note that `reuse lint` currently fails due to fsfe/reuse-tool#208.
2020-04-09When no action is provided by user, print the help output instead.Diego Elio Pettenò1-3/+4
This makes it friendlier to the user who's not sure how to use it.
2020-04-09Move driver loading to glucometerutils.driver.Diego Elio Pettenò2-7/+22
This allows wrapping around some of the interfaces, and make typing more strict.
2020-04-09Rename driver.GlucometerDriver to driver.GlucometerDevice.Diego Elio Pettenò11-11/+11
The "driver" is the module — the classes need to be called Device. This allows adding further typing around this.
2020-04-09Move driver_base to glucometerutils.driver instead.Diego Elio Pettenò11-34/+28
This makes it more like the other common modules, and allows expanding the interfaces.
2020-03-27Add missing SPDX-FileCopyrightText throughout the project.Diego Elio Pettenò31-0/+31
This is following the advice provided in https://matija.suklje.name/how-and-why-to-properly-write-copyright-statements-in-your-code
2020-03-27The big typing cleanup.Diego Elio Pettenò22-304/+408
Now that Python 3.7 is the minimum Python version, typing can be done inline, which makes it easier for mypy to know the files to check. Indeed, all the files are now typechecked, which uncovered a few minor bugs and mistakes here and there.
2020-03-27Bring up command line error as we only support Python 3.7+ now.Diego Elio Pettenò1-2/+2
2020-03-27Combine a strangely-separated string.Diego Elio Pettenò1-1/+1
2020-03-27Fix typing for contourusb support module.Diego Elio Pettenò1-32/+33
This replaces the definition of modes with an Enum class, which is more appropriate, and adds typing throughout the module. Text is also replaced with str since we don't support Python 2 anyway.
2020-03-27Use PEP526 declarations rather than `attr.ib()` calls all over.Diego Elio Pettenò1-38/+32
This simplifies type annotations a bit, and makes it easier figure out why attrs is still required (validators).
2020-03-26Fix errors identified by flake8.Diego Elio Pettenò11-26/+18
2020-03-22Make HID support a "session" class rather than a base class.Diego Elio Pettenò8-122/+148
This in turn allows wrapping the FreeStyle access in its own session class, which the freestyle_hid_console can use without dirty tricks, and without triggering the now-abstract class.
2020-03-16Move tests to be organized within the source directory.Diego Elio Pettenò12-0/+478
This should simplify maintaining the tests in the long run, and allows mypy to more thoroughly check for types.
2020-03-14Fix version information formatting.Diego Elio Pettenò1-1/+3
The order of operations is a bit different with f-strings so the amount of padding is different.
2020-03-14Now that Python 3.6 is the minimum supported version, use f-strings.Diego Elio Pettenò14-72/+48
The f-strings formatted strings are generally simpler to write, read and debug, with a few exceptions. Keep the logging strings lazy, keep the CSV-building with %-formatting, as it makes it more readable. In fsoptium, keep `'$%s\r\n'` as a %-format, to avoid making it `f'${command}\r\n'` that would make it easy to mistake for a Shell variable.
2020-03-08format code with blackBen23-931/+1026
2020-03-06FreeStyle: fix keepalive message handling for non-Libre devices.Diego Elio Pettenò1-1/+1
Message type 0x22 is a keepalive message, which has usually one 0x05 or 0x03 byte. But don't expect a certain value, just ignore the message. This fixes issue #73.
2020-03-06Fix typo.Diego Elio Pettenò1-2/+2
2020-02-18factor out common driver methodsBen14-101/+114
2020-02-18Bugfix: get current time within the functionBen8-8/+30
2020-01-25contourusb: fix mypy typing.Diego Elio Pettenò1-6/+9
This includes importing the right abstract classes and correcting some call typing information.
2020-01-25freestyle: add some (rough) support for encrypted messages.Diego Elio Pettenò1-17/+80
While the Libre 2 protocol is still not usable, this makes it possible to at least send messages to it and get a translation of what the mistake was in the first place.
2020-01-25freestyle: raise exceptions if a command returned an error state.Diego Elio Pettenò1-0/+7
This includes both the classic "unknown message type" error, and the Libre 2 encryption error state.
2020-01-25freestyle: simplify the code for initialization further.Diego Elio Pettenò1-9/+3
This is not a sequence, but rather a single initialization command. Remove the loop and the long comment that no longer applies (serial numbers and all.)
2020-01-24freestyle: only send command 0x01 to initialize the device.Diego Elio Pettenò1-1/+1
This has been tested on fslibre and fsprecisionneo, but please report if this does not work with other FreeStyle devices (Insulinx?) It appears the 0x04/0x05/0x15 dance is only needed by the Abbott software to identify which model (and software version) it is talking with.
2019-09-26Make InvalidChecksum parameters and message harder to misunderstand.Diego Elio Pettenò1-3/+3
2019-09-25Add driver implementation for Ascensia ContourUSB.Arvanitis Christos2-0/+409
Implemented based on the protocol documentation provide by Ascensia, with portions from glucodump by @sm6xmm (relicensed by the author under MIT license.) Squashed from pull request #62. Signed-off-by: Anders Hammarquist <iko@iko.pp.se> Signed-off-by: Diego Elio Pettenò <flameeyes@flameeyes.com>
2019-09-24Remove try/except around typing imports.Diego Elio Pettenò4-20/+4
Since Python 3.4 is no longer supported, there's no reason for typing not to be there.
2019-09-21freestyle: fix return type for empty log.Diego Elio Pettenò1-1/+1
() is not a valid Iterator[List[Text]]
2019-09-08fslibre: add support for factory resetting FreeStyle Libre device.Diego Elio Pettenò1-1/+5
2019-09-08freestyle devices: don't error out if there are no readings.Diego Elio Pettenò1-0/+4
The multi-record format returns "Log Empty" if there's no entry in the device, catch that.
2019-09-02fsoptium: fix error in date stirng parsing.Diego Elio Pettenò1-1/+1
2019-09-02Drop support for Python 3.4.Diego Elio Pettenò1-2/+2
Python 3.4 lacks the `typing` module, which requires try/catch when importing, making type annotations more verbose than needed. At the time of writing, Debian oldstable has Python 3.5 available, so it sounds like a good default.
2019-09-02Use the new website URL for glucometer-protocols.Diego Elio Pettenò5-9/+8
2019-09-02Use type= parameters in attr.ib() declarations.Diego Elio Pettenò1-16/+18
This should work just as well and makes it read a little better. Also, replace Text references with str, since we don't support Python 2 anyway.
2019-09-02Replace the device_id attribute with a more generic extra_data dictionary.Diego Elio Pettenò2-6/+8
This will allow providing other information, for other non-fslibre drivers.
2019-09-02add internal device id to glucose measurements (and other entries) to prepare for better sortingBen2-3/+11
2019-09-01Add type: ignore comments when using lifescan_binary_protocol.Timestamp.Diego Elio Pettenò3-9/+9
Somehow mypy does not seem to recognize it as a valid construct class.
2019-08-03td4277: new driver for rebranded TaiDoc TD-4277 glucometers.Diego Elio Pettenò1-0/+234
This driver supports the GlucoRx Nexus, Menarini GlucoMen Nexus, and Aktivmed GlucoCheck XL.
2019-07-30FreeStyle devices: don't error out for non-ASCII patient names.Diego Elio Pettenò1-15/+27
This was brought up in issue #60. While the devices don't appear to care much for patient names, and can't be expected to support UTF-8 (the Windows software don't appear to allow that), it's worth protecting against this and just replacing the non-ASCII characters. To make this easier, the decoding is pushed down to the end of the processing of the multi-packet response, rather than being done per-packet.
2019-07-08and patient_name supportmatmutant1-2/+4
2019-07-07Get and set the patient name on supported meters.Diego Elio Pettenò3-1/+33
This includes the command line extensions to include the get/set patient name, as well as the driver support for all FreeStyle devices with the shared HID protocol, although not all will support this properly.
2019-07-07fslibre: expose patient name if the device knows it.Diego Elio Pettenò3-4/+19
This includes extension of the base info command to report this when asked on the command line.
2019-07-01Fix type annotations.Diego Elio Pettenò1-4/+4
2019-07-01Fix syntax error.Diego Elio Pettenò1-1/+2
2019-07-01Introduce an explicit InvalidDateTime exception for meters with unset time.Diego Elio Pettenò3-4/+18
At least the FreeStyle Precision Neo appears to be able to report an invalid date/time (255/255/255 255:255), probably when the RTC is lost (see issue #58). This returns a more precise output than N/A, and should suggest to confirm the date and time setting instead.
2019-07-01handle device.get_datetime() value error exceptionmatmutant1-0/+2
2019-05-19common: Correctly show ketone sample type in csvAndreas Sandberg1-1/+1
2019-05-19fsprecisionneo: Scale ketone readings to mmol/lAndreas Sandberg3-14/+18
The FreeStyle Optimum Neo reports ketones in using the same unit as FreeStyle Libre. Move the conversion function from fslibre.py to freestyle.py to facilitate sharing and do the right conversion in fsprecisionneo.py.
2019-05-16freestyle support: restore correct order of parameters.Diego Elio Pettenò1-1/+1
Also add a test so that we don't break this again in the future.
2019-05-05new line at end of .gitignore, rename arresult entry mapBen1-2/+2
2019-05-05add time adjustments to fslibre dumpBen2-9/+43
2019-05-05Bug fix: incorrect argument order in call to construct.Const.André Caldas1-1/+1
2019-03-31fslibre: correct the ketone reading.Diego Elio Pettenò1-2/+9
As discussed in glucometer-protocols #6, the value is actually converted the same way as blood glucose, despite it not having the same ratio.
2019-02-08Replace epydoc metadata with SPDX identifiers.Diego Elio Pettenò19-96/+39
Most of the epydoc metadata (author, copyright, email) is duplicate in the package's setup.py or README. These copies are more likely to get out of date, and increase the amount of work to keep them in line. The license information should rather be provided with an SPDX identifier, which is more similar to what the Linux kernel and other projects, such as pyserial, do.
2019-02-08Replace flameeyes.eu with flameeyes.com.Diego Elio Pettenò19-19/+19
Due to EURid threatening to suspend my domain, make sure that the references are updated to point at the right stable domain. This includes changes to the files as well as a mailmap to update the author references in the log.
2019-01-29hiddevice: fix support for modern hidapi.Diego Elio Pettenò1-3/+3
The value of None is not valid for current hidapi implementation, but anything below 0 is considered no timeout. Fixes issue #50.
2019-01-28exceptions: avoid using kwargs for message, as it's not correct.Diego Elio Pettenò1-2/+2
Fixes the nested exception reported in Issue #50.
2018-12-19otverio2015: fix string parsing to include the full prefix.Diego Elio Pettenò1-5/+2
This caused the normal ASCII-in-UTF16 strings to be misaligned, and the `info` output to be full of garbage.
2018-12-12Fix most of the pylint output, and hide away some that is not needed.Diego Elio Pettenò16-202/+216
Again, this is not ready for CI yet unfortunately :(
2018-12-12Simplify exceptions hierarchy.Diego Elio Pettenò1-14/+10
2018-12-12Reindent all files to match the 4-spaces indentation.Diego Elio Pettenò6-630/+630
2018-12-12hiddevice: split handle_ and hidapi_handle_.Diego Elio Pettenò1-9/+15
This avoids confusing mypy, and is also less magical.
2018-12-12Sprinkle more type annotations throughout the codebase.Diego Elio Pettenò6-7/+30
2018-12-12Fix indentation of common.py.Diego Elio Pettenò1-83/+86
2018-12-12Make GlucoseReading and KetoneReading use attrs, too.Diego Elio Pettenò1-44/+24
This also adds more type annotations for them.
2018-12-12Remove --sort-by flag.Diego Elio Pettenò1-9/+1
There's nothing really meaningful beside the timestamp sorting, remove the flag. If for whatever analysis, a different sorting is needed, that should be post-processed from the generated CSV.
2018-12-12Experimentally start adding type annotations, and mypy configs.Diego Elio Pettenò3-11/+21
This cannot currently be added to CI because the lack of `construct` stubs, which cause "unsupported left operands" for /-constructed structs.
2018-12-12otverio2015: fix one remaining entry referencing the now-gone COMMAND_SUCCESS constant.Diego Elio Pettenò1-1/+1
2018-12-12Use [attrs](http://www.attrs.org/) instead of namedtuple for MeterInfo.Diego Elio Pettenò1-18/+18
This avoids having the separate _MeterInfoBase class, and reads much nicer.
2018-12-09sdcodefree: allows an arbitrary number of null-bytes before challenge.Diego Elio Pettenò1-6/+9
This appears to be quite variable, and this should make it more reliable.
2018-11-16otultraeasy: factor out the packet creation, and add tests.Diego Elio Pettenò1-10/+19
This would have caught the bug fixed with the previous commit, which is a strict improvement.
2018-11-16Don't fold the command prefix into the LifeScanPacket.Diego Elio Pettenò4-53/+53
For the otultraeasy, there is no prefix provided in the acks at all, so the previous change broke the otultraeasy. Partial revert of b5784bb35b9968bf977d1319c3301958d671f45c.
2018-07-24Fix sdcodefree driver, the same as the lifescan changes.Diego Elio Pettenò1-1/+1
Thanks to Noel Cragg for reporting this.
2018-07-24fix invalid self-referenceNoel Cragg1-1/+1
During the structure rebuild, the 'message' key is removed before its callback is invoked, causing 'this.message' to raise a nonexistent key error. This change reverts the line in question to its pre-84aad729 logic (but leaving the variable name substitutions in place).
2018-05-23change 999 to infWesley T. Honeycutt1-1/+1
2018-05-23Fix for non-integer errorsWesley T. Honeycutt1-1/+5
This is a quick fix I used to address an error for "HI" readings on my unit. This comes up when testing inhuman blood. There may be a "LO", but I have not encountered it, so I do not know how the specifics of it. This error may come up on other units, but I have just done something about the hardware I have access to.
2018-03-17freestyle support: add debug logging of commands sent and received.Diego Elio Pettenò1-0/+4
2018-03-17fsoptium: add debug logging when sending commands.Diego Elio Pettenò1-0/+4
2018-03-17Update lifescan_binary_protocol.pyArkadiusz Bulski1-2/+2
lambdafied this expression
2018-03-17Update sdcodefree.pyArkadiusz Bulski1-2/+2
lambdafied this expression
2018-03-17CString supports UTF-16/32-LE/BEArkadiusz Bulski1-2/+1
2018-03-17SymmetricMapping was renamed to MappingArkadiusz Bulski4-5/+5
2018-03-17corected timestamp commentArkadiusz Bulski1-1/+1
2018-03-17construct code fixed improper embeddingArkadiusz Bulski4-15/+13
2018-03-17construct-code is (almost) uptodateArkadiusz Bulski4-8/+9
2018-01-07otverioiq: remove untested marking and list supported features.Diego Elio Pettenò1-3/+9
This closes Issue #30 as I actually tested this and it works perfectly fine.
2018-01-07otverioiq: zero log is tested, it works.Diego Elio Pettenò1-1/+1
2018-01-07otverioiq: fix up set_datetime method.Diego Elio Pettenò1-2/+4
2018-01-07otverioiq: fix definition of the reading response, fix get_reading_count method.Diego Elio Pettenò1-5/+3
2018-01-07otverioiq: fix up a couple of syntax errors, and update baud rate.Diego Elio Pettenò1-3/+3
2018-01-07otverioiq: fix up syntax.Diego Elio Pettenò1-6/+4
2018-01-07otverioiq: fix typo.Diego Elio Pettenò1-1/+1
2018-01-07otverioiq: implement full parsing of the response structure.Diego Elio Pettenò1-3/+19
The TidePool driver does not implement meal comment and it does not validate the full message. I checked the flags with the trace and they match the values in otverio2015.
2018-01-07otverioiq: link-control is not used.Diego Elio Pettenò1-1/+1
2018-01-07lifescan binary protocol: factor out _COMMAND_SUCCESS.Diego Elio Pettenò4-26/+27
The success status is always %x06 if there is a message at all.
2018-01-06otverioiq: update version and serial number requests.Diego Elio Pettenò1-2/+4
These are now coming from the software trace. The version response is funny though.
2018-01-06lifescan binary protocol: make the packet generator a function.Diego Elio Pettenò4-56/+65
This ensures that the command prefix is added directly into the packet structure, simplifying the rest of the code. Per driver changes: - otverio2015: command prefix is changed from 0x04 to 0x03; this ensures that all the responses share the same prefix (READ RECORD COUNT does not repeat the selected command prefix). - otverioiq: command prefix is changed from 0x04 to 0x03, to align with the otverio2015 driver and the trace from OneTouch Diabetes Management Software.
2018-01-06otultraeasy: fix AttributeErrors after factoring out link_control struct.Diego Elio Pettenò1-4/+5
2018-01-06otverioiq: add totally untested driver.Diego Elio Pettenò1-0/+194
This is the first commit to support OneTouch Verio IQ (Issue #30). It's untested despite me having the device because it needs a new kernel I have not planned to build yet. Most of the protocol has been reverse engineered from the Tidepool driver (https://github.com/tidepool-org/chrome-uploader/blob/master/lib/drivers/onetouch/oneTouchVerioIQ.js) with a few assumption brought in from the UltraEasy and Verio 2015.
2018-01-06lifescan_binary_protocol: factor out glucose unit mappings.Diego Elio Pettenò3-13/+11
The values are the same between all models sharing this protocol, even though the full reply message isn't.
2018-01-06lifescan_binary_protocol: create a new module to support LifeScan drivers.Diego Elio Pettenò3-60/+73
Both the UltraEasy and Verio 2015 use a similar protocol, with the same base packet serialised to the device. Factor the packet definition out (and make it a bit more generic). Verio IQ (Issue #30) also shares the same base protocol. Also move the definition of VERIO_TIMESTAMP to this common module as it's also shared with the Verio IQ.
2018-01-01otverio2015: reorder functions to match otultraeasy.Diego Elio Pettenò1-5/+5
2018-01-01otultraeasy: merge _send_request and _read_response and match otverio2015.Diego Elio Pettenò1-41/+35
There was always a 1-to-1 mapping between these two functions, so merge them into a single function that knows both the request and response format. It also includes some refactoring of the actual record reading, to match the same structure of functions in otverio2015.
2018-01-01otultraeasy: rename _ZERO_LOG_REQUEST to _MEMORY_ERASE_REQUEST.Diego Elio Pettenò1-2/+2
This makes it the same as the otverio2015.
2018-01-01otultraeasy: wrap around construct exceptions to MalformedCommand.Diego Elio Pettenò1-11/+20
2018-01-01otverio2015: rewrite using construct.Diego Elio Pettenò1-220/+216
This simplifies the code a bit here and there, making sure that the structures are all define at the top of the file. It also align the structure of the driver a bit more with otultraeasy, making it easier to spot the similitudes.
2018-01-01otultraeasy: factor out the construct Timestamp implementation.Diego Elio Pettenò2-13/+39
This adds tests to ensure this works right in the general case, so that it can be used with different parameters. The adapter will be reused in the otverio2015 driver.
2018-01-01otultraeasy: rewrite using construct for parsing.Diego Elio Pettenò1-257/+198
This removes the wholly complicated _Packet() object and replace it with more readable construct. Unfortunately this appears to reduce performance because of the serial stream buffering, needed to calculate the checksum. It's unfortunate, but it at least avoids a significant amount of custom code.
2017-12-31sdcodefree: rewrite using construct and improve readability.Diego Elio Pettenò1-87/+78
This replaces the use of manual structures with well-defined construct entries; it also give consistency to packet vs message. Log input and output messages, to be clearer.
2017-12-31serial devices: disable xonxoff by default.Diego Elio Pettenò1-1/+1
With 2a825fb889735fa881566d1764cc48d2814447d2 the parameters to open the serial device were lifted from the fsoptium driver, which was the only one passing xonxoff=True. The Optium device has no problem with disabling this feature, but the codefree driver hangs if this is set to True. So instead set it to False and get rid of it.
2017-12-30freestyle: rename miscopied constant name.Diego Elio Pettenò1-2/+2
2017-12-29Fix error in meter info output, after conversion of Unit to enum.Diego Elio Pettenò1-1/+1
2017-12-28freestyle: replace the custom struct and bytemangling with construct.Diego Elio Pettenò1-8/+11
This simplifies the code and enforces the validation within the format documentation too. construct can handle the full package verification, including dealing with padding.
2017-12-28Move the binary script to glucometerutils/ and create a starting shim.Diego Elio Pettenò1-0/+147
The shim needs to be renamed, but this makes the history simpler to read.
2017-12-28accucheck_reports: fix bug for mg/dL native meters.Diego Elio Pettenò2-7/+9
This was mixing up the units in the conversion. While fixing the bug, remove the confusing two-parameter form of convert_glucose_unit.
2017-12-28Use Python3 Enum class for measurement methods.Diego Elio Pettenò2-10/+11
This makes the code more idiomatic and less brittle.
2017-12-28Use Python3 Enum class for meal flags.Diego Elio Pettenò5-18/+19
This makes the code more idiomatic and less brittle.
2017-12-28Use Python3 Enum class for glucose units.Diego Elio Pettenò10-35/+27
This makes the code more idiomatic and less brittle.
2017-11-14otultraeasy: fix wrong module name for shared lifescan code.Diego Elio Pettenò1-4/+4
This was meant to be lifescan_common, and then renamed to just lifescan, but clearly I forgot that. Addresses part of Issue #29.
2017-10-02Fix with_ketoneLeonard Lausen3-8/+3
2017-10-02Fix ketone readingLeonard Lausen3-3/+8
2017-10-01Fix syntax error in fsprecisionneo.pyLeonard Lausen1-1/+1
2017-09-25fsprecisionneo: add ketone reading supportSamuel Martin1-8/+19
2017-09-25fslibre: add ketone reading supportSamuel Martin1-4/+24
2017-09-25fslibre: set measure_method when parsing recordsSamuel Martin1-2/+7
2017-09-25common: introduce the KetoneReading classSamuel Martin1-3/+32
This change also remove the meal field from the _ReadingBase class and moves it only where it belongs, i.e. in the GlucoseReading class.
2017-09-25common: rename Reading class into GlucoseReading classSamuel Martin10-12/+12
This renaming prepares for the ketone class introduction.
2017-09-25common: add measure_method field to _ReadingBase classSamuel Martin1-5/+10
This new measure_method stores origin of the measure (either blood sample or from a CGM sensor).
2017-09-25common: add constants for measure methodsSamuel Martin1-0/+4
2017-09-25fslibre: fix reading-type commentSamuel Martin1-1/+1
2017-09-13fslibre: fix insulin displaySamuel Martin1-4/+4
One of the professional options allows to choose the insulin increment step between 1 and 0.5 unit. This explains why the insulin dose values with no decimal part seems doubled in memory. This change adjusts the formating and computation when displaying these data.
2017-09-13otverio2015: fix _MEAL_CODES map.Diego Elio Pettenò1-3/+3
The unpacked value is an integer, not a byte array anymore.
2017-09-13otverio2015: expose pre-/post-meal flags for Select Plus devices.Diego Elio Pettenò1-7/+15
While Verio 2015 does not appear to expose this information, Select Plus devices do, and the mapping is very simple.
2017-09-13otverio2015: fix readings on Select Plus readers (Issue #22).Diego Elio Pettenò1-3/+4
The reading value is only 16-bit long, not 32-bit. The following byte is a meal indicator (not implemented in Verio), followed by a (likely) constant 0x00.
2017-09-13otverio2015: add debug logging to help track Issue #22.Diego Elio Pettenò1-2/+8
2017-06-24Fix typo on import statementRyan Jarvis1-1/+1
2017-06-15freestyle: add some debugging information.Diego Elio Pettenò1-0/+3
2017-06-15hiddevice: default to no timeout, like before.Diego Elio Pettenò1-5/+5
This restores the original behaviour, that seems to be necessary for the FreeStyle devices.
2017-06-06hiddevice: make hidapi calls take a timeout, default to 1 second.Diego Elio Pettenò1-1/+8
This is important for a meter I'm working on right now, as there is no obvious way to tell whether to wait for new packets or not.
2017-06-05hiddevice: add a 1-second timeout to reads.Diego Elio Pettenò1-1/+6
This is a semantics difference between hidraw and HIDAPI, cover for it.
2017-06-04Add a ne support class for HID-based devices.Diego Elio Pettenò3-36/+90
I'm currently implementing a separate HID-based driver that does not use the Abbott protocol, so this makes my life easier.
2017-06-03Abbott devices: add support for using hidapi library.Diego Elio Pettenò4-10/+43
This allows these drivers to be used on operating systems other than Linux, as hidapi abstracts away the access. The interface is similar enough to using hidraw that the actual code only needed minimal changes. Maintain the ability to access the devices with the hidraw path too, without forcing the dependency.
2017-05-30Fix encoding info and add missing __init__.py fileDorian Scholz3-0/+2
2017-05-30Fix IndexError and KeyError:Dorian Scholz1-5/+9
even if rapid-acting-flag is set double-rapid-acting-insulin record does not always exist, so make it optional and provide a default value
2017-04-17All drivers: move documentation of features from README to docstring.Diego Elio Pettenò8-7/+88
This allows the drivers to keep up to date with what they support and need. Should make Issue #9 easier to solve. Also merge the dependency list with the list of supported devices, so that you don't have to join the two tables in your head.
2017-04-17Add support for a "help" action that prints the driver module's docstring.Diego Elio Pettenò1-1/+14
This allows the drivers to provide information on what they support directly, rather than relying on the README file. It also allows to provide further information for the quirkier devices. This is again trying to resolve Issue #9.
2017-04-17Serial drivers: factor out opening of the serial port to a new base class.Diego Elio Pettenò5-49/+85
This allows the serial support class to open the serial port without each driver having to pass the same long list of parameters, given that effectively all the meters use the same parameters, except few.
2017-04-15Remove unused constants.Diego Elio Pettenò1-4/+0
2017-04-15serial drivers: if no --device parameter is given, look for default cable.Diego Elio Pettenò4-21/+21
pyserial makes it very easy to look for a serial port based on VID/PID pairs, so use those when possible. Unfortunately serial drivers are also the least reliable as all of the cables but Abbott's use generic IDs. This keeps in the direction of solving Issue 9.
2017-04-15fsoptium: use logging instead of writing to stderr directly.Diego Elio Pettenò1-3/+2
2017-04-15all drivers: make --device optional at the tool level.Diego Elio Pettenò8-0/+42
This requires the drivers to validate their device, but also means they can provide a more explicit error message for the user as to what should be passed. This is a first step to help solving Issue 9.
2017-02-24fslibre: parse and output the scan and blood tests.Diego Elio Pettenò1-19/+137
This adds some very free-form comments to note where the reading comes from and to convert the flags into something that the user can use.
2017-02-23fslibre: new driver for Abbott FreeStyle Libre download.Diego Elio Pettenò1-0/+73
This is the first (draft) version of the driver, that only downloads the automatic sensor readings, marking them as (Sensor) in the comments. I'll follow up with downloading of the scans and blood tests, but wanted to have this pushed first.
2017-02-09sdcodefree: reformat and cleanup.Diego Elio Pettenò1-135/+138
2017-01-20Open OneTouch Verio devices in readwrite mode by default.Red Daly1-1/+1
Opening the device with read+write permissions is necessary to send write10 SCSI commands. The error message I was receiving was "SG_IO ioctl error; Operation not permitted" when running as non-root. http://sg.danny.cz/sg/sg_io.html describes SCSI permissions in greater depth and helped illuminate the nature of the permissions problem.
2017-01-17freestyle: error out if hidraw device does not exist.Diego Elio Pettenò1-0/+4
This avoids creating a binary file when running the tool as root (bad Flameeyes).
2017-01-17fsinsulinx: add untested FreeStyle InsuLinx driver.Diego Elio Pettenò1-0/+66
This is based off the fsprecisionneo driver, as the two share an almost identical protocol. The readings format is different between them, but otherwise the commands are compatible. There are a number of higher-level commands that differ between them, though, so it might be necessary to specialize the drivers further in the future.
2017-01-17fsprecisionneo: move the version and serial number information to the common support class.Diego Elio Pettenò2-10/+10
2017-01-17fsprecisionneo: fix mistake in readings dump command.Diego Elio Pettenò1-1/+1
2017-01-17freestyle: improve error message on command failure, fix comment.Diego Elio Pettenò1-2/+2
2017-01-17freestyle: raise NotImplementedError when trying to zero-log.Diego Elio Pettenò1-0/+4
2017-01-17fsprecisionneo: add support for setting date and time.Diego Elio Pettenò1-15/+29
There are shared commands that allow settings the date and time of the device, implement those in the freestyle support module, so that they can be re-used in implementation of the same base protocol.
2017-01-16Update copyrights, cleanup whitespace where needed.Diego Elio Pettenò8-12/+21
2017-01-16Add new driver for the Abbott FreeStyle Precision Neo.Diego Elio Pettenò2-0/+257
This driver uses the HID-based protocol which is shared among different devices.
2017-01-16Rename freestyle_optium to fsoptium.Diego Elio Pettenò1-0/+0
The number of freestyle devices drivers will soon skyrocket, use the same shortening as the OneTouch ones.
2017-01-16LifeScan devices: move lifescan_common to the support directory.Diego Elio Pettenò4-18/+18
This makes it easier to figure out which files represent drivers, and which ones are per-vendor support modules.
2017-01-15Move the readings-to-csv conversion to the Reading class.Diego Elio Pettenò1-0/+6
2017-01-15Wrap the meter information to a namedtuple, instead of a string.Diego Elio Pettenò7-56/+73
This matches the gdef MeterInfo message, and produces a similar (though not identical) string as before. Importantly, it allows providing semantic information.
2016-11-16Fix error in call to map() functionL. Guruprasad1-2/+2
2016-08-31freestyle_optium: ignore β-ketones results from dumps.Diego Elio Pettenò1-4/+7
Since there is no way to expose non-glucose readings right now (I might work on that in the future), filter β-ketones results out from the dump.
2016-08-31freestyle_optium: fix reversed parameters to map().Diego Elio Pettenò1-1/+1
Not sure how this ever worked.
2016-08-31freestyle_optium: remove debugging print.Diego Elio Pettenò1-1/+0
2016-06-19sdcodefree: new driver.Diego Elio Pettenò1-0/+190
This driver supports SD Codefree readers, that are sold in the UK by HomeHealth UK.
2016-05-21otverio2015: fix date/time handling, which was broken outside of UTC.Diego Elio Pettenò1-1/+1
2016-05-21otverio2015: implement proper glucose unit identification.Diego Elio Pettenò1-3/+22
I managed to get my hands on an US-edition of the device, and I can confirm this behaves in a similar way to the otultraeasy.
2016-03-02Use a more Pythonic map(..., int) instead of list comprehension.Diego Elio Pettenò2-4/+4
2016-03-02Move the InvalidChecksum exception to the base exceptions module.Diego Elio Pettenò6-21/+13
Most glucometers have *some* sort of checksum, so there is no reason to implement this on a per-driver basis.
2016-02-15accuchek_reports: add a new driver for Accu-Chek Mobile meters.Diego Elio Pettenò1-0/+129
The default USB connection provides a USB storage device with a CSV datafile. This driver works by looking for that file and importing it. This does not support setting the time, nor reading the actual device time, but it is at least a good way to import data from different meters under the same format.
2016-02-15otultra2: make the before/after meal constants in common module.Diego Elio Pettenò2-4/+9
This will lead the way to providing meal information with future drivers.
2016-02-14otverio2015: new driver for OneTouch Verio (2015) and similar devices.Diego Elio Pettenò1-0/+226
This should be working for OneTouch Select Plus devices, too. It currently does not support reporting in the native unit of the device. As of today, you'll also need my forked repository of python-scsi, as the current upstream one does not have working SGIO for Linux.
2016-02-13Make the ConnectionFailed exception more generic.Diego Elio Pettenò1-2/+2
2016-02-13otultraeasy: move the MalformedCommand exception to common.Diego Elio Pettenò2-11/+17
Also make the exception more general, so that it can be used in the verio2015 driver.
2016-02-13otultraeasy: move the crc function to lifescan_common.Diego Elio Pettenò2-14/+25
The same CRC-CCITT function is used in Verio 2015 devices, so prepare to reuse it by moving it to the common module.
2016-02-09Update documentation, reference the new glucometer-protocols repository.Diego Elio Pettenò1-1/+8
Also update copyright year.
2016-02-09freestyle_optium: implement checksum verification on results.Diego Elio Pettenò1-2/+26
This should ensure more integrity of the results, and matches the behaviour on the lifescan devices.
2016-02-08Implement a basic driver for the FreeStyle Optium devices.Diego Elio Pettenò2-0/+256
This driver supports dumping of (glucose) readings and reading/setting the clock.
2014-02-08otultra2: avoid using connect/disconnect to wake up the device.Diego Elio Pettenò1-3/+2
It seems like the device is very sensible to the reset command.
2014-01-29otultra2: move checksum function within otultra2 driver.Diego Elio Pettenò2-21/+20
The function is not shared with the Ultra Easy and likely not with other devices either.
2014-01-29Initial support for OneTouch Ultra Easy glucometers.Diego Elio Pettenò1-0/+326
The driver is fully functional but requires proper documentation and testing.
2014-01-29common: fix namedtuple usage to allow for optional parameters.Diego Elio Pettenò1-3/+3
The otultraeasy does not provide comments or meal indications.
2014-01-29Add connect/disconnect methods to otultra2 and send \x11\r on connection.Diego Elio Pettenò1-5/+8
The otultraeasy requires explicit connect/disconnect so implementing this before is helpful.
2013-12-11Clean up the code to remove methods that should be functions and imports.Diego Elio Pettenò2-121/+115
2013-12-11Allow sorting the dumped data; sort by date by default.Diego Elio Pettenò1-5/+7
This changes the dump output for otultra2 devices as they would dump data in record format, last reading first.
2013-12-11Change all the internal representations to mg/dL for compatibility with LifeScan.Diego Elio Pettenò2-15/+12
While mmol/L is the international standard unit, at least LifeScan uses mg/dL in all their devices, and since they are the ones for which we have protocols for, we might as well use the same.
2013-12-11Generalise the meal/comment handling to the Reading object.Diego Elio Pettenò2-6/+15
While not all readers implement before/after meal notes, it's possible to implement an heuristics for that.
2013-12-11otultra2: expose the meal and comments as separate field in the CSV.Diego Elio Pettenò1-5/+1
Idea by Jim Sifferle, implemented in a slightly different way as I noticed I forgot to quote it properly.
2013-12-08Better error handling.Diego Elio Pettenò1-1/+1
If any exception is thrown by the library, print an error statement and return a non-zero exit value.
2013-12-08Add a new command to dump the identification of the glucometer.Diego Elio Pettenò1-0/+18
This allows to get the serial number, as well as other details about the glucometer once it's installed.
2013-12-08otultra2: implement a zero log command to clear a device's memory.Diego Elio Pettenò1-1/+11
2013-12-08otultra2: implement decoding of meal and comment codes.Diego Elio Pettenò2-2/+33
This also dumps the comment with the dump command.
2013-09-29Read more data out of the OTUltra2 dump lines. Return data in a Reading object.Diego Elio Pettenò2-10/+30
The Reading object will be extended to cater for flags, comments and other device-specific information.
2013-08-03Relicense everything under MIT license.Diego Elio Pettenò4-4/+4
There is no reason for me to use GPLv3 now that I'm not using the CRC32-Sick code, so I'll go with the most liberal license out there.
2013-08-03Implement the correct checksum algorithm.Diego Elio Pettenò1-30/+8
Unlike what I though, OneTouch2 does not use CRC32 Sick algorithm, but a very stupid full 16-bit modulo sum of the bytes in the reply. This is very simple and does not require GPLv3 code at all.
2013-08-03Add support for checksum verification for the otultra2 driver.Diego Elio Pettenò3-25/+91
This introduced some changes in the Exception class to simplify the code, and at the same time it adds a module for multiple lifescan drivers to share code (multiple OneTouch protocols share the same checksum for instance).
2013-08-03Update function names to follow PEP8.Diego Elio Pettenò2-28/+28
2013-08-03Add utf-8 encoding specification to all files.Diego Elio Pettenò3-0/+3
2013-08-03otultra2: fix default unit handling.Diego Elio Pettenò1-1/+2