Subversion Repositories Projects

Rev

Rev 130 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 130 Rev 140
Line 2... Line 2...
2
 
2
 
3
 
3
 
4
unsigned char TxBuffer[150];
4
unsigned char TxBuffer[150];
5
unsigned char _TxBuffer[150];
5
unsigned char _TxBuffer[150];
6
 
6
 
7
char RxBuffer[150];
7
unsigned char RxBuffer[150];
8
char PrintableRxBuffer[150];
8
char PrintableRxBuffer[150];
9
 
9
 
10
 
10
 
11
 
11
 
12
int mk_socket;
12
int mk_socket;
Line 81... Line 81...
81
}
81
}
82
 
82
 
83
 
83
 
84
int rx_last_length;
84
int rx_last_length;
85
 
85
 
-
 
86
 
-
 
87
void Decode64(unsigned char *ptrOut, unsigned char len, unsigned char ptrIn,unsigned char max)
-
 
88
{
-
 
89
 unsigned char a,b,c,d;
-
 
90
 unsigned char ptr = 0;
-
 
91
 unsigned char x,y,z;
-
 
92
 while(len)
-
 
93
  {
-
 
94
   a = RxBuffer[ptrIn++] - '=';
-
 
95
   b = RxBuffer[ptrIn++] - '=';
-
 
96
   c = RxBuffer[ptrIn++] - '=';
-
 
97
   d = RxBuffer[ptrIn++] - '=';
-
 
98
   if(ptrIn > max - 2) break;    
-
 
99
 
-
 
100
   x = (a << 2) | (b >> 4);
-
 
101
   y = ((b & 0x0f) << 4) | (c >> 2);
-
 
102
   z = ((c & 0x03) << 6) | d;
-
 
103
 
-
 
104
   if(len--) ptrOut[ptr++] = x; else break;
-
 
105
   if(len--) ptrOut[ptr++] = y; else break;
-
 
106
   if(len--) ptrOut[ptr++] = z; else break;
-
 
107
  }
-
 
108
 
-
 
109
}
-
 
110
 
86
int read_from_mk()
111
int read_from_mk()
87
{      
112
{      
88
  char in_char='#';
113
  char in_char='#';
89
  int count=0;
114
  int count=0;
90
  int r=0;
115
  int r=0;
-
 
116
  int i=0;
91
 
117
 
92
  printf("starting read\n");
118
  printf("starting read\n");
93
  while(in_char!='\n')
119
  while(in_char!='\n')
94
    {
120
    {
95
      //      printf("b read\n");
121
      //      printf("b read\n");
96
      count=read(mk_socket,&in_char,1);
122
      count=read(mk_socket,&in_char,1);
Line 110... Line 136...
110
  rx_last_length=r;
136
  rx_last_length=r;
111
  PrintableRxBuffer[r++]='\0'; // terminate 
137
  PrintableRxBuffer[r++]='\0'; // terminate 
112
  printf("done --->%s\n",PrintableRxBuffer);
138
  printf("done --->%s\n",PrintableRxBuffer);
113
 
139
 
114
  if (RxBuffer[2]=='D')
140
  if (RxBuffer[2]=='D')
-
 
141
    {
115
    debug_sets++;
142
      debug_sets++;
-
 
143
      Decode64((unsigned char *) &DebugOut,sizeof(DebugOut),3,rx_last_length);
-
 
144
      printf("decoded FC Debug data height:%d\n",DebugOut.Analog[5]);
116
 
145
    }
117
  return 1;
146
  return 1;
118
}
147
}
119
 
148
 
120
 
149
 
121
int connect_mk_bluetooth(char dest[18])
150
int connect_mk_bluetooth(char dest[18])