Creating a serialport as public variable

조회 수: 4 (최근 30일)
AaHi
AaHi 2021년 11월 17일
편집: Antonio Hortal 2021년 11월 17일
Hello everybody,
I've got a problem defining a serialport as a public variable. Doing that I get the following error message:
I have defined the properties as following:
properties (Access = public)
TCPcont tcpclient % Description
TCPprog tcpclient % Description
COM_con serialport % Serialport for USB Connection
end
Does anyone have an idea why it's working for the TCP-Client but not for the serialport?
Thank you so much, all the best
Aaron

답변 (1개)

Antonio Hortal
Antonio Hortal 2021년 11월 17일
편집: Antonio Hortal 2021년 11월 17일
The issue is that your code is trying to validate the properties requiring them to be of the class next to them. When your app is created, Matlab is trying to initialize these properties as tcpclient.empty() and serialport.empty(). More on property validation in this article
While tcpclient is actually a class (and therefore tcpclient.empty() does exist as a method), serialport is not. The command serialport is a function whose output is an element of the class internal.Serialport. What you can do is replace the 'serialport' by 'internal.Serialport'
Hope that helped :)

카테고리

Help CenterFile Exchange에서 Serial and USB Communication에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by