DiamondLightSource / cothread

Cooperative Python Threads and EPICS Channel Access bindings
Apache License 2.0
13 stars 9 forks source link

Disconnected channel incorrectly generate InvalidDatatype error #16

Closed blondejamtart closed 4 years ago

blondejamtart commented 4 years ago

Typical traceback:

Traceback (most recent call last):
  File "bug_maker.py", line 63, in <module>
    print(catools.caget("pc0111-BUG-REPR-%02d:PID" % (i + 1)))
  File "/dls_sw/prod/common/python/RHEL7-x86_64/pymalcolm/4-1/prefix/lib/python2.7/site-packages/cothread-2.16-py2.7-linux-x86_64.egg/cothread/catools.py", line 745, in caget
    return caget_one(pvs, **kargs)
  File "/dls_sw/prod/common/python/RHEL7-x86_64/pymalcolm/4-1/prefix/lib/python2.7/site-packages/cothread-2.16-py2.7-linux-x86_64.egg/cothread/catools.py", line 130, in throw_wrapper
    return function(pv, *args, **kargs)
  File "/dls_sw/prod/common/python/RHEL7-x86_64/pymalcolm/4-1/prefix/lib/python2.7/site-packages/cothread-2.16-py2.7-linux-x86_64.egg/cothread/catools.py", line 621, in caget_one
    dbrcode, dbr_to_value = dbr.type_to_dbr(channel, datatype, format)
  File "/dls_sw/prod/common/python/RHEL7-x86_64/pymalcolm/4-1/prefix/lib/python2.7/site-packages/cothread-2.16-py2.7-linux-x86_64.egg/cothread/dbr.py", line 776, in type_to_dbr
    dbrcode = _type_to_dbrcode(datatype, format)
  File "/dls_sw/prod/common/python/RHEL7-x86_64/pymalcolm/4-1/prefix/lib/python2.7/site-packages/cothread-2.16-py2.7-linux-x86_64.egg/cothread/dbr.py", line 657, in _type_to_dbrcode
    datatype = _datatype_to_dbr(datatype)
  File "/dls_sw/prod/common/python/RHEL7-x86_64/pymalcolm/4-1/prefix/lib/python2.7/site-packages/cothread-2.16-py2.7-linux-x86_64.egg/cothread/dbr.py", line 637, in _datatype_to_dbr
    error)
  File "/dls_sw/prod/common/python/RHEL7-x86_64/pymalcolm/4-1/prefix/lib/python2.7/site-packages/cothread-2.16-py2.7-linux-x86_64.egg/cothread/py23.py", line 12, in raise_from
    raise exception
cothread.dbr.InvalidDatatype: Datatype "65535" not supported for channel access
Araneidae commented 4 years ago

This one is easy to fix: turns out that the return code from ca_field_type was not being correctly checked because the return type was not set to c_short. Fixed in commit bf6d7b2c2fcee869d661acf93c8d42d9acafa896