Skip to content

Commit 86a6247

Browse files
committed
Issue #26: Read chip temperature
1 parent fdc8e0c commit 86a6247

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ For example:
3737
reader = mercury.Reader("tmr:///dev/ttyUSB0", baudrate=9600)
3838
```
3939

40+
#### reader.get_temperature()
41+
Returns the chip temperature in degrees of Celsius.
42+
4043
#### reader.get_supported_regions()
4144
Lists supported regions for the connected device.
4245

mercury.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,21 @@ Reader_set_read_plan(Reader *self, PyObject *args, PyObject *kwds)
385385
return NULL;
386386
}
387387

388+
static PyObject *
389+
Reader_get_temperature(Reader *self)
390+
{
391+
TMR_Status ret;
392+
uint8_t temp;
393+
394+
if ((ret = TMR_paramGet(&self->reader, TMR_PARAM_RADIO_TEMPERATURE, &temp)) != TMR_SUCCESS)
395+
{
396+
PyErr_SetString(PyExc_TypeError, "Error getting temperature");
397+
return NULL;
398+
}
399+
400+
return PyLong_FromLong(temp);
401+
}
402+
388403
static PyObject *
389404
Reader_get_antennas(Reader *self)
390405
{
@@ -754,6 +769,9 @@ Reader_get_model(Reader* self)
754769
}
755770

756771
static PyMethodDef Reader_methods[] = {
772+
{"get_temperature", (PyCFunction)Reader_get_temperature, METH_NOARGS,
773+
"Returns the chip temperature"
774+
},
757775
{"get_antennas", (PyCFunction)Reader_get_antennas, METH_NOARGS,
758776
"Lists available antennas."
759777
},

0 commit comments

Comments
 (0)