lundi 22 décembre 2014

Unable to check received value on serial port in matlab


I want to check if I receive a dot ('.') on serial port in Matlab. For this I run for loop for 10 times in which I check if I got '.' on serial port then display "A dot is received" otherwise display whatever is received. But on receiving '.' on serial port it is not displaying "A dot is receibed". here is my code:-



s=serial('COM5', 'BaudRate',9600);%, 'DataBits',8, 'Terminator','');
fopen(s);
disp('Port succefully Opened');
count=0;
checkdot = '.';
for x = 1:10

recv= fscanf(s);
z = char(recv);
if (z== '.')
disp('A dot is received');

else
disp(z);
end

end
fclose(s);


And here is my output on command window:-



>> Serialcomm
Port succefully Opened
.

.

.

.

.

.

.

.

.

.


So, please tell me where is the mistake.





Aucun commentaire:

Enregistrer un commentaire