DexcTrack / dexctrack

A program to dynamically and interactively graph information from Dexcom G4, G5, and G6 CGM receivers.
GNU General Public License v3.0
25 stars 12 forks source link

get only the latest glucose value #16

Open charlesGLP1 opened 7 months ago

charlesGLP1 commented 7 months ago

Thank you very much for sharing this fantastic program. I have a project to use part of the code for grabbing only the last glucose value. The idea was to use this value for a further labview processing. Unfortunately, while labview is capable to call python nodes, I have difficulties to extract only the last glucose value.

Could you help ? I need only a python command to send via the terminal to display in the same terminal window the last glucose value

Thanks in advance

Charles-Henri Malbert

DexcTrack commented 7 months ago

Here's a brief program which might suffice. It's hard for me to test because I "upgraded" to a G7 system, which no longer works with Dexctrack. Dexcom now encrypts all of their data, just to make it difficult for us.

# Support python3 print syntax in python2
from __future__ import print_function

import readReceiver

receiverInstance = None

#---------------------------------------------------------
def getReceiverInstance():
    rsni = None
    rdi = None

    my_dport = readReceiver.readReceiverBase.FindDevice()   # a port descriptor string
    if receiverInstance:
        rsni = receiverInstance
        devType = rsni.GetDeviceType()
    else:
        devType = None
        if my_dport is not None:
            rsni = readReceiver.readReceiver(my_dport, dbg=False)
            if rsni:
                devType = rsni.GetDeviceType()

    if my_dport:
        if rsni and devType:
            if devType == 'g4':
                rdi = readReceiver.readReceiver(my_dport, rsni.port, dbg=False)
            elif devType == 'g5':
                rdi = readReceiver.readReceiverG5(my_dport, rsni.port, dbg=False)
            elif devType == 'g6':
                rdi = readReceiver.readReceiverG6(my_dport, rsni.port, dbg=False)
            else:
                print('getReceiverInstance() : Unrecognized firmware version', devType)
        else:
            rdi = readReceiver.readReceiver(my_dport, dbg=False)

    return rdi

#---------------------------------------------------------

receiverInstance = getReceiverInstance()

if receiverInstance is not None:
    gluc, trend, read_status = receiverInstance.GetCurrentGlucoseAndTrend()
    if gluc:
        print('CurrentGlucose =', gluc, ' trend =', trend, ' status =', read_status)

When I run this with my old G6 Receiver, I get ...

$ python3 dexcGluc.py CurrentGlucose = 1 trend = 88 status = 0

which looks odd. Maybe the glucose and trend values got swapped? Not sure. It's hard to debug because I don't have a paired transmitter anymore.

charlesGLP1 commented 7 months ago

Thank you so much for your fast answer.

I keep you informed of the ongoing work

Sincerlely

Charles


Charles-Henri Malbert Membre titulaire de l'Académie Nationale de Médecine DMV, Dr es Sci, HDR Directeur de Recherches Professeur Medical School The University of Adelaide

Unité Ani-Scan Département de Nutrition Humaine

@.***

INRAE - Site de Saint-Gilles Tèl. : +33 1 (0)2 23 48 50 71

Le 16 nov. 2023 à 23:30, Steve Erlenborn @.***> a écrit :

Here's a brief program which might suffice. It's hard for me to test because I "upgraded" to a G7 system, which no longer works with Dexctrack. Dexcom now encrypts all of their data, just to make it difficult for us.

Support python3 print syntax in python2

from future import print_function

import readReceiver

global receiverInstance = None

---------------------------------------------------------

def getReceiverInstance(): rsni = None rdi = None

my_dport = readReceiver.readReceiverBase.FindDevice()   # a port descriptor string
if receiverInstance:
    rsni = receiverInstance
    devType = rsni.GetDeviceType()
else:
    devType = None
    if my_dport is not None:
        rsni = readReceiver.readReceiver(my_dport, dbg=False)
        if rsni:
            devType = rsni.GetDeviceType()

if my_dport:
    if rsni and devType:
        if devType == 'g4':
            rdi = readReceiver.readReceiver(my_dport, rsni.port, dbg=False)
        elif devType == 'g5':
            rdi = readReceiver.readReceiverG5(my_dport, rsni.port, dbg=False)
        elif devType == 'g6':
            rdi = readReceiver.readReceiverG6(my_dport, rsni.port, dbg=False)
        else:
            print('getReceiverInstance() : Unrecognized firmware version', devType)
    else:
        rdi = readReceiver.readReceiver(my_dport, dbg=False)

return rdi

---------------------------------------------------------

receiverInstance = getReceiverInstance()

if receiverInstance is not None: gluc, trend, read_status = receiverInstance.GetCurrentGlucoseAndTrend() if gluc: print('CurrentGlucose =', gluc, ' trend =', trend, ' status =', read_status)

When I run this with my old G6 Receiver, I get ...

$ python3 dexcGluc.py CurrentGlucose = 1 trend = 88 status = 0

which looks odd. Maybe the glucose and trend values got swapped? Not sure. It's hard to debug because I don't have a paired transmitter anymore.

— Reply to this email directly, view it on GitHub https://github.com/DexcTrack/dexctrack/issues/16#issuecomment-1815416453, or unsubscribe https://github.com/notifications/unsubscribe-auth/BABSNPYKT3OG22B5L5NVHKLYE2HWVAVCNFSM6AAAAAA7OO47HOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJVGQYTMNBVGM. You are receiving this because you authored the thread.

charlesGLP1 commented 7 months ago

It works beautifully. Again many thanks. I have to remove the Global mention in the line Global receiverInstance = None. My knowledge on python is far too small to understand the reason. The essential part is that's it is working

Fantastic program and super help.