How to use variables as input for Data size(N) of Raspberry Pi I2C Master Read block?

2 vues (au cours des 30 derniers jours)
Hello, I am reading characters of more than 32 bytes from a slave(Arduino UNO/nano in my case). Since the slave can send only 32 bytes of data at one instance, the data is received as different packets. The raspberry pi acts as master and it mentions the packet number to the slave. Since the last may not have 32 bytes of data, the data size should be varying as per the remaining bytes of data to be received. The above functionality is achieved using the mscript as per below script.
no_bytes = (data_length - (packet_number * 32));
% Check the size of data to be received
if (no_bytes > 32)
receive_data = char(read(US_sensor, 32));
else
receive_data = char(read(US_sensor, no_bytes));
end
I want to achieve the same operation in Simulink using I2C Master read block. How can I set Data size as an variable which will be updated as the simulink runs in realtime.

Réponses (0)

Catégories

En savoir plus sur Run on Target Hardware dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by