Taking data received from serial port as single element
Ältere Kommentare anzeigen
Hi all,
i am receiving the ASCII values of some data say (*12) through serial port, then after that i am eliminating first character i.e(*)Then i am converting this ASCII values to Decimal values using 'char'. Later i need to process remaining data '12' as single element for giving it as an input to some other function. But problem is my function is taking '1' and '2' as separate values instead of one single value '12'. please give some suggestions in a way such that i should give '12' as input to my function.
Sample Code
ser1 = serial('COM27', 'BaudRate', 9600,'Terminator','*');
fopen(ser1);
while(1)
input3=fread(ser1);
input1=input3(2:end)
input2=char(input1)
input3=input2
output=input3+1;
end
If input is *12 expected output is 13. But i am getting output as 2(1+1),3(2+1)
Thanks in advance
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!