A class for using MU2.

Dependents:   EM_Mission FM_integration_copy FM_integration_off FM_integration

Revision:
2:2297b491e452
Parent:
1:c60752b4acb9
Child:
4:a7d413a2889d
--- a/MU2Class.cpp	Sat Jul 06 06:19:08 2013 +0000
+++ b/MU2Class.cpp	Sat Jul 06 07:29:39 2013 +0000
@@ -1,5 +1,6 @@
 #include "MU2Class.h"
 #include "mbed.h"
+//#include <stdlib.h>
 
 MU2Class::MU2Class(PinName tx,PinName rx){
     _tx=tx;
@@ -12,6 +13,12 @@
   return index;
 }
 
+/*uint8_t MU2Class::Store_Int(int data_int[], int index, int Message[]){
+  uint8_t j=0;
+  while(Message[j]!='\0'&&Message[j]!='^')  data_int[index++]=Message[j++];//store char in message into data_str and returns the last index.
+  return index;
+}*/
+
 void MU2Class::send(char Send_Message[]){
   Serial MyMu2(_tx,_rx);
   Serial pc(USBTX,USBRX);
@@ -48,8 +55,53 @@
     }
     str_length/=16;
   }
+  MyMu2.printf(send_data);
+  /*for(int j=0;j<=send_index;j++){
+    MyMu2.putc(send_data[j]);
+    pc.putc(send_data[j]); //for debugging.Comment out when U use this in practice.
+  }*/
+}
+
+/*void MU2Class::send(int Send_Message[]){
+  Serial MyMu2(_tx,_rx);
+  Serial pc(USBTX,USBRX);
+  
+  int i=4, int_length=0,send_index=0;
+  char send_data[255];
+  
+  MyMu2.baud(19200);
+  pc.baud(19200);
+
+  send_index=0;//initializing the variant.
+  send_index=Store_Str(send_data, send_index, "@DT00^");//this variant is the last index of the string.The reason why char "^" here is that for the case of the data size 10,20,A0 or something . Store_Str copies the string of its last variant into its first variant .
+
+  while(Send_Message[int_length]!='\0'){
+    //send_data[send_index++]=Send_Message[int_length++];//storing the string we wanna send into the send_data until null terminater appers.
+    //itoa(Send_Message[int_length++],send_data[send_index++],10);
+    
+  }
+  send_data[send_index++]='\r';//insert carrige return at the last of send_data.
+  send_data[send_index++]='\n';
+
+  //str_length-=2; //the code block below is for making data size proper.
+
+  for(i=4; i>2; i--){
+    if(int_length%16<10){
+      send_data[i]='0'+int_length%16;
+    }else{
+      switch(int_length%16){
+        case 10:send_data[i]='A'; break;
+        case 11:send_data[i]='B'; break;
+        case 12:send_data[i]='C'; break;
+        case 13:send_data[i]='D'; break;
+        case 14:send_data[i]='E'; break;
+        case 15:send_data[i]='F'; break;
+      }
+    }
+    int_length/=16;
+  }
   for(int j=0;j<=send_index;j++){
     MyMu2.putc(send_data[j]);
     pc.putc(send_data[j]); //for debugging.Comment out when U use this in practice.
   }
-}
\ No newline at end of file
+}*/
\ No newline at end of file