Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

caproto pvproperty string PV issue #8

Open
vstadnytskyi opened this issue Oct 18, 2019 · 1 comment
Open

caproto pvproperty string PV issue #8

vstadnytskyi opened this issue Oct 18, 2019 · 1 comment

Comments

@vstadnytskyi
Copy link
Owner

vstadnytskyi commented Oct 18, 2019

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: ''
@vstadnytskyi
Copy link
Owner Author

vstadnytskyi commented Oct 18, 2019

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.

https://github.com/caproto/caproto/blob/497cbd22da5a3ad45f6955570a3c389b17edbb15/caproto/server/server.py#L1106

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant