For Hepta-Sat Lite

Revision:
4:ede5c519e238
Parent:
3:c3e667ee70f1
Child:
5:c441a88f6952
diff -r c3e667ee70f1 -r ede5c519e238 HeptaXbee.cpp
--- a/HeptaXbee.cpp	Sat Aug 05 14:21:01 2017 +0000
+++ b/HeptaXbee.cpp	Wed Aug 23 06:18:34 2017 +0000
@@ -6,137 +6,245 @@
 {
     rcmd = 0;
     cmdflag = 0;
+    //xbee.baud(115200);
 }
 
-void HeptaXbee::xbee_recieve(int *xrcmd, int *xcmdflag) {
+void HeptaXbee::xbee_recieve(int *xrcmd, int *xcmdflag)
+{
     xbee.attach(this,&HeptaXbee::commandget,Serial::RxIrq);
     //xbee.printf("ssXbeedata= %d,%d",HeptaXbee::rcmd,HeptaXbee::cmdflag);
     *xrcmd = HeptaXbee::rcmd;
     *xcmdflag = HeptaXbee::cmdflag;
 }
 
-void HeptaXbee::initialize(){
+void HeptaXbee::initialize()
+{
     HeptaXbee::rcmd = 0;
     HeptaXbee::cmdflag = 0;
 }
 
-void HeptaXbee::commandget(){
+void HeptaXbee::commandget()
+{
     HeptaXbee::rcmd=xbee.getc();
     HeptaXbee::cmdflag = 1;
     //xbee.printf("Xbeedata= %d,%d",rcmd,cmdflag);
 }
 
 void HeptaXbee::xbee_transmit(char* output_data,size_t output_n,
-                        char data1[],char data2[],char data3[],char data4[],char data5[],char data6[],char data7[],char data8[],char data9[],char data10[],char data11[],char data12[],char data13[],char data14[], 
-                            int n1,int n2,int n3,int n4,int n5,int n6,int n7,int n8,int n9,int n10,int n11,int n12,int n13,int n14,int data_num)
+                              char data1[],char data2[],char data3[],char data4[],char data5[],char data6[],char data7[],char data8[],char data9[],char data10[],char data11[],char data12[],char data13[],char data14[],
+                              int n1,int n2,int n3,int n4,int n5,int n6,int n7,int n8,int n9,int n10,int n11,int n12,int n13,int n14,int data_num)
 {
     int N=0,i=0,ii;
-    if(data_num>=1){
-        for(i = 0; i <= n1-1; i++){
-        output_data[N+i] = data1[i];
+    if(data_num>=1) {
+        for(i = 0; i <= n1-1; i++) {
+            output_data[N+i] = data1[i];
         }
         N=i;
     }
-    
-    if(data_num>=2){
-        for(i = 0; i <= n2-1; i++){
-        output_data[N+i] = data2[i];
+
+    if(data_num>=2) {
+        for(i = 0; i <= n2-1; i++) {
+            output_data[N+i] = data2[i];
         }
         N=N+i;
     }
-    if(data_num>=3){
-        for(i = 0; i <= n3-1; i++){
-        output_data[N+i] = data3[i];
+    if(data_num>=3) {
+        for(i = 0; i <= n3-1; i++) {
+            output_data[N+i] = data3[i];
+        }
+        N=N+i;
+    }
+    if(data_num>=4) {
+        for(i = 0; i <= n4-1; i++) {
+            output_data[N+i] = data4[i];
+        }
+        N=N+i;
+    }
+    if(data_num>=5) {
+        for(i = 0; i <= n5-1; i++) {
+            output_data[N+i] = data5[i];
         }
         N=N+i;
     }
-    if(data_num>=4){
-        for(i = 0; i <= n4-1; i++){
-        output_data[N+i] = data4[i];
+    if(data_num>=6) {
+        for(i = 0; i <= n6-1; i++) {
+            output_data[N+i] = data6[i];
         }
         N=N+i;
     }
-    if(data_num>=5){
-        for(i = 0; i <= n5-1; i++){
-        output_data[N+i] = data5[i];
+    if(data_num>=7) {
+        for(i = 0; i <= n7-1; i++) {
+            output_data[N+i] = data7[i];
+        }
+        N=N+i;
+    }
+    if(data_num>=8) {
+        for(i = 0; i <= n8-1; i++) {
+            output_data[N+i] = data8[i];
         }
         N=N+i;
     }
-    if(data_num>=6){
-        for(i = 0; i <= n6-1; i++){
-        output_data[N+i] = data6[i];
+    if(data_num>=9) {
+        for(i = 0; i <= n9-1; i++) {
+            output_data[N+i] = data9[i];
+        }
+        N=N+i;
+    }
+    if(data_num>=10) {
+        for(i = 0; i <= n10-1; i++) {
+            output_data[N+i] = data10[i];
         }
         N=N+i;
     }
-    if(data_num>=7){
-        for(i = 0; i <= n7-1; i++){
-        output_data[N+i] = data7[i];
+    if(data_num>=11) {
+        for(i = 0; i <= n11-1; i++) {
+            output_data[N+i] = data11[i];
         }
         N=N+i;
     }
-    if(data_num>=8){
-        for(i = 0; i <= n8-1; i++){
-        output_data[N+i] = data8[i];
+    if(data_num>=12) {
+        for(i = 0; i <= n12-1; i++) {
+            output_data[N+i] = data12[i];
+        }
+        N=N+i;
+    }
+    if(data_num>=13) {
+        for(i = 0; i <= n13-1; i++) {
+            output_data[N+i] = data13[i];
         }
         N=N+i;
     }
-    if(data_num>=9){
-        for(i = 0; i <= n9-1; i++){
-        output_data[N+i] = data9[i];
+    if(data_num>=14) {
+        for(i = 0; i <= n14-1; i++) {
+            output_data[N+i] = data14[i];
         }
-        N=N+i;
+    }
+    for(ii=0; ii<output_n; ii++) {
+        xbee.putc(output_data[ii]);
+
     }
-    if(data_num>=10){
-        for(i = 0; i <= n10-1; i++){
-        output_data[N+i] = data10[i];
+    xbee.printf("\n");
+}
+void HeptaXbee::puts( char *s )
+{
+    while ( char c    = *s++ )
+        xbee.putc( c );
+}
+void HeptaXbee::printf( char *format, ... )
+{
+    char        s[ 100 ];
+    va_list        args;
+
+    va_start( args, format );
+    vsnprintf( s, 100, format, args );
+    va_end( args );
+
+    xbee.puts( s );
+}
+char HeptaXbee::getc()
+{
+    char character;
+    character = xbee.getc();
+    return character;
+}
+
+char HeptaXbee::putc(char cc)
+{
+    xbee.putc(cc);
+}
+/*
+void HeptaXbee::xbee_transmit_SD(char* output_data,size_t output_n,
+                                 char data1[],char data2[],char data3[],char data4[],char data5[],char data6[],char data7[],char data8[],char data9[],char data10[],char data11[],char data12[],char data13[],char data14[],
+                                 int n1,int n2,int n3,int n4,int n5,int n6,int n7,int n8,int n9,int n10,int n11,int n12,int n13,int n14,int data_num)
+{
+    int N=0,i=0,ii;
+    if(data_num>=1) {
+        for(i = 0; i <= n1-1; i++) {
+            output_data[N+i] = data1[i];
+        }
+        N=i;
+    }
+
+    if(data_num>=2) {
+        for(i = 0; i <= n2-1; i++) {
+            output_data[N+i] = data2[i];
         }
         N=N+i;
     }
-    if(data_num>=11){
-        for(i = 0; i <= n11-1; i++){
-        output_data[N+i] = data11[i];
-        }
-        N=N+i;
-    }
-    if(data_num>=12){
-        for(i = 0; i <= n12-1; i++){
-        output_data[N+i] = data12[i];
-        }
-        N=N+i;
-    }
-    if(data_num>=13){
-        for(i = 0; i <= n13-1; i++){
-        output_data[N+i] = data13[i];
+    if(data_num>=3) {
+        for(i = 0; i <= n3-1; i++) {
+            output_data[N+i] = data3[i];
         }
         N=N+i;
     }
-    if(data_num>=14){
-        for(i = 0; i <= n14-1; i++){
-        output_data[N+i] = data14[i];
+    if(data_num>=4) {
+        for(i = 0; i <= n4-1; i++) {
+            output_data[N+i] = data4[i];
+        }
+        N=N+i;
+    }
+    if(data_num>=5) {
+        for(i = 0; i <= n5-1; i++) {
+            output_data[N+i] = data5[i];
+        }
+        N=N+i;
+    }
+    if(data_num>=6) {
+        for(i = 0; i <= n6-1; i++) {
+            output_data[N+i] = data6[i];
+        }
+        N=N+i;
+    }
+    if(data_num>=7) {
+        for(i = 0; i <= n7-1; i++) {
+            output_data[N+i] = data7[i];
+        }
+        N=N+i;
+    }
+    if(data_num>=8) {
+        for(i = 0; i <= n8-1; i++) {
+            output_data[N+i] = data8[i];
+        }
+        N=N+i;
+    }
+    if(data_num>=9) {
+        for(i = 0; i <= n9-1; i++) {
+            output_data[N+i] = data9[i];
+        }
+        N=N+i;
+    }
+    if(data_num>=10) {
+        for(i = 0; i <= n10-1; i++) {
+            output_data[N+i] = data10[i];
+        }
+        N=N+i;
+    }
+    if(data_num>=11) {
+        for(i = 0; i <= n11-1; i++) {
+            output_data[N+i] = data11[i];
+        }
+        N=N+i;
+    }
+    if(data_num>=12) {
+        for(i = 0; i <= n12-1; i++) {
+            output_data[N+i] = data12[i];
+        }
+        N=N+i;
+    }
+    if(data_num>=13) {
+        for(i = 0; i <= n13-1; i++) {
+            output_data[N+i] = data13[i];
+        }
+        N=N+i;
+    }
+    if(data_num>=14) {
+        for(i = 0; i <= n14-1; i++) {
+            output_data[N+i] = data14[i];
         }
     }
-    for(ii=0;ii<output_n;ii++){
-        xbee.putc(output_data[ii]);  
-        
+    for(ii=0; ii<output_n; ii++) {
+        xbee.putc(output_data[ii]);
     }
-    xbee.printf("\n");   
-}
-void HeptaXbee::puts( char *s ) {
-        while ( char c    = *s++ )
-            xbee.putc( c );
+    xbee.printf("\n");
 }
-void HeptaXbee::printf( char *format, ... ) {
-        char        s[ 32 ];
-        va_list        args;
-
-        va_start( args, format );
-        vsnprintf( s, 32, format, args );
-        va_end( args );
-
-        xbee.puts( s );
-}
-char HeptaXbee::getc(){
-    char character;
-    character = xbee.getc();
-    return character;
-    }
\ No newline at end of file
+*/
\ No newline at end of file