Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 230 → Rev 231

/branches/ligi_j2me/src/MKCommunicator.java
1,23 → 1,15
/*********************************************************************************************************************************
* *
* Abstaction Layer to Communicate via J2ME and Bluetooth with the FlightCtrl of the MikroKopter Project (www.mikrokopter.de ) *
* *
* Author: Marcus -LiGi- Bueschleb *
* Project-Start: 9/2007 *
* Version: 0.07 *
* Mailto: ligi@smart4mobile.de *
* Licence: Creative Commons / Non Commercial *
* Big Up: Holger&Ingo *
* ChangeLog: *
* 0.01 - initial Version ( initialize connection / main Thread with reading data from MK) *
* 0.02 - reconnect after connection loss ( e.g. switching on/off ) *
* 0.03 - added send_command ( with CRC ) *
* 0.04 - added decode64 to decode 'pseudo' BASE64 *
* 0.05 - added get_version *
* 0.06 - added parsing of DebugData *
* 0.07 - Code-(Doc&&Cleanup) && initial svn commit *
* *
*********************************************************************************************************************************/
/**********************************************************************************************
*
* Abstaction Layer to Communicate via J2ME and Bluetooth with the FlightCtrl of the MikroKopter Project (www.mikrokopter.de )
*
* Author: Marcus -LiGi- Bueschleb
* Project-Start: 9/2007
* Version: 0.07
* Mailto: ligi@smart4mobile.de
* Licence: Creative Commons / Non Commercial
* Big Up: Holger&Ingo
*
************************************************************************************************/
import javax.microedition.io.*;
import java.io.*;
134,6 → 126,12
}
 
 
public void motor_test(int[] params)
{
send_command(0,'t',params);
}
 
 
// send command to FC ( add crc and pack into pseudo Base64
public void send_command(int modul,char cmd,int[] params)
{
144,9 → 142,9
for(int param_pos=0;param_pos<(params.length/3 + (params.length%3==0?0:1)) ;param_pos++)
{
int a = (param_pos<params.length)?params[param_pos]:0;
int b = ((param_pos+1)<params.length)?params[param_pos+1]:0;
int c = ((param_pos+2)<params.length)?params[param_pos+2]:0;
int a = (param_pos*3<params.length)?params[param_pos*3]:0;
int b = ((param_pos*3+1)<params.length)?params[param_pos*3+1]:0;
int c = ((param_pos*3+2)<params.length)?params[param_pos*3+2]:0;
 
send_buff[3+param_pos*4] = (char)((a >> 2)+'=' );
send_buff[3+param_pos*4+1] = (char)('=' + (((a & 0x03) << 4) | ((b & 0xf0) >> 4)));