serial port - What does this matlab code do and how should i implement it -


i bought diy project has coding can explain waht code do. have knowledge of c , c++ haven't worked on matlab before. project read sms using @ commands , processing through avr kit since unaware of matlab programming need understand particular code , how implement in matlab getting error saying(undefined bluetooth)

while(1)     flag1=0;     flag2=0;     i=0;     j=1;     count=0;     fwrite(bluetooth,65)     fwrite(bluetooth,84)     fwrite(bluetooth,43)     fwrite(bluetooth,67)     fwrite(bluetooth,77)     fwrite(bluetooth,71)     fwrite(bluetooth,76)     fwrite(bluetooth,61)     fwrite(bluetooth,34)     fwrite(bluetooth,82)     fwrite(bluetooth,69)     fwrite(bluetooth,67)     fwrite(bluetooth,32)     fwrite(bluetooth,85)     fwrite(bluetooth,78)     fwrite(bluetooth,82)     fwrite(bluetooth,69)     fwrite(bluetooth,65)     fwrite(bluetooth,68)     fwrite(bluetooth,34)     fwrite(bluetooth,13)     a=fread(bluetooth,1)     if(a==13)         a=fread(bluetooth,1)         if(a==10)             28             while(flag1==0)                 a=fread(bluetooth,1)                 if(a==79)                     count=count+1                 end                 if(a==75)                     count=count+1                 end                 if(a==10)                     flag1=1                 end             end         end     end     if(count~=2)         while(flag2==0)             a=fread(bluetooth,1)             i=i+1;             if(j>0)                 fopen(pc_uc)                 j=j-1;             end             fwrite(pc_uc,a)             if(a==13)                 flag2=1             end         end         i=1:7             a=fread(bluetooth,1)         end         fclose(bluetooth)         fclose(pc_uc)         fopen(bluetooth)     end end 

it's not pretty code, here's does, far can tell:

  1. send sms command:

    at+cmgl="rec unread" 
  2. check carriage return, <cr> (ascii code 13)

  3. check line feed, <lf> (ascii code 10)
  4. read in characters until reads in ok or <lf>.
  5. if did not receive ok, copy data pc_us (no idea is) until hits <cr> in bluetooth, read few bytes bluetooth (clearing buffer?), close , r-open bluetooth.

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -