Problem with the odt notation of "configureTerminator" for serialport

7 visualizzazioni (ultimi 30 giorni)
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)

Risposte (2)

Sarthak
Sarthak il 16 Apr 2024
Modificato: Sarthak il 22 Apr 2024
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 il 21 Apr 2024
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 Commenti
Sarthak
Sarthak il 22 Apr 2024
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!

Accedi per commentare.

Prodotti


Release

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by