• We recently switched our forum platform. If you experience any issues please email support@crystalfontz.com

temp conv. example

bhecox

New member
Can anyone submit a Non-C example of how to convert the DOW report packet
from a scab board? python,perl,vb, any but
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 

CF Tech

Administrator
First off, there is an error in the data sheet. It currently reads:
Code:
0x82: Temperature Sensor Report
type = 0x82
data_length = 4
data[0] is the index of the temperature sensor being reported:
data[1] is the MSB of Temperature_Sensor_Counts <<<<<<<<<<
data[2] is the LSB of Temperature_Sensor_Counts <<<<<<<<<<
data[3] is DOW_crc_status
It should read:
Code:
0x82: Temperature Sensor Report
type = 0x82
data_length = 4
data[0] is the index of the temperature sensor being reported:
data[1] is the LSB of Temperature_Sensor_Counts <<<<<<<<<<
data[2] is the MSB of Temperature_Sensor_Counts <<<<<<<<<<
data[3] is DOW_crc_status
Taking that into account, and getting rid of the C tricks gives:
Code:
if(packet->data[3]==0)
  print("INVALID CRC: NO SENSOR, BAD CABLE, ETC");
else
  {
  float
    degc;
  float
    degf;
  degc=(packet->data[1]+(256*packet->data[2])) / 16.0;
  degf=(degc*9.0)/5.0+32.0;
  }
Does that help to clear it up at all?
 

bhecox

New member
code bug

Yes, that helps alot, I believe I'm back on track now.

I'm using python:
Code:
from struct import *

def parse_temp_report(report=()):
    temp_c = (ord(report[3]) + (256*ord(report[4])))/16.0
    temp_f = (temp_c*9.0)/5.0+32.0
    print temp_c," ",temp_f

def poll(delay=.01):
    global LCD
    while 1:
        chars = LCD.TTY.inWaiting()
        read0 =  LCD.TTY.read(chars)
        if len(read0)>0:
            unpack_var = ""
            for char in range(chars):unpack_var += "c"
            recvd = struct.unpack(unpack_var,read0)
            if recvd[0] == "\x82":
                if len(recvd)>4:
                    parse_temp_report(recvd)
        time.sleep(delay)
Which now is working great!!!!

If any one needs help with a CFA-635 python Lib just let me know. Thanks agian CF tech for all your help!
 
Top