ACM1219: add checkHWIdent

waiting 0.5 sec before the first communication helps to start
properly

+ added usb dev names for box
This commit is contained in:
zolliker 2024-07-03 14:09:13 +02:00 committed by Markus Zolliker
parent 476d2087f6
commit 21dae2d9ce
2 changed files with 17 additions and 5 deletions

View File

@ -8,7 +8,7 @@ Node('UC220T.psi.ch',
Mod('io1', Mod('io1',
'frappy_psi.RP100.RP100IO', 'frappy_psi.RP100.RP100IO',
'communication', 'communication',
uri='serial:///dev/tty.usbmodem1401?baudrate=9600+bytesize=8+parity=none+stopbits=1') uri='serial:///dev/ttyACM0?baudrate=9600+bytesize=8+parity=none+stopbits=1')
Mod('V1', Mod('V1',
'frappy_psi.RP100.VoltageChannel', 'frappy_psi.RP100.VoltageChannel',
'Voltage Channel 1', 'Voltage Channel 1',
@ -33,7 +33,7 @@ Mod('V2',
Mod('io2', Mod('io2',
'frappy_psi.ACM1219.ACM1219IO', 'frappy_psi.ACM1219.ACM1219IO',
'communication', 'communication',
uri='serial:///dev/tty.usbserial-A904TGR7?baudrate=9600+bytesize=8+parity=none+stopbits=1') uri='serial:///dev/ttyUSB0?baudrate=9600+bytesize=8+parity=none+stopbits=1')
Mod('C1C2', Mod('C1C2',
'frappy_psi.ACM1219.BothChannels', 'frappy_psi.ACM1219.BothChannels',
'Capacitance channels 1 and 2', 'Capacitance channels 1 and 2',
@ -81,4 +81,4 @@ Mod('T',
'frappy_psi.dummy.Temp', 'frappy_psi.dummy.Temp',
'dummy T written from client', 'dummy T written from client',
target=Param(min=1, max=325), target=Param(min=1, max=325),
) )

View File

@ -17,6 +17,7 @@
# Paul M. Neves <pmneves@mit.edu> # Paul M. Neves <pmneves@mit.edu>
# ***************************************************************************** # *****************************************************************************
import time
from frappy.core import Readable, Parameter, FloatRange, HasIO, StringIO, Property, IntRange,\ from frappy.core import Readable, Parameter, FloatRange, HasIO, StringIO, Property, IntRange,\
IDLE, BUSY, WARN, ERROR, Drivable, BoolType, Attached, StructOf IDLE, BUSY, WARN, ERROR, Drivable, BoolType, Attached, StructOf
@ -24,7 +25,18 @@ from frappy.core import Readable, Parameter, FloatRange, HasIO, StringIO, Proper
class ACM1219IO(StringIO): class ACM1219IO(StringIO):
"""communication with ACM1219""" """communication with ACM1219"""
end_of_line = ('\r\n', '\r') # ('\n', '\r') ('\r\n', '\r') end_of_line = ('\r\n', '\r') # ('\n', '\r') ('\r\n', '\r')
identification = [('*IDN?', r'.*')] encoding = 'latin-1' # initial reply might not be ascii for a strange reason
identification = [('*IDN?', r'.*,ACM1219,.*')]
def checkHWIdent(self):
for _ in range(3):
time.sleep(0.5)
try:
self.communicate('*IDN?')
break
except Exception:
pass
super().checkHWIdent()
class BothChannels(HasIO, Readable): class BothChannels(HasIO, Readable):
@ -188,4 +200,4 @@ class YoungsModulus(Readable):
def read_value(self): def read_value(self):
return self.stress.value / self.strain.value return self.stress.value / self.strain.value