フィルターのクリア

Serial communication with arbitrary number of bytes

2 ビュー (過去 30 日間)
alex pabouctsidis
alex pabouctsidis 2012 年 12 月 8 日
Hello,
I'm trying to receive data from a sensor in real time. the problem is the communication protocol is entirely binary lengths varying from 3 to 20+ bytes (in one frame).
I tried two use methods:
converting my hex value into text (equivalent ascii) and sending the string. the problem is 00 is represented as the nul char and cuts my string (sending everything before the first 00).
I then tried to use the binary fwrite command, but i'm limited to 8,16,32,64 bits where as i need an arbitrary number (such as 24).
I also tried cutting my data into multiple (8bit/16bit/32bit) segments and sending them one after another, but that also doesn't work. it needs to all go at the same time.
As an example, i'd like to send '0x201000' and '0x2005503C280000' in one go.
Does anyone have any idea on how to tackle this problem?
Regards, Alex

採用された回答

Walter Roberson
Walter Roberson 2012 年 12 月 8 日
fwrite() can take arrays, each element of which is uint8()

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by