フィルターのクリア

How to queue CAN messages for transmission?

3 ビュー (過去 30 日間)
Chris Mounce
Chris Mounce 2020 年 3 月 11 日
コメント済み: Chris Mounce 2022 年 6 月 9 日
Hello,
I have a number of CAN messages that I'm looking to add to a queue for transmission. When trying to do this with either of the two queue blocks, I get errors about either the output of the queue not being compatible with the transmit block, or (with the other queue block option) the CAN message being the wrong data type, since it's a CAN message and not a basic datatype. It seems like setting up a CAN message FIFO in Simulink should be fairly straightforward, what am I missing? Thanks!
  2 件のコメント
Adrian Izbicki
Adrian Izbicki 2022 年 6 月 9 日
Did you find a solution for this?
Chris Mounce
Chris Mounce 2022 年 6 月 9 日
I eventually used an S function with a third party CAN solution that was able to queue up the messages.
However, there is a solution with newer versions of MATLAB that allow for data store indexing. As you can use an indexed data store as a rotating buffer.
It involves 5 steps:
  1. Create a ReadIndex datastore starting at value 1
  2. Create a WriteIndex datastore starting at value 1
  3. Create a MessageBuffer datastore of whatever size you want
  4. Write a message to MessageBuffer at index WriteIndex and then increment WriteIndex. If greater than the size of your MessageBuffer, wrap to 1
  5. Whenever WriteIndex != ReadIndex, read the data in MessageBuffer at index ReadIndex and then increment ReadIndex. If greater than the size of your MessageBuffer, wrap to 1.
Keep in mind that if these writes or reads are called via an interrupt, you could have problems with data integrity.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by