Why doesn't it work?

5 vues (au cours des 30 derniers jours)
Bence Salanki
Bence Salanki le 28 Sep 2015
Commenté : Bence Salanki le 29 Sep 2015
Hi,
I'm trying to create a serial communication between two of my USB ports with two USB-serial adapter and a cross-over cable. I'm using the following code:
input = serial('COM3');
output = serial('COM4');
fwrite(input, 'hello');
fgets(output);
After fgets() this is what I get:
Warning: A timeout occurred before the Terminator was reached.
It seems like there is no stop bit after the characters and I don't know what to do with it. Please help me.
Thanks.

Réponses (1)

Walter Roberson
Walter Roberson le 29 Sep 2015
fwrite(input, sprintf('%s\n', 'hello'));
or
fprintf(input, '%s\n', 'hello');
or
fprintf(input, 'hello'); %special case, adds \n automatically
  1 commentaire
Bence Salanki
Bence Salanki le 29 Sep 2015
Thank you!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Thermal Analysis dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by