caproto pvproperty string PV issue
vstadnytskyi opened this issue · 1 comments
I have a caproto server with a string PV. The max length of the PV is 1. I get an error on the server side If I use pyepics to write into this PV. Interestingly there are no problems with caproto.threading.client.write() function and I can write one character without a problem.
it works fine, if the default value is longer than 1 or i set max_length large than 1. So there is something special about how caproto processes the string sent from pyepics wx.PVTextCtrl field.
Codes:
caproto-sandbox/server_string_pv.py
caproto-sandbox/server_string_pv_client.py
caproto-sandbox/server_string_pv_gui.py
If I use pyepics GUI
works:
VALVE = pvproperty(value='nnnnnn', dtype=str)
VALVE = pvproperty(value='', dtype=str, max_length = 2)
VALVE = pvproperty(value='nn', dtype=str)
doesn't work:
VALVE = pvproperty(value='', dtype=str)
VALVE = pvproperty(value='', dtype=str, max_length = 1)
If I use caproto threading client it works always.
In [14]: client.VALVE.write('b')
Out[14]: WriteNotifyResponse(data_type=<ChannelType.CHAR: 4>, data_count=1, status=CAStatusCode(name='ECA_NORMAL', code=0, code_with_severity=1, severity=<
CASeverity.SUCCESS: 1>, success=1, defunct=False, description='Normal successful completion'), ioid=0)
In [15]: client.VALVE.write('o')
Out[15]: WriteNotifyResponse(data_type=<ChannelType.CHAR: 4>, data_count=1, status=CAStatusCode(name='ECA_NORMAL', code=0, code_with_severity=1, severity=<
CASeverity.SUCCESS: 1>, success=1, defunct=False, description='Normal successful completion'), ioid=1)
Error:
ERROR:caproto.circ:Invalid write request by user-13 (user 13.niddk.nih.gov): WriteRequest(data=array([0], dtype=uint8), data_type=<ChannelType.CHAR: 4>, d
ata_count=1, sid=0, ioid=3, metadata=None)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/caproto/server/common.py", line 471, in handle_write
user_address=self.circuit.address)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/caproto/_data.py", line 434, in auth_write
flags=flags))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/caproto/_data.py", line 971, in write_from_dbr
await super().write_from_dbr(*args, flags=flags, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/caproto/_data.py", line 462, in write_from_dbr
direction=ConversionDirection.FROM_WIRE)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/caproto/_backend.py", line 346, in convert_values
convert_from=from_dtype)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/caproto/_numpy_backend.py", line 64, in python_to_epics
return np.asarray(values).astype(type_map[dtype])
ValueError: invalid literal for int() with base 10: ''
I have found there are some other dtypes. One of them looks like chr dtype ChannelType.CHAR: PvpropertyChar,
, but I am not sure how to specify it when I create the pvproperty.