Files
frappy/frappy_psi/capacitance_readings/TSSOP16.py
2025-07-21 17:10:50 +02:00

31 lines
979 B
Python

import serial
import time
import traceback
from frappy.core import Readable, Parameter, FloatRange, HasIO, StringIO, Property, IntRange, IDLE, BUSY, WARN, ERROR, Drivable, BoolType, Attached
class TSSOP16_IO(StringIO):
end_of_line = '\r'
wait_before = 0.0 #3.0
identification = [ ('*IDN?', r'0x48,ACM1219,.*') ]
class TSSOP16(HasIO, Readable):
'''only configured for channel 1'''
ioClass = TSSOP16_IO
value = Parameter('value', FloatRange(unit='pF'), readonly=True)
pollinterval = Parameter(default=0.1)
def read_value(self):
try:
l = self.communicate('readCVT')
vals = l.split(',')
vals = [ float(v) for v in vals ]
#print(vals)
return vals[0]
except:
traceback.print_exc()
self.io.closeConnection()
self.io.connectStart()
time.sleep(3.0)
return self.read_value()