Additional commands, dump utility
This commit is contained in:
42
dump.py
Executable file
42
dump.py
Executable file
@@ -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)
|
||||||
48
ilt1000.py
48
ilt1000.py
@@ -24,9 +24,46 @@ class Saturated(Error):
|
|||||||
pass
|
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):
|
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)
|
self._dev = serial.Serial(device, 115200)
|
||||||
try:
|
try:
|
||||||
# clear junk in outgoing buffer
|
# clear junk in outgoing buffer
|
||||||
@@ -66,6 +103,7 @@ class ILT1000(object):
|
|||||||
return int(self._SendCommand('gettemp'))
|
return int(self._SendCommand('gettemp'))
|
||||||
|
|
||||||
def GetAmbientTempF(self):
|
def GetAmbientTempF(self):
|
||||||
|
# SPEC ERROR
|
||||||
# Protocol doc indicates that this is degrees F * 100, but actual values
|
# Protocol doc indicates that this is degrees F * 100, but actual values
|
||||||
# look like just degrees F
|
# look like just degrees F
|
||||||
return int(self._SendCommand('getambienttemp'))
|
return int(self._SendCommand('getambienttemp'))
|
||||||
@@ -80,11 +118,15 @@ class ILT1000(object):
|
|||||||
ret = self._SendCommand('setdatetime ' + timestr)
|
ret = self._SendCommand('setdatetime ' + timestr)
|
||||||
assert int(ret) == 0
|
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')
|
ret = self._SendCommand('getcurrent')
|
||||||
return float(ret)
|
return float(ret)
|
||||||
|
|
||||||
def GetVoltage(self):
|
def GetSensorVoltage(self):
|
||||||
ret = self._SendCommand('getvoltage')
|
ret = self._SendCommand('getvoltage')
|
||||||
return float(ret) / 1000000
|
return float(ret) / 1000000
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user