Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Noob need help reading rs232 via matlab

Status
Not open for further replies.

vptran84

Electrical
Joined
May 5, 2006
Messages
1
Location
US
Hi,

Here is what I am trying to do.

On one computer i open matlab and run the program (posted below) to open the serial port and read data. On the other computer i open hyperterminal and send data. If the data i receive in matlab is the same as the data i sent then you know the matlab program is working correctly.

So I am trying to read data from the rs232 via matlab, but i am struggling g
reatly.

here is my code:

s = serial('com1');
s.InputBufferSize = 10;
fopen(s);
fid = fopen('C\out.txt', 'w')
a = fread(s,8);
fwrite(fid,char(a));
fclose(s);
fclose(fid);
Results:

fid =

3

Warning: The specified amount of data was not returned within the Timeout period.

I don't really know what is wrong.

Please if anyone could, I would greatly appreciated. This is taking me so much time, and I am on the brink of madness. thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top