On Thu, Jun 5, 2025 at 3:37 PM Elias Hawa <elias.hawa2...@gmail.com> wrote:

> Hello everyone,
>
> I'm currently working on a sensor driver for the Quectel L86-M33 GNSS
> module. It communicates over UART and is very feature rich, allowing users
> to send commands over UART to modify things such as position fix interval
> and device baud rate (default at 9600).
>
> I'm able to correctly send commands to the device to change its baud rate,
> but I've so far been unsuccessful in figuring out how to change the baud
> rate of the UART device. So far I've attempted to change the baud rate
> using `file_ioctl` and termios within the device driver but had no luck. I
> also experimented with using termios calls in userspace but also had no
> success there. In each instance, the device would crash shortly after
> attempting to change the baud rate of the UART device.
>
> I've confirmed that commands are being sent correctly as changing the baud
> rate of the GNSS module without changing the baud rate of the UART device
> returns illegible text.
>
> Any help is appreciated,
> Elias



Hi Elias,

I assume the UART whose BAUD rate you wish to change is a peripheral of
your microcontroller chip?

What microcontroller arch are you using?

Note that the termios and/or ioctl are calling an upper half driver, but in
order for these calls to be successful--that is, in order for them to work
properly and actually change your UART BAUD rate--there has to be an
implementation in the lower half driver.

In NuttX, the concept of upper half and lower half drivers can be summed up
as follows: the upper half is device independent and shared by all
architectures; the lower half driver is device-specific. This is documented
here:
https://nuttx.apache.org/docs/latest/components/drivers/index.html

I did some work on the UART code to add some missing termios and ioctl
support on the architectures I use and am able to test. You can look
through some of the PRs I did, in case it helps you find your way around
the code.

For example:

PR-8465
https://github.com/apache/nuttx/pull/8465

might be relevant. In that one, I made the CTS/RTS termios or ioctls work
on Tiva architecture.

You might see what code was added in that PR. The changes were in up_ioctl
of that arch. That's part of the lower half driver. In that same function
you'll likely see the entry point for altering the BAUD rate.

Then, find the corresponding code of your arch and see if such handling is
missing. If so, adding it will probably solve the issue.

Hope this helps,

Nathan

Reply via email to