フィルターのクリア

fwrite int64 not supported

3 ビュー (過去 30 日間)
Andrea Bettati
Andrea Bettati 2019 年 6 月 28 日
回答済み: Guillaume 2019 年 6 月 28 日
Hi to you all,
I'm using matlab to exchange data with a cortex M4 board.
In my embedded c code I enabled the usb vcom and I am able to write and read using
fwrite()
fread()
Everything is fine if I use 'int32' as precision, but 'int64' is not supported.
Unfortunately I need to send to my board some int64 parameters and I wonder which is the best way of doind this.
Any hints?

回答 (1 件)

Guillaume
Guillaume 2019 年 6 月 28 日
Well, a 64 bit integer can be easily split into two 32-bit halves. You'd need to know the endianess of your environment but it's going to be either:
%input:
% val64: a uint64 integer scalar
val64as32 = typecast(val64, 'uint32');
fwrite(something, val64as32, 'uint32')
or
%input:
% val64: a uint64 integer scalar
val64as32 = fliplr(typecast(val64, 'uint32'));
fwrite(something, val64as32, 'uint32')

カテゴリ

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

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by