Having trouble using a C library via a Python API: What am I doing wrong?
Question: I'm using a Python script in conjunction with a thermocouple and a
thermocouple reader. To communicate with the thermocouple reader, which is
written in C, I have to use an API. That API is
[PyDAQFlex](https://github.com/torfbolt/PyDAQFlex). The thermocouple reader
also came with a tester script, written in C. I'm trying to get a temperature
reading from the thermocouple reader, but it only outputs the CJC value.

My code:

    
    
    import daqflex
    
    d = daqflex.USB_2001_TC()
    
    def get_temperature():
        return float(d.send_message("?AI{0}:CJC/DEGC").encode("utf-8"))
    

The output of my code:

    
    
    u'AI{0}:CJC/DEGC=23.8'
    

Note: 23.8 is _not_ the temperature. That value is the CJC, as seen in the
tester script's command line output below. It's related, but not the value I'm
looking for.

* * *

The tester script's code:

<http://pastebin.com/Atsdy7X0> (to get the temperature, I press "t" and then
"k" because I have a K-type thermocouple).

The tester script's command line output:

<http://pastebin.com/jq4Rr4QX> (the temperature here is accurate. This is what
I want to plug into my script.)

* * *

The PyDAQFlex script:

<https://github.com/torfbolt/PyDAQFlex/blob/master/daqflex/devices.py> (see
line 105)

The C code for the thermocouple reader:

<http://pastebin.com/rEDR9efR> (Not included in entirety, only the relevant
parts.)

* * *

I am seriously struggling to see my mistake here. This [exact piece of
code](https://github.com/torfbolt/PyDAQFlex/issues/6) appears to have worked
for someone else in the PyDAQFlex Github page, so I'm extremely confused. I
have emailed the creator of the software, a person in Github with a similar
issue as me, and I just spent 6 hours in various IRC chats. Please help me. If
it helps, I used parts of
[this](http://www.mccdaq.com/TechTips/TechTip-9.aspx) tutorial to install the
drivers and things for the thermocouple reader. Thank you so much.


Answer: If 23.8 is related, but not the right temp, then it is a calibration problem.
Could you print what original tester program and pydaqflex send and receive
from the device, when calibrating?

