Titech Cansat / MU2

Dependents:   EM_ver1 template FM_ver3_for_ARLISS FM_ver3_for_test

Files at this revision

API Documentation at this revision

Comitter:
Nerosho
Date:
Tue Jul 30 11:08:44 2019 +0000
Parent:
0:48505968b10e
Commit message:
ver2_2;

Changed in this revision

MU2.cpp Show annotated file Show diff for this revision Revisions of this file
MU2.h Show annotated file Show diff for this revision Revisions of this file
diff -r 48505968b10e -r dcb1eee964d5 MU2.cpp
--- a/MU2.cpp	Tue Jul 16 12:05:44 2019 +0000
+++ b/MU2.cpp	Tue Jul 30 11:08:44 2019 +0000
@@ -1,26 +1,23 @@
 #include "MU2.h"
-#include "mbed.h"
+
 #include "stdint.h"
 #include <string>
 #include <sstream>
 
-MU2::MU2(PinName tx,PinName rx) //MU2クラスのMU2という関数(コンストラクタ)の定義
+MU2::MU2(PinName tx,PinName rx):MuPort(tx,rx)//MU2クラスのMU2という関数(コンストラクタ)の定義
 {
+    MuPort.baud(19200);
     _tx=tx;
     _rx=rx;
 }
 
-/*MU2::MU2(PinName tx,PinName rx) : Serial(tx,rx){
-}*/
-
 
 void MU2::send(char Message[])
 {
-    Serial MuPort(_tx,_rx);
-    Serial pc(USBTX,USBRX);
+
 
-    MuPort.baud(19200);
-    pc.baud(9600);
+    //MuPort.baud(9600);//19200?
+    //pc.baud(19200);//9600
 
     int index=0;
     std::string send_data;
@@ -41,7 +38,8 @@
         std::stringstream ss;  //stiringstreamクラスのstd::hexマニュピレータを用いて変換。<sstream>のincludeが必要。
         ss << std::hex << index ; //indexを16進数に変換
         std::string str_ss = ss.str();
-        send_data += '0'+str_ss;
+        send_data += '0';
+        send_data += str_ss;
     } else {
         std::stringstream ss;  //stiringstreamクラスのstd::hexマニュピレータを用いて変換。<sstream>のincludeが必要。
         ss << std::hex << index ; //indexを16進数に変換
@@ -55,13 +53,14 @@
     }
 
 
-    pc.printf("%s\n",send_data.c_str());
+    //pc.printf("%s\n",send_data.c_str());
+    //pc.printf("%s\n",Message);
 
 
     MuPort.printf("%s", send_data.c_str());//.c_str()でstring型のstrを変換
 
 
-    for(int i=0; i<2; i++) {
-        MuPort.putc(last_data[i]);
+    for(int l=0; l<2; l++) {
+        MuPort.putc(last_data[l]);
     }
 }
\ No newline at end of file
diff -r 48505968b10e -r dcb1eee964d5 MU2.h
--- a/MU2.h	Tue Jul 16 12:05:44 2019 +0000
+++ b/MU2.h	Tue Jul 30 11:08:44 2019 +0000
@@ -7,7 +7,7 @@
 {
 
 private:
-
+Serial MuPort;
     PinName _tx; //tx pin name which connected to mbed
     PinName _rx; //rx pin name which connected to mbed