-
Notifications
You must be signed in to change notification settings - Fork 6
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
Use inp/out links for mapping terminals #44
Conversation
This should help avoid mistakes in branchy return code
The previous design pattern didn't make much sense
Going to mark this as ready now. Once approved (or mostly approved) I'll regenerate the templates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that this moves to more standard EPICS INP/OUT string handling - not requiring record names to conform and still retaining back-compatibility.
I didn't fully dig into the logic as much as I'd like to, but the methodology seems solid enough to me 👍
ek9000App/src/devEK9000.cpp
Outdated
: drvModbusAsyn(portName, octetPortName, 0, 2, -1, 256, dataTypeUInt16, 150, "") { | ||
|
||
/* Initialize members */ | ||
m_terms = static_cast<devEK9000Terminal*>(malloc(sizeof(devEK9000Terminal) * termCount)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my own information, why the mix of malloc/free and not just use new[]
operator to allocate all terminals?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was confused at my own code here too, but I just remembered: new[]
requires a default constructible type, which devEK9000Terminal
is not because its constructor takes a parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll probably make m_terms
a std::vector<devEK9000Terminal*>
instead- just realized that the destructor is not being called on any devEK9000Terminal
s because the array is simply being freed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. I like the std::vector
approach much better 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Onto regenerating the database files in a follow-up PR?
Also clamp num terminals to <= 0xFF in ek9000Register
I'll do that right now! |
Yep, seeing this in database form reinforces my opinion that it's a good change 👍 |
This ended up being a sizable refactor, but ultimately fixes the biggest issue with the module. Previously record -> terminal mapping was determined by
ek9000ConfigureTerminal
and a numeric suffix on the record name. Now it's done entirely using an inp/out link in theINST_IO
format, similar to how asyn does it.The legacy logic still exists in the module, not sure if I should keep it around or axe it entirely though.
Some other changes made here:
devEK9000
to derive directly fromdrvModbusAsyn
, as it should've in the first placestrdup
calls I missed during an earlier refactorStill a draft for now until I decide what to do with the legacy paths. Also haven't regenerated the DB templates yet, just to make it easier to review :)