Problem with the odt notation of "configureTerminator" for serialport

조회 수: 6 (최근 30일)
Gianluigi
Gianluigi 2024년 4월 8일
댓글: Gianluigi 2024년 4월 22일
Hi,
I do this with serial port:
sss=serialport('com1',9600)
Then, I try to configure the terminator with the dot notation:
sss.configureTerminator = 'CR'
I receive this error:
Assignment not supported because the result of method 'configureTerminator' is a temporary value.
If I do this:
>> configureTerminator(sss,'cr')
that works.
Why? I wrong something in the sintax?
All the other commnads I used like flush, write, writeline, read, etc have not shown problems with dot notation.
Tyhank you, Gianluigi
PS: This is my license:
-----------------------------------------------------------------------------------------------------
MATLAB Version: 24.1.0.2461801 (R2024a) Prerelease Update 1
MATLAB License Number: 566431
Operating System: Microsoft Windows 10 Pro Version 10.0 (Build 19045)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB Version 24.1 (R2024a)
Simulink Version 24.1 (R2024a)
Curve Fitting Toolbox Version 24.1 (R2024a)
Data Acquisition Toolbox Version 24.1 (R2024a)
Database Toolbox Version 24.1 (R2024a)
Instrument Control Toolbox Version 24.1 (R2024a)
Optimization Toolbox Version 24.1 (R2024a)
Parallel Computing Toolbox Version 24.1 (R2024a)
Simscape Version 24.1 (R2024a)
Simscape Electrical Version 24.1 (R2024a)
Symbolic Math Toolbox Version 24.1 (R2024a)
System Composer Version 24.1 (R2024a)

답변 (2개)

Sarthak
Sarthak 2024년 4월 16일
편집: Sarthak 2024년 4월 22일
Hello Gianluigi,
From what I could understand from the documentation of 'serialport', I can see that 'configureTerminator' is an object function and not an object property which could be accessed using the dot notation through assignment. The 'configureTerminator' function would set the terminator of the device that is passed to it i.e. the serialport device.
The error also states that 'configureTerminator' is a method and not a property. That is why you are unable to configure the terminator with the dot notation.
Please refer to the following documentation for more information on 'serialport' and 'configureTerminator'.
Hope this helps!

Gianluigi
Gianluigi 2024년 4월 21일
Hi Sarthak,
sorry for the delay in my answer.
The help for any of those function is for a conventional use, not a dot notation.
However I have a news: the dot notation for configurterminator is working.
My error was to assign the terminator this way:
sss.configureTerminator = 'CR'
But the correct sintax is:
sss.configureTerminator( 'CR' )
Do you agree?
thank you gianluigi
  댓글 수: 2
Sarthak
Sarthak 2024년 4월 22일
Hi Gianluigi,
Yes, as I stated configureTerminator is an object function, which means you can call it on the object as the following and the dot notation will work
sss.configureTerminator('CR');
or use it conventionally like in the documentation shared as
configureTerminator(sss, 'CR');
Apologies for any confusions.
Cheers!
Gianluigi
Gianluigi 2024년 4월 22일
No probkem,
thank you
gianluigi

댓글을 달려면 로그인하십시오.

카테고리

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

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by