About serial communication and it correction

**At sending side****
s = serial('COM1');
set(s,'BaudRate',9600,'DataBits',8);
fopen(s);
fwrite(s,'we love you')
fclose(s)
**at receiving side****
s = serial('COM1');
set(s,'BaudRate',9600,'DataBits',8);
fopen(s);
x=fgets(s)
fclose(s)
*but at receiving only we is coming *
can you help me to get complete data at receiving side plz reply fast

답변 (1개)

Walter Roberson
Walter Roberson 2013년 2월 16일

0 개 추천

Change to
fprintf(s,'we love you\n')

댓글 수: 9

mohammad
mohammad 2013년 2월 17일
thanks bro but the result is same
I suggest you try with fgetl() instead of fgets()
mohammad
mohammad 2013년 2월 17일
i
its only giving this
I wonder if you are running into a "race condition", where the data is being sent before the receiver is ready. How are you coordinating the two programs?
Do you have a "null modem cable" between the two systems? A normal serial cable would not be suitable for directly connecting two computers together.
mohammad
mohammad 2013년 2월 17일
편집: mohammad 2013년 2월 17일
thanks brother for helping me
brother i am using transducer nrf 24l01 for communication between two computers
and i have alread checked serial communication on hyperlink or terminal
now i m totally confused i have tried many commands but the result is same
I seem to be having difficulty finding the specifications for that device.
I am finding discussions suggesting that at least some nRF2401 use TTL level communications; if that is what is being used you would have difficulty.
mohammad
mohammad 2013년 2월 18일
ok thanks i will further try and then tell you

이 질문은 마감되었습니다.

질문:

2013년 2월 16일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by