Borrar filtros
Borrar filtros

How do you pass port number parameter data to Simulink Serial blocks

2 visualizaciones (últimos 30 días)
Rick Policy
Rick Policy el 25 de Oct. de 2022
Respondida: Sachin Lodhi el 30 de Ag. de 2023
I have a need to be able to set the communication port number in my serial blocks prior to running the model (e.g. via a test harness or constant string block). The goal is to have the serial ports not "hard coded" in the model just in case Win 10 reassigns the USB device to another com port.
It seems like the "Port" parameter is limited to the drop down list. Does anyone know of a mechanism to allow for external Port setting?

Respuestas (1)

Sachin Lodhi
Sachin Lodhi el 30 de Ag. de 2023
As per my understanding, you would like to set the communication port number in your serial blocks dynamically. For this, I recommend you use the set_param” function. To set communication port in the “Serial Configuration” block, please use the following command(use your port number instead of COM5)
set_param(gcb, "Port", "COM5");
I suggest you refer to the following documentation to know more about “set_param()” function:
The parameter name to be used in the “set_param()” function is “Port”. I suggest you refer to the following documentation for more reference:
I hope this helps you in setting the port number as an external parameter.

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by