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

String record handling data truncation #46

Closed
AlexanderWells-diamond opened this issue Oct 11, 2021 · 2 comments · Fixed by #79
Closed

String record handling data truncation #46

AlexanderWells-diamond opened this issue Oct 11, 2021 · 2 comments · Fixed by #79
Assignees

Comments

@AlexanderWells-diamond
Copy link
Collaborator

When creating a string record, if you set an initial_value that is longer than 39 characters the data is silently truncated. It would be useful if there was at least a warning/error of some kind emitted when this occurs.

In this example note that the trailing "!" of the string is missing:

# Import the basic framework components.
from softioc import softioc, builder, asyncio_dispatcher

# Create an asyncio dispatcher, the event loop is now running
dispatcher = asyncio_dispatcher.AsyncioDispatcher()

# Set the record prefix
builder.SetDeviceName("PREFIX")

# Create some records
bo1 = builder.stringOut('SO', initial_value="hello this is long sentence of 39 chars!")

# Boilerplate get the IOC started
builder.LoadDatabase()
softioc.iocInit(dispatcher)

# Finally leave the IOC running with an interactive shell.
softioc.interactive_ioc(globals())

Getting the value:

[...]$ caget PREFIX:SO
PREFIX:SO                      hello this is long sentence of 39 chars
@AlexanderWells-diamond
Copy link
Collaborator Author

Note that I have already added a tiny amount of logging to the AsyncioDispatcher https://github.com/dls-controls/pythonSoftIOC/blob/master/softioc/asyncio_dispatcher.py#L37

If the warnings module is used for user notification instead then this one should use the same mechanism.

@AlexanderWells-diamond
Copy link
Collaborator Author

This ended up being mostly fixed in #60, then fully fixed in 53f107d, with a test added in 5f14ca3 as part of #79

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

Successfully merging a pull request may close this issue.

2 participants