BCDA-APS / apstools

various tools for use with Bluesky at the APS
https://bcda-aps.github.io/apstools/latest/
Other
16 stars 9 forks source link

synApps AsynRecord device binary output fails #871

Open canismarko opened 1 year ago

canismarko commented 1 year ago

Trying to write commands via the binary output of an asyn record for setting up an ensemble controller. The commands seem to get sent, but the returned status object does not complete properly.

Step Taken

from apstools.synApps.asyn import AsynRecord
asyn = AsynRecord("25idc:aerotech:cmdWriteRead", name="asyn")
asyn.binary_output.set("PSOCONTROL @0 RESET").wait()

Expected Outcome

The wait status completes successfully without error.

Actual Outcome

The command gets properly set to the EPICS record as seen via a camonitor, but the status does not complete properly:

UnknownStatusFailure: The status Status(obj=EpicsSignal(read_pv='25idc:aerotech:cmdWriteRead.BOUT', name='asyn_binary_output', parent='asyn', value='PSOCONTROL @0 RESET', timestamp=1689262760.340343, auto_monitor=True, string=True, write_pv='25idc:aerotech:cmdWriteRead.BOUT', limits=False, put_complete=False), done=False, success=False) has failed. To obtain more specific, helpful errors in the future, update the Device to use set_exception(...) instead of _finished(success=False).

Workaround

If I subclass the AsynRecord and make binary_output a string record using string=True, then it works as expected.

class MyAsyn(AsynRecord):
    binary_output = Component(EpicsSignal, ".BOUT", kind="normal", string=True)

asyn = MyAsyn("25idc:aerotech:cmdWriteRead", name="asyn")
asyn.binary_output.set("PSOCONTROL @0 RESET").wait()
MarkRivers commented 1 year ago

Is there a reason you are using binary output mode when the value you are sending appears to be an ASCII string?

The error could be because you are using cmdWriteRead. When it reads from the device it needs to know when the read is complete. If you use binary mode then it ignores terminators, and so the readback may be timing out. You can use asynTrace to debug.

canismarko commented 1 year ago

@MarkRivers I'm copying from @timmmooney's PSOEnsembleFly.db file which uses .BOUT. I tried the ascii output and that also seems to work, so I guess I don't have a reason to use .BOUT other than this is what Tim used.

MarkRivers commented 1 year ago

It also matters what input format and output format the asyn record is using. These are the IFMT and OFMT fields documented here: https://epics-modules.github.io/asyn/asynRecord.html#input-output-control-fields