フィルターのクリア

passing hex data to .NET

1 回表示 (過去 30 日間)
gujax
gujax 2012 年 9 月 27 日
Hi, This is quite basic but I am missing it.
An object in C# has to be passed a value, which is an operational code '0x20'.
This code is being sent to an instrument. I understand that the instrument can only decipher binary formatted numbers.
I am using .NET interface for accessing the C# code which is interfacing with the instrument. However, I am unable to set the instrument to the above value.
If the object is 'pkt' whose property is 'opcode' and the 'opcode' needs a value of 0x20 this is what I tried:
pkt.opcode=sscanf('0x20','%x'); This did not work.
Then I tried pkt.opcode=hex2dec('0x20') - not happy.
I tried pkt.opcode=20 - not happy.
Tried pkt.opcode=00100000 - again no results. (A light is supposed to switch on when this number is transferred).
The instrument manual says that the opcode value is 0x20 and the return type is uint32 (it has both read and write enabled).
This is now really confusing. Does it mean it needs an integer decimal value? If that is the case is my first step correct? Thanks

採用された回答

Walter Roberson
Walter Roberson 2012 年 9 月 27 日
編集済み: Walter Roberson 2012 年 9 月 27 日
Try
pkt.opcode = uint8(hex2dec('20'));

その他の回答 (1 件)

gujax
gujax 2012 年 9 月 28 日
Thanks, it worked!

カテゴリ

Help Center および File ExchangeCall Web Services from MATLAB Using HTTP についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by