From 836baf451270367a06e9dd4e64bacf90f5c038bd Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Fri, 8 Apr 2016 10:59:37 -0700 Subject: [PATCH] Additional commands, dump utility --- dump.py | 42 ++++++++++++++++++++++++++++++++++++++++++ ilt1000.py | 48 +++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 87 insertions(+), 3 deletions(-) create mode 100755 dump.py diff --git a/dump.py b/dump.py new file mode 100755 index 0000000..c583cfb --- /dev/null +++ b/dump.py @@ -0,0 +1,42 @@ +#!/usr/bin/python3 + +import argparse +import ilt1000 + + +parser = argparse.ArgumentParser(description='ilt1000 dump') +parser.add_argument( + '--device', + dest='device', + action='store', + default='/dev/ttyUSB1') +FLAGS = parser.parse_args() + + +LABEL_WIDTH = 25 + + +def PrintLine(label, value, unit=''): + print(('%s:' % label).rjust(LABEL_WIDTH), value, unit) + + +ilt = ilt1000.ILT1000(device=FLAGS.device) + + +LINES = [ + ('Model', ilt.GetModelName, ''), + ('Generation', ilt.GetGeneration, ''), + ('Firmware version', ilt.GetFirmwareVersion, ''), + ('Serial number', ilt.GetSerialNumber, ''), + ('Controller temperature', ilt.GetControllerTempF, '°F'), + ('Ambient temperature', ilt.GetAmbientTempF, '°F'), + ('Date/time', ilt.GetDateTime, ''), + ('Sensor current', ilt.GetSensorCurrent, 'A'), + ('Sensor voltage', ilt.GetSensorVoltage, 'V'), + ('Transmission', ilt.GetTransmissionPercent, '%'), + ('Optical density', ilt.GetOpticalDensity, '%'), +] + + +for label, callback, unit in LINES: + PrintLine(label, callback(), unit) diff --git a/ilt1000.py b/ilt1000.py index 0d58161..6580497 100755 --- a/ilt1000.py +++ b/ilt1000.py @@ -24,9 +24,46 @@ class Saturated(Error): pass +# TODO commands: +# eraselogdata +# get100perc +# getauxserialno +# getdarkmode +# getfactorydark +# getirradiance +# getlogdata +# getuserdark +# set100perc +# setautaveraging +# setcurrentloop +# sethiaveraging +# setlowaveraging +# setmedaveraging +# setsimpleirrcal +# setuserdark +# startlogdata +# stoplogdata +# usecalfactor +# usefactorydark +# usefeedbackres +# usenodark +# useuserdark +# erasecalfactor +# getcalfactor +# getclockfreq +# getfeedbackres +# setcalfactor +# setclockfreq +# setsamplecount + + class ILT1000(object): - def __init__(self, device, set_time=True): + # ILT1000 presents two FTDI serial devices, which become ttyUSB0 and ttyUSB1 + # if nothing else is attached. ttyUSB0 seems to be completely non-responsive. + # We default to ttyUSB1 + + def __init__(self, device='/dev/ttyUSB1', set_time=True): self._dev = serial.Serial(device, 115200) try: # clear junk in outgoing buffer @@ -66,6 +103,7 @@ class ILT1000(object): return int(self._SendCommand('gettemp')) def GetAmbientTempF(self): + # SPEC ERROR # Protocol doc indicates that this is degrees F * 100, but actual values # look like just degrees F return int(self._SendCommand('getambienttemp')) @@ -80,11 +118,15 @@ class ILT1000(object): ret = self._SendCommand('setdatetime ' + timestr) assert int(ret) == 0 - def GetCurrentPicoAmps(self): + def GetSensorCurrent(self): + # SPEC ERROR + # Protocol doc indicates that this is in pA, but atual values are in + # scientific notation and appear to be A. They are also suspiciously + # similar to getvoltage return values. ret = self._SendCommand('getcurrent') return float(ret) - def GetVoltage(self): + def GetSensorVoltage(self): ret = self._SendCommand('getvoltage') return float(ret) / 1000000