フィルターのクリア

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

3 ビュー (過去 30 日間)
Abhishek Kekud
Abhishek Kekud 2017 年 10 月 27 日
編集済み: Abhishek Kekud 2017 年 10 月 27 日
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.

回答 (0 件)

カテゴリ

Help Center および File ExchangeRun on Target Hardware についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by