-
Notifications
You must be signed in to change notification settings - Fork 8.1k
modem: cellular: baudrate update from devicetree #97702
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
base: main
Are you sure you want to change the base?
modem: cellular: baudrate update from devicetree #97702
Conversation
Add the option for request strings to be selected at runtime from a function instead of hardcoded at compile time. Signed-off-by: Jordan Yates <[email protected]>
Validate that the `request_fn` functionality works as expected. Signed-off-by: Jordan Yates <[email protected]>
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.
Scripts are designed to be prepared in advance, they can be hardcoded to save RAM, or they can be stored in RAM and prepared at runtime.
And this PR was designed to preserve that capability to the greatest extent possible. In return, this allows moving hardware configuration to devicetree, which is where it should be. More generally, it allows tailoring any AT commands which should be configured on a per device basis, rather than the hardcoded configuration currently. The current behaviour of |
|
|
||
| target-speed: | ||
| type: int | ||
| default: 3000000 |
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.
Isn't baud rate dependent on host capabilities? Might a more conservative default of 1000000 be 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.
Absolutely, and this was the primary motivation for the change. The value of 3000000 was chosen to match the deprecated kconfig option, but I can drop it back to 921600 or something if that is preferable.
275f892 to
e52041c
Compare
Simplicity is the key here, not saving a few bytes. The simplest way to achieve this is to just define a custom baudrate request script for the instance of the lara_r6. and if this is common to all modems, which it looks like it is, a helper can be created which is a bit more general. A more complex way would be to add a mutable script and use that across all modems like we do for apn requests but those cost quite a bit of RAM and complexity.
I agree with the problem, I just don't agree with the proposed solution |
|
Simplicity is the key here I guess the question is, simplicity for who, and where. Your proposal works, but basically doubles the size of the device creation macro. I am skeptical of turning it into a generic macro, if configuration could be generalized in that way, we probably wouldn't be duplicating every chat script for every modem. The second optioned mentioned, the mutable scripts used by the APN configuration, is a ridiculous amount of boilerplate and code for what essentially boils down to sending a compile time const string. But even ignoring those two points above, the changes to
That's completely trivial with the ability to pull the string from a function, but I don't even want to think about the headache of doing it with dynamic scripts and flat out impossible with the constant scripts. My follow up question would be, what part of this proposal has the complexity you are arguing against? |
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 think this looks great. It's an elegant solution and provides an alternate way to send commands via modem chat.
Moving the baud rate to DT is also nice.
It's not clear to me where the issue lies here...
e52041c to
f0071d4
Compare
|
Removed |
Move baudrate updates from a global kconfig to a devicetree property. Signed-off-by: Jordan Yates <[email protected]>
f0071d4 to
2e3c4e0
Compare
|
|
(sorry I accidentally edited the comment instead of quote replying)
Users of the modem subsystem, where complexity leads to bugs and makes it harder to work with.
The size of the macro is not an issue for me, it has no affect on code size, and could be made generic, thus making that size negligible.
Sure, I agree
Functionality which I purposely designed against. AT like communication flow is predetermined, there is a known value to send before the script is started, and the expected response to the command, anything outside of that is an error. There should be no reason to be "in-flight" modifying the scripts behavior.
We do exactly this in GNSS drivers, prepare script, send script, wait, repeat.
Yes, that's why we have dynamic ones
The unnecessary changes to modem_chat is my biggest issue. |
That's a blanket argument against adding any feature ever. I also disagree that the implementation details of the internals would somehow make the modem subsystem harder to work with.
That just seems unnecessarily limiting for no real reason. Are there complicated configuration chains that dynamic scripts are needed to solve, sure. Are there also chains which boil down to "if this send 1 else send 2", absolutely. I don't really understand why providing a simpler mechanism to solve the simpler problem is such a problem. I would argue that forcing all users into the dynamic chat approach leads directly to "complexity leads to bugs and makes it harder to work with", which was said by someone at some point.
So turning this: into this: is an unacceptable increase in complexity? I am skeptical |
Its a rewording of KISS, which can be referred to as a blanket statement like any other foundational design philosophy.
This is how I read the above: There is a solution which covers all static cases, and there is a solution that covers all dynamic cases, why can't we add a third solution which covers all static cases, and one more specific "dynamic" usecase. "dynamic" being in quotes since its not actually a dynamic usecase, the string is known at compile time and immuatble.
The dynamic scripts require more knowledge to use than the static ones, but with that knowledge, a user can modify everything. You may see "just a simple change to solve a specific issue", I see a series of follow up PRs adding a callback for the matches, then the response scripts, then the error responses... We already have a complete solution that works for all dynamic cases, a solution which is not even needed to solve the issue in this PR. |
Sure. I don't see why its such a problem to make solving a subclass of problems easier.
And if that makes solving a problem easier, whats your concern? Zephyr exists to solve problems. |
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.
generally fine, props that can change per dev instance, to have it in the dt, instead of a Kconfig
The third solution is not necessary nor scalable, thus it is not a proper solution to the problem.
Like this PR? yeah, I did indeed raise the concern. The solution in this PR is not proper, a SPI transfer does not have a callback to change any of the buffers mid transfer, RTIO does not have a callback to modify an SQE mid transaction, modem_chat does not have a callback to modify a script mid transaction, I could go on. The entire transaction is known BEFORE the transaction is started, thus, that is when it shall be defined. |



Move baudrate updates from a global kconfig to a devicetree property.
Implemented by extending the modem chat API to support requests to be provided from a callback instead of being statically specified.
Tested on an OOT modem using the same implementation as applied for the LARA_R6.