How to change baud rate of CLI.

How do you change the baud rate of serial CLI. I see the function “BSP_CLI_COM_PORT” to change com port. But where is the ability to change baud rate?

On method would be to edit src\bsp\platforms\bsp_sys.h. Look for BSP_BAUD_RATE. Edit the definition of this constant and rebuild the bsp.

The comment states - BSP_BAUD_RATE determines the baud rate that will be used for the configuration
dialog if APP_USE_NVRAM is 0, or if NVRAM is uninitialized. I believe this is the baud rate used for dialog allowing user to change network settings just after initial boot which in my case is on com2. I am using the CLI api interface on com4 which is the FIM port. I need to know how to change the baudrate for the CLI api. Does BSP_BAUD_RATE also change CLI baud rate. If so not much flexibility.

The baud rate could be set by modifying the file NETOS\src\bsp\cli\src\cli_eng.c. I added code to set baud rate using the tcgetattr, cfsetospeed and tcsetattr function calls. Although this worked it also changed this file for all projects which is not what I wanted to do. I was hoping for a solution that was specific to a particular platform at least. Still looking for better solution.

Hi,

You may find that copying the updated “cli_eng.c” into your project but leaving the one in NETOS\src\bsp\cli\src will do what you want.

In theorey the linker will find the routines in your project and link them in preference to the standr ones in the library. I am not 100% sure that this will work but it should be woth a try.

rather go for this.

#ifdef MY_CUSTOMIZED_BAUD_RATE
struct termios tios;
tcgetattr(serial_fd, &tios);
cfsetospeed(&tios, MY_CUSTOMIZED_BAUD_RATE);
tcsetattr(serial_fd, TCSANOW, &tios);
#endif

then define it whereever you want. :slight_smile: :slight_smile: