A class for using MU2.

Dependents:   EM_Mission FM_integration_copy FM_integration_off FM_integration

Files at this revision

API Documentation at this revision

Comitter:
ATKINZ117
Date:
Sat Jul 13 11:16:09 2013 +0000
Parent:
3:9f98138ed0c4
Commit message:
checked can send GPS data

Changed in this revision

MU2Class.cpp Show annotated file Show diff for this revision Revisions of this file
MU2Class.h Show annotated file Show diff for this revision Revisions of this file
--- a/MU2Class.cpp	Wed Jul 10 04:11:56 2013 +0000
+++ b/MU2Class.cpp	Sat Jul 13 11:16:09 2013 +0000
@@ -1,33 +1,29 @@
 #include "MU2Class.h"
 #include "mbed.h"
-//#include <stdlib.h>
 
 MU2Class::MU2Class(PinName tx,PinName rx){
     _tx=tx;
     _rx=rx;
 }
 
+/*MU2Class::MU2Class(PinName tx,PinName rx) : Serial(tx,rx){
+}*/
+
 uint8_t MU2Class::Store_Str(char data_str[], int index, char Message[]){
   uint8_t j=0;
   while(Message[j]!='\0'&&Message[j]!='^')  data_str[index++]=Message[j++];//store char in message into data_str and returns the last index.
   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);
+  //Serial pc(USBTX,USBRX);
   
   int i=4, str_length=0,send_index=0;
   char send_data[255];
   
   MyMu2.baud(19200);
-  pc.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 .
@@ -35,10 +31,11 @@
   while(Send_Message[str_length]!='\0'){
     send_data[send_index++]=Send_Message[str_length++];//storing the string we wanna send into the send_data until null terminater appers.
   }
-  send_data[send_index++]='\r';//insert carrige return at the last of send_data.
-  send_data[send_index++]='\n';
+  //send_data[send_index++]='\r';//insert carrige return at the last of send_data.
+  //send_data[send_index++]='\n';
+  send_data[send_index++]='\0';
 
-  //str_length-=2; //the code block below is for making data size proper.
+  str_length-=2; //the code block below is for making data size proper.
 
   for(i=4; i>2; i--){
     if(str_length%16<10){
@@ -60,48 +57,4 @@
     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
--- a/MU2Class.h	Wed Jul 10 04:11:56 2013 +0000
+++ b/MU2Class.h	Sat Jul 13 11:16:09 2013 +0000
@@ -11,6 +11,9 @@
 
 private:
     uint8_t Store_Str(char data_str[], int index, char Message[]);
+    //uint8_t Convert_Str(uint8_t data_str[], uint8_t index, uint32_t temp);
+    
+    
     /*uint8_t Store_Int(int data_int[], int index, int Message[]);*/
     PinName _tx; //tx pin name which connected to mbed
     PinName _rx; //rx pin name which connected to mbed