About serial communication and it correction

Status
Not open for further replies.

yousufsaleem

Junior Member level 1
Joined
Mar 7, 2012
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,414
***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
 

Try to check the value 's.BytesAvailable' at receiver side
then use 'fread'

type 'get(s)' (without semicolumn) in command window to view all the serial port structure parameters.
 

i am using matlab and a have check it on hyper terminal and its working good
 

Maybe your function call of fgets is executed before all bytes can come and maybe it is better to wait a little in an empty loop checking available bytes in the receiver buffer, how you think?
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…