发送完单片机文件内容后删除dfu.bin;在发给移动站服务实际命令处打印log
| | |
| | | public static final String BIND_RTCM_TOPIC = "BIND_RTCM_TOPIC"; |
| | | public static final String BIND_DEBUG_TXT = "BIND_DEBUG_TXT"; |
| | | public static final int UPGRADE_MCU_CONTENT_FILE = 0x8100; |
| | | public static final String MCU_FILE_NAME = "dfu.bin"; |
| | | public static String exam_enter_exitdata="exam_enter_exitdata"; |
| | | } |
| | |
| | | import java.nio.charset.Charset; |
| | | import java.util.List; |
| | | |
| | | import safeluck.drive.evaluation.util.CThreadPoolExecutor; |
| | | import safeluck.drive.evaluation.util.FileUtil; |
| | | import safeluck.drive.evaluation.util.PermissionManager; |
| | | import safeluck.drive.evaluation.viewmodels.MainViewModel; |
| | |
| | | }; |
| | | |
| | | private void sendMcuUprgrade() { |
| | | try { |
| | | byte[] datas = FileUtil.readLocalFile(this,"dfu.bin"); |
| | | Log.i(TAG, ByteUtil.byte2hex(datas)); |
| | | if (datas != null){ |
| | | CThreadPoolExecutor.runInBackground(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | byte[] datas = FileUtil.readLocalFile(MainActivity.this,Constant.MCU_FILE_NAME); |
| | | if (datas != null){ |
| | | Log.i(TAG, ByteUtil.byte2hex(datas)); |
| | | |
| | | String strs = new String(datas, Charset.forName("ISO-8859-1")); |
| | | MyLog.i(TAG, "mcu upgrade datas.legnth=="+strs.getBytes("ISO-8859-1").length); |
| | | AYSdk.getInstance().sendCmd(Constant.UPGRADE_MCU_CONTENT_FILE, strs); |
| | | }else{ |
| | | MyLog.i(TAG,"mcu升级文件不存在"); |
| | | String strs = new String(datas, Charset.forName("ISO-8859-1")); |
| | | MyLog.i(TAG, "mcu upgrade datas.legnth=="+strs.getBytes("ISO-8859-1").length); |
| | | AYSdk.getInstance().sendCmd(Constant.UPGRADE_MCU_CONTENT_FILE, strs); |
| | | FileUtil.deleteFile("",Constant.MCU_FILE_NAME); |
| | | }else{ |
| | | MyLog.i(TAG,"mcu升级文件不存在"); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | private void sendRtkConfigInfo() { |
| | |
| | | try { |
| | | byte[] datas =FileUtil.readLocalFile(getActivity(),"dfu.bin"); |
| | | if (datas != null){ |
| | | Log.i(TAG,ByteUtil.byte2hex(datas)); |
| | | |
| | | String strs = new String(datas, Charset.forName("ISO-8859-1")); |
| | | Log.i(TAG, "onClick: datas.legnth=="+strs.getBytes("ISO-8859-1").length); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除某个文件 |
| | | * @param parentPathName 当前文件的父目录一直到根目录(不包括根目录) |
| | | * @param fileName 文件名 |
| | | */ |
| | | public static void deleteFile(String parentPathName, String fileName){ |
| | | String dir =Environment.getExternalStorageDirectory().getAbsolutePath()+"/"; |
| | | dir = dir+parentPathName; |
| | | MyLog.i(TAG,"删除文件"+dir+fileName); |
| | | File file = new File(dir,fileName); |
| | | if (file.exists()){ |
| | | file.delete(); |
| | | } |
| | | } |
| | | public static byte[] readLocalFile(Context context,String fileName) throws IOException { |
| | | InputStream inputStream = null; |
| | | String dir = Environment.getExternalStorageDirectory().getAbsolutePath()+"/"; |
| | |
| | | |
| | | @Override |
| | | public void sendCmd(int cmd, String s) { |
| | | MyLog.i(TAG,"CMD="+ String.format("0x%x",cmd) +" content:"+(!TextUtils.isEmpty(s)?s:"null")); |
| | | |
| | | SvrManager.getInstance().sendCmd(cmd,s); |
| | | } |
| | | |
| | |
| | | import android.content.ServiceConnection; |
| | | import android.os.IBinder; |
| | | import android.os.RemoteException; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | |
| | | import java.util.LinkedList; |
| | |
| | | if (!checkRemoteIsNull()){ |
| | | try { |
| | | remoteInterface.SendCmd(cmd,s); |
| | | if(cmd == 0x8100){ |
| | | MyLog.i(TAG,"CMD="+ String.format("0x%x",cmd) +" contentLength:"+(!TextUtils.isEmpty(s)?s.length():0)); |
| | | }else{ |
| | | |
| | | MyLog.i(TAG,"CMD="+ String.format("0x%x",cmd) +" content:"+(!TextUtils.isEmpty(s)?s:"null")); |
| | | } |
| | | } catch (RemoteException e) { |
| | | e.printStackTrace(); |
| | | } |