Equivalent of get device status in 'serial' to 'serialport'

4 ビュー (過去 30 日間)
Pin-Hao Cheng
Pin-Hao Cheng 2021 年 7 月 23 日
編集済み: dpb 2021 年 7 月 27 日
I am updating some legacy codes, namely changing 'serial' to 'serialport,' as 'serial' will be removed soon.
Part of the code are as follow:
if get(device,'Status') ~= 'open'
...
end
According to the serial properties documentation, "Status of serial port device connection, returned as closed or open."
I have been going through the serialport documentation, theres nothing similar to 'status' property.
I wonder how can we handle this check?
  2 件のコメント
dpb
dpb 2021 年 7 月 23 日
Why TMW thinks they have to completely revamp stuff is beyond me...this machine doesn't even have a serial port, but in one of the examples there's the following note: "When you are finished working with the scope, clear the serialport object."
So, I'm guessing it's up to your application to keep track -- perhaps exist() then...make it hard don't they... :(
Pin-Hao Cheng
Pin-Hao Cheng 2021 年 7 月 26 日
@dpb that works! Thanks lol

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

採用された回答

Pin-Hao Cheng
Pin-Hao Cheng 2021 年 7 月 26 日
Credit to @dpb
This is the code I used:
if exist('device','var') ~= 1
...
end
  1 件のコメント
dpb
dpb 2021 年 7 月 26 日
編集済み: dpb 2021 年 7 月 27 日
Kewl...glad the guess turned out to be a fruitful approach...

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSerial and USB Communication についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by