Poll temperature, Version, Toggle checksum – ThermoProbe TL2 User Manual

Page 13

Advertising
background image

13

02/2013, JK

Send Rate: Poll (enter ? For a temp.)<cr><lf>

Response (failure):

Rate Format">R X" (X =1,10,30,60,3600,Poll)<cr><lf>.

Remarks: The brackets contain the options, separated by commas. (e.g. R 10<cr>, R poll<cr>). A lower case r

or the word Rate (or rate) can be used. Entering 0 is the same as entering poll.

Poll Temperature

Command:

?<cr>

Response (success):

Response (failure): The TL2 sends the temperature now, regardless of the temperature send rate. (When in

polling mode, the TL2 only sends temperatures when it is polled.) Polling for a temperature resets the
timer for the 10-3600 second rate (the next temperature will be sent <rate> seconds from the polled
temperature.

Remarks: Polling can be used when not in polling mode to synchronize the send rate. It can be used in polling

mode to get the temperature exactly when it is needed.

Version

Command:

V<cr>

Response (success): A lower case v can be used. Sends the TL2 firmware version for the main and accessory

boards.

Response (failure): none
Remarks: The version information is useful when verifying that the correct firmware has been loaded on the TL2.


Toggle Checksum

Command:

C<cr>

Response (toggle on): Lower case c can be used. A checksum hash of all bytes (exclusive of the <cr><lf>) is

appended to the temperature string. (a comma precedes the hash and is included in the hash
calculation)

Response (toggle off): Lower case c can be used. Temperatures are sent without a checksum hash.
Remarks: The checksum calculation is a sum of the bytes of the character string except for the terminating

<cr><lf>. All of the bytes are summed in an 8 bit value with overflow bits ignored. Then one is added
to the exclusive OR of the sum. The resulting checksum, when added to all the other bytes, will equal
0.

A sample code segment for the checksum calculation is given here (to keep the code simple, there
isn't any code for checking inputs, etc.):


//

// create checksum

//

// The entire string, including date, time, temperature and commas

// (including the comma before the checksum)

//

#define

STRING_LEN 42

char

sz_string[STRING_LEN + 1] =

"2012-09-11,14:00:21,24.3254,C,24.2996,C,1C"

;

// checksum is

1C

// String to convert decimal to ascii hex

char

hex[16] = {

'0'

,

'1'

,

'2'

,

'3'

,

'4'

,

'5'

,

'6'

,

'7'

,

'8'

,

'9'

,

'A'

,

'B'

,

'C'

,

'D'

,

'E'

,

'F'

};

// The checksum string

char

sz_checksum[3] =

"\0"

;

// The checksum value

unsigned

char

c_sum = 0;

unsigned

int

c_checksum = 0;

int

i = 0;

// compute checksum for the date/time/temperature string

for

(i = 0; i < (STRING_LEN - 2); i++){

c_sum += (

unsigned

char

)sz_string[i];

}
c_sum = (

unsigned

char

)((c_sum ^ 0xFF) + 1);

// convert c_checksum to ascii

Advertising