Page 1 of 1
Serial Device: usart speed change "on the fly"
Posted: Mon Dec 10, 2012 7:45 pm
by ucasano
Hi,
I need to change the speed of my serial port driver, i.e. at 57600bps, after the serial driver has already been started, i.e. at 9600bps.
In order to do so, I have to start at 9600bps, send the AT command "AT+IPR=57600", wait for OK answer and then switch to 57600.
This is what I think to do:
1) send sdStop()
2) change speed parameter to 57600bps
3) send sdStart()
Could this be working for me?
Thanks.
-g
Re: Serial Device: usart speed change "on the fly"
Posted: Mon Dec 10, 2012 7:47 pm
by Giovanni
Hi,
You don't need to stop, just call sdStart() again to set new parameters, of course you need multiple configuration structures.
Giovanni
Re: Serial Device: usart speed change "on the fly"
Posted: Mon Dec 10, 2012 8:00 pm
by ucasano
Alright, I will do so!
Thanks.
-g
Re: Serial Device: usart speed change "on the fly"
Posted: Wed Feb 06, 2013 10:39 pm
by kalevik
Giovanni wrote:Hi,
You don't need to stop, just call sdStart() again to set new parameters, of course you need multiple configuration structures.
Giovanni
You must be kidding
If i make user selectable communication parameters (with dip switch), lets say 1200-115200 and 1/2 stop bit, i must wrote 16 configuration structure?
kalevik
Re: Serial Device: usart speed change "on the fly"
Posted: Wed Feb 06, 2013 10:47 pm
by Giovanni
You can have one structure and change it or multiple constant structures.
Giovanni
Re: Serial Device: usart speed change "on the fly"
Posted: Thu Feb 07, 2013 6:29 am
by kalevik
Giovanni wrote:You can have one structure and change it or multiple constant structures.
Giovanni
Okay, i understand wrong your answer to ucasano, "of course you need multiple configuration structures".
kalevik
Re: Serial Device: usart speed change "on the fly"
Posted: Fri Mar 12, 2021 6:55 pm
by rew
Giovanni wrote:You don't need to stop, just call sdStart() again to set new parameters, of course you need multiple configuration structures.
i
This is inconsistent with lots of other stuff in Chibios: Many things in Chibios don't tolerate being restarted by "just call start again", because they are not in the right "state".
Re: Serial Device: usart speed change "on the fly"
Posted: Fri Mar 12, 2021 8:55 pm
by Giovanni
Start is meant to be call-able when the device is in "started" state, not when it is in "active" state, you cannot call start when there is an operation in progress.
Serial does not have a defined "active" state and can be always restarted. Look at the assertions in the driver to see the valid states (or the HAL documentation, there are state diagrams there).
Giovanni