Serial Device: usart speed change "on the fly"

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: utzig, lbednarz, tfAteba, barthess, RoccoMarco

ucasano
Posts: 57
Joined: Mon Aug 06, 2012 1:05 pm
Has thanked: 1 time

Serial Device: usart speed change "on the fly"

Postby ucasano » Mon Dec 10, 2012 7:45 pm

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

User avatar
Giovanni
Site Admin
Posts: 13529
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 861 times
Been thanked: 743 times
Contact:

Re: Serial Device: usart speed change "on the fly"

Postby Giovanni » Mon Dec 10, 2012 7:47 pm

Hi,

You don't need to stop, just call sdStart() again to set new parameters, of course you need multiple configuration structures.

Giovanni

ucasano
Posts: 57
Joined: Mon Aug 06, 2012 1:05 pm
Has thanked: 1 time

Re: Serial Device: usart speed change "on the fly"

Postby ucasano » Mon Dec 10, 2012 8:00 pm

Alright, I will do so!
Thanks.
-g

kalevik
Posts: 3
Joined: Wed Dec 21, 2011 1:15 pm
Location: Finland

Re: Serial Device: usart speed change "on the fly"

Postby kalevik » Wed Feb 06, 2013 10:39 pm

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 :shock:

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

User avatar
Giovanni
Site Admin
Posts: 13529
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 861 times
Been thanked: 743 times
Contact:

Re: Serial Device: usart speed change "on the fly"

Postby Giovanni » Wed Feb 06, 2013 10:47 pm

You can have one structure and change it or multiple constant structures.

Giovanni

kalevik
Posts: 3
Joined: Wed Dec 21, 2011 1:15 pm
Location: Finland

Re: Serial Device: usart speed change "on the fly"

Postby kalevik » Thu Feb 07, 2013 6:29 am

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

rew
Posts: 360
Joined: Sat Jul 19, 2014 12:59 pm
Been thanked: 12 times

Re: Serial Device: usart speed change "on the fly"

Postby rew » Fri Mar 12, 2021 6:55 pm

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".

User avatar
Giovanni
Site Admin
Posts: 13529
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 861 times
Been thanked: 743 times
Contact:

Re: Serial Device: usart speed change "on the fly"

Postby Giovanni » Fri Mar 12, 2021 8:55 pm

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


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 6 guests