|  | @@ -28,82 +28,85 @@ import android.widget.Toast;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  | -	ProgressBar progressBar31;//进度条
 | 
	
		
			
				|  |  | -	CheckBox  checkBox31;//打开重力传感器
 | 
	
		
			
				|  |  | -	SensorManager sensorManager=null;//新建sensor的管理器
 | 
	
		
			
				|  |  | -	Sensor sensor;//传感器
 | 
	
		
			
				|  |  | -	float X_lateral;//X方向角度
 | 
	
		
			
				|  |  | -	int Speed=0;//速度
 | 
	
		
			
				|  |  | -	TextView textView35;//显示速度值
 | 
	
		
			
				|  |  | +	ProgressBar progressBar31;//杩涘害鏉�
 | 
	
		
			
				|  |  | +	CheckBox  checkBox31;//鎵撳紑閲嶅姏浼犳劅鍣�
 | 
	
		
			
				|  |  | +	SensorManager sensorManager=null;//鏂板缓sensor鐨勭�鐞嗗櫒
 | 
	
		
			
				|  |  | +	Sensor sensor;//浼犳劅鍣�
 | 
	
		
			
				|  |  | +	float X_lateral;//X鏂瑰悜瑙掑害
 | 
	
		
			
				|  |  | +	int Speed=0;//閫熷害
 | 
	
		
			
				|  |  | +	TextView textView35;//鏄剧ず閫熷害鍊�
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  | -	ImageButton imageButton31;//上
 | 
	
		
			
				|  |  | -	ImageButton imageButton32;//下
 | 
	
		
			
				|  |  | -	ImageButton imageButton33;//右
 | 
	
		
			
				|  |  | -	ImageButton imageButton34;//左
 | 
	
		
			
				|  |  | +	ImageButton imageButton31;//涓�
 | 
	
		
			
				|  |  | +	ImageButton imageButton32;//涓�
 | 
	
		
			
				|  |  | +	ImageButton imageButton33;//鍙�
 | 
	
		
			
				|  |  | +	ImageButton imageButton34;//宸�
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  | -	ImageButton imageButton35;//运行
 | 
	
		
			
				|  |  | -	ImageButton imageButton36;//急停
 | 
	
		
			
				|  |  | -	ImageButton imageButton37;//右转
 | 
	
		
			
				|  |  | -	ImageButton imageButton38;//左转
 | 
	
		
			
				|  |  | +	ImageButton imageButton35;//杩愯�
 | 
	
		
			
				|  |  | +	ImageButton imageButton36;//鎬ュ仠
 | 
	
		
			
				|  |  | +	ImageButton imageButton37;//鍙宠浆
 | 
	
		
			
				|  |  | +	ImageButton imageButton38;//宸﹁浆
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	boolean forward = false;
 | 
	
		
			
				|  |  |  	boolean back = false;
 | 
	
		
			
				|  |  |  	boolean right = false;
 | 
	
		
			
				|  |  |  	boolean left = false;
 | 
	
		
			
				|  |  | +	boolean run = false;
 | 
	
		
			
				|  |  | +	boolean stop = false;
 | 
	
		
			
				|  |  | +	boolean righttrun = false;
 | 
	
		
			
				|  |  | +	boolean lefttrun = false;
 | 
	
		
			
				|  |  | +	Vibrator vibrator;//鎸夐挳鎸変笅闇囧姩
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  | -	Vibrator vibrator;//按钮按下震动
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  | +	byte[] sendbyte = new byte[4];//鍙戦€佺殑鏁版嵁缂撳瓨
 | 
	
		
			
				|  |  | +	boolean SendDataFlag = true;//鍙戦€佹暟鎹�换鍔℃帶鍒�
 | 
	
		
			
				|  |  | +	SendMsgThread sendMsgThread;//鍙戦€佹暟鎹�换鍔�
 | 
	
		
			
				|  |  | +	boolean stopcar = false;//鎵ц�涓€娆″彂閫佸仠杞︽暟鎹�
 | 
	
		
			
				|  |  | +	Intent intentmain = new Intent(); //鐣岄潰璺宠浆--涓荤晫闈�
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  | -	byte[] sendbyte = new byte[4];//发送的数据缓存
 | 
	
		
			
				|  |  | -	boolean SendDataFlag = true;//发送数据任务控制
 | 
	
		
			
				|  |  | -	SendMsgThread sendMsgThread;//发送数据任务
 | 
	
		
			
				|  |  | -	boolean stopcar = false;//执行一次发送停车数据
 | 
	
		
			
				|  |  | -	Intent intentmain = new Intent(); //界面跳转--主界面
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | -	long exitTime=0;//返回按键计时
 | 
	
		
			
				|  |  | +	long exitTime=0;//杩斿洖鎸夐敭璁℃椂
 | 
	
		
			
				|  |  |  	@Override
 | 
	
		
			
				|  |  |  	protected void onCreate(Bundle savedInstanceState) {
 | 
	
		
			
				|  |  |  		super.onCreate(savedInstanceState);
 | 
	
		
			
				|  |  | -		setTheme(android.R.style.Theme);//设置主题风格
 | 
	
		
			
				|  |  | +		setTheme(android.R.style.Theme);//璁剧疆涓婚�椋庢牸
 | 
	
		
			
				|  |  |  		setContentView(R.layout.control);
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		progressBar31 = (ProgressBar) findViewById(R.id.progressBar31);
 | 
	
		
			
				|  |  | -		progressBar31.setProgress(50);//显示到一半
 | 
	
		
			
				|  |  | +		progressBar31.setProgress(50);//鏄剧ず鍒颁竴鍗�
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		checkBox31 = (CheckBox) findViewById(R.id.checkBox31);
 | 
	
		
			
				|  |  |  		checkBox31.setOnCheckedChangeListener(checkBox31Check);
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		textView35 = (TextView) findViewById(R.id.textView35);//速度显示
 | 
	
		
			
				|  |  | +		textView35 = (TextView) findViewById(R.id.textView35);//閫熷害鏄剧ず
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		imageButton31 = (ImageButton) findViewById(R.id.imageButton31);//上
 | 
	
		
			
				|  |  | -		imageButton32 = (ImageButton) findViewById(R.id.imageButton32);//下
 | 
	
		
			
				|  |  | -		imageButton33 = (ImageButton) findViewById(R.id.imageButton33);//右
 | 
	
		
			
				|  |  | -		imageButton34 = (ImageButton) findViewById(R.id.imageButton34);//左
 | 
	
		
			
				|  |  | +		imageButton31 = (ImageButton) findViewById(R.id.imageButton31);//涓�
 | 
	
		
			
				|  |  | +		imageButton32 = (ImageButton) findViewById(R.id.imageButton32);//涓�
 | 
	
		
			
				|  |  | +		imageButton33 = (ImageButton) findViewById(R.id.imageButton33);//鍙�
 | 
	
		
			
				|  |  | +		imageButton34 = (ImageButton) findViewById(R.id.imageButton34);//宸�
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		imageButton35 = (ImageButton) findViewById(R.id.imageButton35);//启动
 | 
	
		
			
				|  |  | -		imageButton36 = (ImageButton) findViewById(R.id.imageButton36);//急停
 | 
	
		
			
				|  |  | -		imageButton37 = (ImageButton) findViewById(R.id.imageButton37);//右转
 | 
	
		
			
				|  |  | -		imageButton38 = (ImageButton) findViewById(R.id.imageButton38);//左转
 | 
	
		
			
				|  |  | +		imageButton35 = (ImageButton) findViewById(R.id.imageButton35);//鍚�姩
 | 
	
		
			
				|  |  | +		imageButton36 = (ImageButton) findViewById(R.id.imageButton36);//鎬ュ仠
 | 
	
		
			
				|  |  | +		imageButton37 = (ImageButton) findViewById(R.id.imageButton37);//鍙宠浆
 | 
	
		
			
				|  |  | +		imageButton38 = (ImageButton) findViewById(R.id.imageButton38);//宸﹁浆
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		imageButton31.setOnTouchListener(imageButton31Touch);//上
 | 
	
		
			
				|  |  | -		imageButton32.setOnTouchListener(imageButton32Touch);//下
 | 
	
		
			
				|  |  | -		imageButton33.setOnTouchListener(imageButton33Touch);//右
 | 
	
		
			
				|  |  | -		imageButton34.setOnTouchListener(imageButton34Touch);//左
 | 
	
		
			
				|  |  | +		imageButton31.setOnTouchListener(imageButton31Touch);//涓�
 | 
	
		
			
				|  |  | +		imageButton32.setOnTouchListener(imageButton32Touch);//涓�
 | 
	
		
			
				|  |  | +		imageButton33.setOnTouchListener(imageButton33Touch);//鍙�
 | 
	
		
			
				|  |  | +		imageButton34.setOnTouchListener(imageButton34Touch);//宸�
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		imageButton35.setOnTouchListener(imageButton35Touch);//启动
 | 
	
		
			
				|  |  | -		imageButton36.setOnTouchListener(imageButton36Touch);//急停
 | 
	
		
			
				|  |  | -		imageButton37.setOnTouchListener(imageButton37Touch);//右转
 | 
	
		
			
				|  |  | -		imageButton38.setOnTouchListener(imageButton38Touch);//左转
 | 
	
		
			
				|  |  | +		imageButton35.setOnTouchListener(imageButton35Touch);//鍚�姩
 | 
	
		
			
				|  |  | +		imageButton36.setOnTouchListener(imageButton36Touch);//鎬ュ仠
 | 
	
		
			
				|  |  | +		imageButton37.setOnTouchListener(imageButton37Touch);//鍙宠浆
 | 
	
		
			
				|  |  | +		imageButton38.setOnTouchListener(imageButton38Touch);//宸﹁浆
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		vibrator=(Vibrator)getSystemService(Service.VIBRATOR_SERVICE);//震动
 | 
	
		
			
				|  |  | +		vibrator=(Vibrator)getSystemService(Service.VIBRATOR_SERVICE);//闇囧姩
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		sendMsgThread = new SendMsgThread();
 | 
	
		
			
				|  |  | -		sendMsgThread.start();//启动发送数据任务
 | 
	
		
			
				|  |  | +		sendMsgThread.start();//鍚�姩鍙戦€佹暟鎹�换鍔�
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	
 | 
	
	
		
			
				|  | @@ -111,15 +114,15 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  	 {
 | 
	
		
			
				|  |  |  		 if (keyCode == KeyEvent.KEYCODE_BACK
 | 
	
		
			
				|  |  |  		            && event.getAction() == KeyEvent.ACTION_DOWN) {
 | 
	
		
			
				|  |  | -		        // 判断间隔时间 大于2秒就退出应用
 | 
	
		
			
				|  |  | +		        // 鍒ゆ柇闂撮殧鏃堕棿 澶т簬2绉掑氨閫€鍑哄簲鐢�
 | 
	
		
			
				|  |  |  		        if ((System.currentTimeMillis() - exitTime) > 2000) {
 | 
	
		
			
				|  |  | -		            Toast.makeText(getApplicationContext(), "再按一次返回连接界面",
 | 
	
		
			
				|  |  | +		            Toast.makeText(getApplicationContext(), "鍐嶆寜涓€娆¤繑鍥炶繛鎺ョ晫闈�",
 | 
	
		
			
				|  |  |  		                    Toast.LENGTH_SHORT).show();
 | 
	
		
			
				|  |  |  		            exitTime = System.currentTimeMillis();
 | 
	
		
			
				|  |  |  		        } 
 | 
	
		
			
				|  |  |  		        else 
 | 
	
		
			
				|  |  |  		        {
 | 
	
		
			
				|  |  | -		        	intentmain.setClass(Control.this, MainActivity.class);//跳转到控制界面
 | 
	
		
			
				|  |  | +		        	intentmain.setClass(Control.this, MainActivity.class);//璺宠浆鍒版帶鍒剁晫闈�
 | 
	
		
			
				|  |  |  		    		Control.this.startActivity(intentmain);
 | 
	
		
			
				|  |  |  		        }
 | 
	
		
			
				|  |  |  		        return false;
 | 
	
	
		
			
				|  | @@ -128,7 +131,7 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  	 }	 
 | 
	
		
			
				|  |  |  	 
 | 
	
		
			
				|  |  |  	/***
 | 
	
		
			
				|  |  | -	 * 前进按钮
 | 
	
		
			
				|  |  | +	 * 鍓嶈繘鎸夐挳
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	private OnTouchListener imageButton31Touch = new OnTouchListener() {
 | 
	
		
			
				|  |  |  		
 | 
	
	
		
			
				|  | @@ -138,20 +141,20 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  			if (event.getAction()==MotionEvent.ACTION_DOWN) {
 | 
	
		
			
				|  |  |  				forward = true;
 | 
	
		
			
				|  |  |  				back=false;
 | 
	
		
			
				|  |  | -				imageButton31.setImageResource(R.drawable.topdown);//改变背景
 | 
	
		
			
				|  |  | +				imageButton31.setImageResource(R.drawable.forwarddown);//鏀瑰彉鑳屾櫙
 | 
	
		
			
				|  |  |  				
 | 
	
		
			
				|  |  | -				vibrator.vibrate(new long[]{0,20}, -1);//震动  
 | 
	
		
			
				|  |  | +				vibrator.vibrate(new long[]{0,20}, -1);//闇囧姩  
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			if (event.getAction()==MotionEvent.ACTION_UP) {
 | 
	
		
			
				|  |  |  				forward = false;
 | 
	
		
			
				|  |  | -				imageButton31.setImageResource(R.drawable.top);//改变背景
 | 
	
		
			
				|  |  | +				imageButton31.setImageResource(R.drawable.forward);//鏀瑰彉鑳屾櫙
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			return false;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	};
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	/***
 | 
	
		
			
				|  |  | -	 * 后退按钮
 | 
	
		
			
				|  |  | +	 * 鍚庨€€鎸夐挳
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	private OnTouchListener imageButton32Touch = new OnTouchListener() {
 | 
	
		
			
				|  |  |  		
 | 
	
	
		
			
				|  | @@ -161,19 +164,19 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  			if (event.getAction()==MotionEvent.ACTION_DOWN) {
 | 
	
		
			
				|  |  |  				back=true;
 | 
	
		
			
				|  |  |  				forward=false;
 | 
	
		
			
				|  |  | -				imageButton32.setImageResource(R.drawable.bottomdown);//改变背景
 | 
	
		
			
				|  |  | -				vibrator.vibrate(new long[]{0,20}, -1); //震动   
 | 
	
		
			
				|  |  | +				imageButton32.setImageResource(R.drawable.backdown);//鏀瑰彉鑳屾櫙
 | 
	
		
			
				|  |  | +				vibrator.vibrate(new long[]{0,20}, -1); //闇囧姩   
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			if (event.getAction()==MotionEvent.ACTION_UP) {
 | 
	
		
			
				|  |  |  				back=false;
 | 
	
		
			
				|  |  | -				imageButton32.setImageResource(R.drawable.bottom);//改变背景
 | 
	
		
			
				|  |  | +				imageButton32.setImageResource(R.drawable.back);//鏀瑰彉鑳屾櫙
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			return false;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	};
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	/***
 | 
	
		
			
				|  |  | -	 * 右转按钮
 | 
	
		
			
				|  |  | +	 * 鍙宠浆鎸夐挳
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	private OnTouchListener imageButton33Touch = new OnTouchListener() {
 | 
	
		
			
				|  |  |  		
 | 
	
	
		
			
				|  | @@ -183,19 +186,19 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  			if (event.getAction()==MotionEvent.ACTION_DOWN) {
 | 
	
		
			
				|  |  |  				right=true;
 | 
	
		
			
				|  |  |  				left=false;
 | 
	
		
			
				|  |  | -				imageButton33.setImageResource(R.drawable.rightdown);//改变背景
 | 
	
		
			
				|  |  | -				vibrator.vibrate(new long[]{0,20}, -1);  //震动  
 | 
	
		
			
				|  |  | +				imageButton33.setImageResource(R.drawable.rightdown);//鏀瑰彉鑳屾櫙
 | 
	
		
			
				|  |  | +				vibrator.vibrate(new long[]{0,20}, -1);  //闇囧姩  
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			if (event.getAction()==MotionEvent.ACTION_UP) {
 | 
	
		
			
				|  |  |  				right=false;
 | 
	
		
			
				|  |  | -				imageButton33.setImageResource(R.drawable.right);//改变背景
 | 
	
		
			
				|  |  | +				imageButton33.setImageResource(R.drawable.right);//鏀瑰彉鑳屾櫙
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			return false;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	};
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	/***
 | 
	
		
			
				|  |  | -	 * 左转按钮
 | 
	
		
			
				|  |  | +	 * 宸﹁浆鎸夐挳
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	private OnTouchListener imageButton34Touch = new OnTouchListener() {
 | 
	
		
			
				|  |  |  		
 | 
	
	
		
			
				|  | @@ -205,12 +208,12 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  			if (event.getAction()==MotionEvent.ACTION_DOWN) {
 | 
	
		
			
				|  |  |  				left=true;
 | 
	
		
			
				|  |  |  				right=false;
 | 
	
		
			
				|  |  | -				imageButton34.setImageResource(R.drawable.leftdown);//改变背景
 | 
	
		
			
				|  |  | -				vibrator.vibrate(new long[]{0,20}, -1); //震动   
 | 
	
		
			
				|  |  | +				imageButton34.setImageResource(R.drawable.leftdown);//鏀瑰彉鑳屾櫙
 | 
	
		
			
				|  |  | +				vibrator.vibrate(new long[]{0,20}, -1); //闇囧姩   
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			if (event.getAction()==MotionEvent.ACTION_UP) {
 | 
	
		
			
				|  |  |  				left=false;
 | 
	
		
			
				|  |  | -				imageButton34.setImageResource(R.drawable.left);//改变背景
 | 
	
		
			
				|  |  | +				imageButton34.setImageResource(R.drawable.left);//鏀瑰彉鑳屾櫙
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			return false;
 | 
	
		
			
				|  |  |  		}
 | 
	
	
		
			
				|  | @@ -218,7 +221,7 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	/***
 | 
	
		
			
				|  |  | -	 * 运行
 | 
	
		
			
				|  |  | +	 * 杩愯�
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	private OnTouchListener imageButton35Touch = new OnTouchListener() {
 | 
	
		
			
				|  |  |  		
 | 
	
	
		
			
				|  | @@ -226,21 +229,21 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  		public boolean onTouch(View v, MotionEvent event) {
 | 
	
		
			
				|  |  |  			// TODO Auto-generated method stub
 | 
	
		
			
				|  |  |  			if (event.getAction()==MotionEvent.ACTION_DOWN) {
 | 
	
		
			
				|  |  | -				forward = true;
 | 
	
		
			
				|  |  | +				run = true;
 | 
	
		
			
				|  |  |  				back=false;
 | 
	
		
			
				|  |  | -				imageButton35.setImageResource(R.drawable.rundown);//改变背景
 | 
	
		
			
				|  |  | +				imageButton35.setImageResource(R.drawable.rundown);//鏀瑰彉鑳屾櫙
 | 
	
		
			
				|  |  |  				
 | 
	
		
			
				|  |  | -				vibrator.vibrate(new long[]{0,20}, -1);//震动  
 | 
	
		
			
				|  |  | +				vibrator.vibrate(new long[]{0,20}, -1);//闇囧姩  
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			if (event.getAction()==MotionEvent.ACTION_UP) {
 | 
	
		
			
				|  |  | -				forward = false;
 | 
	
		
			
				|  |  | -				imageButton35.setImageResource(R.drawable.run);//改变背景
 | 
	
		
			
				|  |  | +				run = false;
 | 
	
		
			
				|  |  | +				imageButton35.setImageResource(R.drawable.run);//鏀瑰彉鑳屾櫙
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			return false;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	};
 | 
	
		
			
				|  |  |  	/***
 | 
	
		
			
				|  |  | -	 * 急停
 | 
	
		
			
				|  |  | +	 * 鎬ュ仠
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	private OnTouchListener imageButton36Touch = new OnTouchListener() {
 | 
	
		
			
				|  |  |  		
 | 
	
	
		
			
				|  | @@ -248,22 +251,22 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  		public boolean onTouch(View v, MotionEvent event) {
 | 
	
		
			
				|  |  |  			// TODO Auto-generated method stub
 | 
	
		
			
				|  |  |  			if (event.getAction()==MotionEvent.ACTION_DOWN) {
 | 
	
		
			
				|  |  | -				forward = true;
 | 
	
		
			
				|  |  | +				stop = true;
 | 
	
		
			
				|  |  |  				back=false;
 | 
	
		
			
				|  |  | -				imageButton36.setImageResource(R.drawable.stopdown);//改变背景
 | 
	
		
			
				|  |  | +				imageButton36.setImageResource(R.drawable.stopdown);//鏀瑰彉鑳屾櫙
 | 
	
		
			
				|  |  |  				
 | 
	
		
			
				|  |  | -				vibrator.vibrate(new long[]{0,20}, -1);//震动  
 | 
	
		
			
				|  |  | +				vibrator.vibrate(new long[]{0,20}, -1);//闇囧姩  
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			if (event.getAction()==MotionEvent.ACTION_UP) {
 | 
	
		
			
				|  |  | -				forward = false;
 | 
	
		
			
				|  |  | -				imageButton36.setImageResource(R.drawable.stop);//改变背景
 | 
	
		
			
				|  |  | +				stop = false;
 | 
	
		
			
				|  |  | +				imageButton36.setImageResource(R.drawable.stop);//鏀瑰彉鑳屾櫙
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			return false;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	}; 
 | 
	
		
			
				|  |  |   
 | 
	
		
			
				|  |  |  	/***
 | 
	
		
			
				|  |  | -	 * 右转
 | 
	
		
			
				|  |  | +	 * 鍙宠浆
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	private OnTouchListener imageButton37Touch = new OnTouchListener() {
 | 
	
		
			
				|  |  |  		
 | 
	
	
		
			
				|  | @@ -271,22 +274,22 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  		public boolean onTouch(View v, MotionEvent event) {
 | 
	
		
			
				|  |  |  			// TODO Auto-generated method stub
 | 
	
		
			
				|  |  |  			if (event.getAction()==MotionEvent.ACTION_DOWN) {
 | 
	
		
			
				|  |  | -				forward = true;
 | 
	
		
			
				|  |  | +				righttrun = true;
 | 
	
		
			
				|  |  |  				back=false;
 | 
	
		
			
				|  |  | -				imageButton37.setImageResource(R.drawable.righttrundown);//改变背景
 | 
	
		
			
				|  |  | +				imageButton37.setImageResource(R.drawable.righttrundown);//鏀瑰彉鑳屾櫙
 | 
	
		
			
				|  |  |  				
 | 
	
		
			
				|  |  | -				vibrator.vibrate(new long[]{0,20}, -1);//震动  
 | 
	
		
			
				|  |  | +				vibrator.vibrate(new long[]{0,20}, -1);//闇囧姩  
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			if (event.getAction()==MotionEvent.ACTION_UP) {
 | 
	
		
			
				|  |  | -				forward = false;
 | 
	
		
			
				|  |  | -				imageButton37.setImageResource(R.drawable.righttrun);//改变背景
 | 
	
		
			
				|  |  | +				righttrun = false;
 | 
	
		
			
				|  |  | +				imageButton37.setImageResource(R.drawable.righttrun);//鏀瑰彉鑳屾櫙
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			return false;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	};  
 | 
	
		
			
				|  |  |   
 | 
	
		
			
				|  |  |  	/***
 | 
	
		
			
				|  |  | -	 * 左转
 | 
	
		
			
				|  |  | +	 * 宸﹁浆
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	private OnTouchListener imageButton38Touch = new OnTouchListener() {
 | 
	
		
			
				|  |  |  		
 | 
	
	
		
			
				|  | @@ -294,28 +297,23 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  		public boolean onTouch(View v, MotionEvent event) {
 | 
	
		
			
				|  |  |  			// TODO Auto-generated method stub
 | 
	
		
			
				|  |  |  			if (event.getAction()==MotionEvent.ACTION_DOWN) {
 | 
	
		
			
				|  |  | -				forward = true;
 | 
	
		
			
				|  |  | +				lefttrun = true;
 | 
	
		
			
				|  |  |  				back=false;
 | 
	
		
			
				|  |  | -				imageButton38.setImageResource(R.drawable.lefttrundown);//改变背景
 | 
	
		
			
				|  |  | +				imageButton38.setImageResource(R.drawable.lefttrundown);//鏀瑰彉鑳屾櫙
 | 
	
		
			
				|  |  |  				
 | 
	
		
			
				|  |  | -				vibrator.vibrate(new long[]{0,20}, -1);//震动  
 | 
	
		
			
				|  |  | +				vibrator.vibrate(new long[]{0,20}, -1);//闇囧姩  
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			if (event.getAction()==MotionEvent.ACTION_UP) {
 | 
	
		
			
				|  |  | -				forward = false;
 | 
	
		
			
				|  |  | -				imageButton38.setImageResource(R.drawable.lefttrun);//改变背景
 | 
	
		
			
				|  |  | +				lefttrun = false;
 | 
	
		
			
				|  |  | +				imageButton38.setImageResource(R.drawable.lefttrun);//鏀瑰彉鑳屾櫙
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			return false;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	};  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  |  	/**
 | 
	
		
			
				|  |  | -	 *左转大于右转大于后退大于前进
 | 
	
		
			
				|  |  | -	 *(单个按钮)谁按下执行谁
 | 
	
		
			
				|  |  | +	 *宸﹁浆澶т簬鍙宠浆澶т簬鍚庨€€澶т簬鍓嶈繘
 | 
	
		
			
				|  |  | +	 *(鍗曚釜鎸夐挳)璋佹寜涓嬫墽琛岃皝
 | 
	
		
			
				|  |  |  	 *
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	class SendMsgThread extends Thread
 | 
	
	
		
			
				|  | @@ -326,40 +324,54 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  			{
 | 
	
		
			
				|  |  |  				sendbyte[0] = (byte)0xaa;
 | 
	
		
			
				|  |  |  	            sendbyte[1] = (byte)0x55;
 | 
	
		
			
				|  |  | -	            if (!checkBox31.isChecked()) {//没有打开重力传感器速度默认50
 | 
	
		
			
				|  |  | +	            if (!checkBox31.isChecked()) {//娌℃湁鎵撳紑閲嶅姏浼犳劅鍣ㄩ€熷害榛樿�50
 | 
	
		
			
				|  |  |  	            	sendbyte[3] = 50;
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  | -				if (forward) {//前进
 | 
	
		
			
				|  |  | +				if (forward) {//鍓嶈繘
 | 
	
		
			
				|  |  |  					sendbyte[2] = (byte)0x01;
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  | -				if (back) {//后退
 | 
	
		
			
				|  |  | +				if (back) {//鍚庨€€
 | 
	
		
			
				|  |  |  					sendbyte[2] = (byte)0x02;
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  | -				if (right) {//右转
 | 
	
		
			
				|  |  | +				if (right) {//鍙�
 | 
	
		
			
				|  |  |  					sendbyte[2] = (byte)0x03;
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  | -				if (left) {//左转
 | 
	
		
			
				|  |  | +				if (left) {//宸�
 | 
	
		
			
				|  |  |  					sendbyte[2] = (byte)0x04;
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  |  				
 | 
	
		
			
				|  |  | -				if (forward || back || right || left) //有按下的按钮
 | 
	
		
			
				|  |  | +				if (run) {//杩愯�
 | 
	
		
			
				|  |  | +					sendbyte[2] = (byte)0x05;
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +				if (stop) {//鍋滄�
 | 
	
		
			
				|  |  | +					sendbyte[2] = (byte)0x06;
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +				if (righttrun) {//鍙宠浆
 | 
	
		
			
				|  |  | +					sendbyte[2] = (byte)0x07;
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +				if (lefttrun) {//宸﹁浆
 | 
	
		
			
				|  |  | +					sendbyte[2] = (byte)0x08;
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +				
 | 
	
		
			
				|  |  | +				
 | 
	
		
			
				|  |  | +				if (forward || back || right || left || run || stop || righttrun || lefttrun) //鏈夋寜涓嬬殑鎸夐挳
 | 
	
		
			
				|  |  |  				{
 | 
	
		
			
				|  |  | -					stopcar = true;//有过按钮操作
 | 
	
		
			
				|  |  | +					stopcar = true;//鏈夎繃鎸夐挳鎿嶄綔
 | 
	
		
			
				|  |  |  					netSend(sendbyte);
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  | -				else//没有按下的按钮发送一次停车指令
 | 
	
		
			
				|  |  | +				else//娌℃湁鎸変笅鐨勬寜閽�彂閫佷竴娆″仠杞︽寚浠�
 | 
	
		
			
				|  |  |  				{
 | 
	
		
			
				|  |  | -					if (stopcar) //有过按钮操作
 | 
	
		
			
				|  |  | +					if (stopcar) //鏈夎繃鎸夐挳鎿嶄綔
 | 
	
		
			
				|  |  |  					{
 | 
	
		
			
				|  |  |  						stopcar = false;
 | 
	
		
			
				|  |  | -						sendbyte[2] = (byte)0x05;
 | 
	
		
			
				|  |  | +						sendbyte[2] = (byte)0x09;
 | 
	
		
			
				|  |  |  						sendbyte[3] = (byte)0x00;
 | 
	
		
			
				|  |  |  						netSend(sendbyte);
 | 
	
		
			
				|  |  |  					}
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  |  				
 | 
	
		
			
				|  |  |  				try {
 | 
	
		
			
				|  |  | -					Thread.sleep(100);//延时100ms
 | 
	
		
			
				|  |  | +					Thread.sleep(100);//寤舵椂100ms
 | 
	
		
			
				|  |  |  				} catch (InterruptedException e) {
 | 
	
		
			
				|  |  |  					// TODO Auto-generated catch block
 | 
	
		
			
				|  |  |  					e.printStackTrace();
 | 
	
	
		
			
				|  | @@ -369,26 +381,26 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	/**
 | 
	
		
			
				|  |  | -	 * 发送数据
 | 
	
		
			
				|  |  | +	 * 鍙戦€佹暟鎹�
 | 
	
		
			
				|  |  |  	 * @param byt
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	private void netSend(byte[] byt)
 | 
	
		
			
				|  |  |  	{
 | 
	
		
			
				|  |  |  		int crc = 0;
 | 
	
		
			
				|  |  | -		ByteBuffer Crcbyte = ByteBuffer.allocate(4);//创建4个字节的  ByteBuffer
 | 
	
		
			
				|  |  | +		ByteBuffer Crcbyte = ByteBuffer.allocate(4);//鍒涘缓4涓�瓧鑺傜殑  ByteBuffer
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -        byte[] sendbyte = new byte[byt.length + 2];//后面加2是原来存储CRC
 | 
	
		
			
				|  |  | +        byte[] sendbyte = new byte[byt.length + 2];//鍚庨潰鍔�2鏄�師鏉ュ瓨鍌–RC
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        for (int i = 0; i < byt.length; i++)//copy数据
 | 
	
		
			
				|  |  | +        for (int i = 0; i < byt.length; i++)//copy鏁版嵁
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              sendbyte[i] = byt[i];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        crc = crc16_modbus(byt, byt.length);//计算CRC
 | 
	
		
			
				|  |  | -        Crcbyte.putInt(crc);//把int转成byte--默认是转成4个字节的,,所以上面定义了4个字节的↑↑
 | 
	
		
			
				|  |  | +        crc = crc16_modbus(byt, byt.length);//璁$畻CRC
 | 
	
		
			
				|  |  | +        Crcbyte.putInt(crc);//鎶奿nt杞�垚byte--榛樿�鏄�浆鎴�4涓�瓧鑺傜殑,,鎵€浠ヤ笂闈㈠畾涔変簡4涓�瓧鑺傜殑鈫戔啈
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        sendbyte[sendbyte.length - 2] = Crcbyte.get(3);//低位在前----java看来默认的大端模式存储数据
 | 
	
		
			
				|  |  | -        sendbyte[sendbyte.length - 1] = Crcbyte.get(2);//高位在后
 | 
	
		
			
				|  |  | +        sendbyte[sendbyte.length - 2] = Crcbyte.get(3);//浣庝綅鍦ㄥ墠----java鐪嬫潵榛樿�鐨勫ぇ绔�ā寮忓瓨鍌ㄦ暟鎹�
 | 
	
		
			
				|  |  | +        sendbyte[sendbyte.length - 1] = Crcbyte.get(2);//楂樹綅鍦ㄥ悗
 | 
	
		
			
				|  |  |          
 | 
	
		
			
				|  |  |          try 
 | 
	
		
			
				|  |  |          {
 | 
	
	
		
			
				|  | @@ -396,7 +408,7 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  		} 
 | 
	
		
			
				|  |  |          catch (Exception e) 
 | 
	
		
			
				|  |  |  		{
 | 
	
		
			
				|  |  | -        	Log.e("Control", "获取输出流错误");
 | 
	
		
			
				|  |  | +        	Log.e("Control", "鑾峰彇杈撳嚭娴侀敊璇�");
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |          try 
 | 
	
		
			
				|  |  |          {
 | 
	
	
		
			
				|  | @@ -404,16 +416,16 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  		} 
 | 
	
		
			
				|  |  |          catch (IOException e) 
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -        	Log.e("Control", "发送错误,跳转到主界面!!");
 | 
	
		
			
				|  |  | +        	Log.e("Control", "鍙戦€侀敊璇�,璺宠浆鍒颁富鐣岄潰!!");
 | 
	
		
			
				|  |  |          	SendDataFlag = false;
 | 
	
		
			
				|  |  |          	socket = null;
 | 
	
		
			
				|  |  | -        	intentmain.setClass(Control.this, MainActivity.class);//有错误跳转到主界面重新连接
 | 
	
		
			
				|  |  | +        	intentmain.setClass(Control.this, MainActivity.class);//鏈夐敊璇�烦杞�埌涓荤晫闈㈤噸鏂拌繛鎺�
 | 
	
		
			
				|  |  |     		 	Control.this.startActivity(intentmain);
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	/***
 | 
	
		
			
				|  |  | -	 * 单选框事件
 | 
	
		
			
				|  |  | +	 * 鍗曢€夋�浜嬩欢
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	private OnCheckedChangeListener checkBox31Check = new OnCheckedChangeListener() {
 | 
	
		
			
				|  |  |  		@Override
 | 
	
	
		
			
				|  | @@ -421,9 +433,9 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  			// TODO Auto-generated method stub
 | 
	
		
			
				|  |  |  			if (isChecked) 
 | 
	
		
			
				|  |  |  			{
 | 
	
		
			
				|  |  | -				sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);//获取手机里面的传感器  
 | 
	
		
			
				|  |  | -				sensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);//选择获取重力传感器
 | 
	
		
			
				|  |  | -				                              //监听函数                        重力传感器对象              工作频率
 | 
	
		
			
				|  |  | +				sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);//鑾峰彇鎵嬫満閲岄潰鐨勪紶鎰熷櫒  
 | 
	
		
			
				|  |  | +				sensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);//閫夋嫨鑾峰彇閲嶅姏浼犳劅鍣�
 | 
	
		
			
				|  |  | +				                              //鐩戝惉鍑芥暟                        閲嶅姏浼犳劅鍣ㄥ�璞�              宸ヤ綔棰戠巼
 | 
	
		
			
				|  |  |  				if (sensorManager !=null) 
 | 
	
		
			
				|  |  |  				{
 | 
	
		
			
				|  |  |  					sensorManager.registerListener(mySensorEventListener, sensor,  SensorManager.SENSOR_DELAY_NORMAL);// SENSOR_DELAY_GAME  
 | 
	
	
		
			
				|  | @@ -433,14 +445,14 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  			{
 | 
	
		
			
				|  |  |  				if (sensorManager !=null) 
 | 
	
		
			
				|  |  |  				{
 | 
	
		
			
				|  |  | -					sensorManager.unregisterListener(mySensorEventListener);//释放传感器
 | 
	
		
			
				|  |  | +					sensorManager.unregisterListener(mySensorEventListener);//閲婃斁浼犳劅鍣�
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	};
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	/**
 | 
	
		
			
				|  |  | -	 * 重力传感器监听事件
 | 
	
		
			
				|  |  | +	 * 閲嶅姏浼犳劅鍣ㄧ洃鍚�簨浠�
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	SensorEventListener mySensorEventListener = new SensorEventListener() {
 | 
	
		
			
				|  |  |  		
 | 
	
	
		
			
				|  | @@ -449,12 +461,12 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  			// TODO Auto-generated method stub
 | 
	
		
			
				|  |  |  			if(event.sensor.getType() == Sensor.TYPE_ACCELEROMETER)
 | 
	
		
			
				|  |  |  			{  
 | 
	
		
			
				|  |  | -                X_lateral = event.values[0]+10; //把-10到10的数据变为0-20  
 | 
	
		
			
				|  |  | -                Speed = (int)((100-(X_lateral*10/2))*2);//变为0-200
 | 
	
		
			
				|  |  | +                X_lateral = event.values[0]+10; //鎶�-10鍒�10鐨勬暟鎹�彉涓�0-20  
 | 
	
		
			
				|  |  | +                Speed = (int)((100-(X_lateral*10/2))*2);//鍙樹负0-200
 | 
	
		
			
				|  |  |                  if (Speed>100) {
 | 
	
		
			
				|  |  |                  	Speed = 100;
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  | -                sendbyte[3] = (byte)Speed;//得到速度变量
 | 
	
		
			
				|  |  | +                sendbyte[3] = (byte)Speed;//寰楀埌閫熷害鍙橀噺
 | 
	
		
			
				|  |  |                  textView35.setText(String.valueOf(Speed));
 | 
	
		
			
				|  |  |                  //Toast.makeText(controlcar.this, Y_longitudinal+"", 500).show();
 | 
	
		
			
				|  |  |                  runOnUiThread(new Runnable() {
 | 
	
	
		
			
				|  | @@ -475,7 +487,7 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  					public void run() 
 | 
	
		
			
				|  |  |  					{
 | 
	
		
			
				|  |  |  						checkBox31.setChecked(false);
 | 
	
		
			
				|  |  | -						Toast.makeText(Control.this, "传感器不存在!!!", 500).show();
 | 
	
		
			
				|  |  | +						Toast.makeText(Control.this, "浼犳劅鍣ㄤ笉瀛樺湪!!!", 500).show();
 | 
	
		
			
				|  |  |  					}
 | 
	
		
			
				|  |  |  				});
 | 
	
		
			
				|  |  |  			}
 | 
	
	
		
			
				|  | @@ -488,10 +500,10 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	};
 | 
	
		
			
				|  |  |  	/**
 | 
	
		
			
				|  |  | -	 * CRC检验值
 | 
	
		
			
				|  |  | +	 * CRC妫€楠屽€�
 | 
	
		
			
				|  |  |  	 * @param modbusdata
 | 
	
		
			
				|  |  |  	 * @param length
 | 
	
		
			
				|  |  | -	 * @return CRC检验值
 | 
	
		
			
				|  |  | +	 * @return CRC妫€楠屽€�
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	 protected int crc16_modbus(byte[] modbusdata, int length)
 | 
	
		
			
				|  |  |       {
 | 
	
	
		
			
				|  | @@ -503,7 +515,7 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |           {
 | 
	
		
			
				|  |  |               for (i = 0; i < length; i++)
 | 
	
		
			
				|  |  |               {
 | 
	
		
			
				|  |  | -                 crc ^= (modbusdata[i]&(0xff));//注意这里要&0xff
 | 
	
		
			
				|  |  | +                 crc ^= (modbusdata[i]&(0xff));//娉ㄦ剰杩欓噷瑕�&0xff
 | 
	
		
			
				|  |  |                   for (j = 0; j < 8; j++)
 | 
	
		
			
				|  |  |                   {
 | 
	
		
			
				|  |  |                       if ((crc & 0x01) == 1)
 | 
	
	
		
			
				|  | @@ -527,14 +539,14 @@ public class Control extends MainActivity {
 | 
	
		
			
				|  |  |       }
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	 /**
 | 
	
		
			
				|  |  | -	  * CRC校验正确标志
 | 
	
		
			
				|  |  | +	  * CRC鏍¢獙姝g‘鏍囧織
 | 
	
		
			
				|  |  |  	  * @param modbusdata
 | 
	
		
			
				|  |  |  	  * @param length
 | 
	
		
			
				|  |  |  	  * @return 0-failed 1-success 
 | 
	
		
			
				|  |  |  	  */
 | 
	
		
			
				|  |  |  	 protected int crc16_flage(byte[] modbusdata, int length)
 | 
	
		
			
				|  |  |       {
 | 
	
		
			
				|  |  | -         int Receive_CRC = 0, calculation = 0;//接收到的CRC,计算的CRC
 | 
	
		
			
				|  |  | +         int Receive_CRC = 0, calculation = 0;//鎺ユ敹鍒扮殑CRC,璁$畻鐨凜RC
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |           Receive_CRC = crc16_modbus(modbusdata, length);
 | 
	
		
			
				|  |  |           calculation = modbusdata[length + 1];
 |