极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 151|回复: 2

8F328P-U 不用Arduino上載 hex 檔

[复制链接]
发表于 2019-1-4 17:21:49 | 显示全部楼层 |阅读模式
步驟:
1) 把附檔解壓後放到桌面,
2) 把要上載的hex檔更名為 upload.hex,放在 "8F328U_Upload_Hex" 文件夾內(如已有同名文件,直接取代),
3) 執行 run.bat


回复

使用道具 举报

 楼主| 发表于 2019-1-4 17:27:00 | 显示全部楼层
壓縮檔上傳不了!
回复 支持 反对

使用道具 举报

 楼主| 发表于 前天 17:54 | 显示全部楼层
使用 Processing範例

//How to upload an arduino sketch from java / processing?
// https://arduino.stackexchange.co ... rom-java-processing

import java.io.*;

void setup(){
    String ArduinoPath = "C:\\Users\\User\\Desktop\\8F328U_Upload_Hex";
String hexPath = "C:\\Users\\User\\Desktop/8F328U_Upload_Hex/upload.hex";
    String port = "COM8";
    runCommand(new String[]{ArduinoPath+"/bin/avrdude", "-C"+ArduinoPath+"/avrdude.conf","-v","-patmega328p","-carduino","-PCOM8","-b57600","-D","-Uflash:w:"+hexPath+":i"});
  }
  void runCommand(String[] cmd){

    String s = null;

    try {

      Process p = Runtime.getRuntime().exec(cmd);
      BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
      BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));

      // read the output from the command
      System.out.println("command out:\n");
      while ( (s = stdInput.readLine ()) != null) System.out.println(s);
      System.out.println("errors (if any):\n");
      while ( (s = stdError.readLine ()) != null) System.out.println(s);

    }catch (IOException e) {
      System.out.println("something went wrong: \n");
      e.printStackTrace();
    }
  }
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊 ( 浙ICP备09023225号 )

GMT+8, 2019-1-17 05:21 , Processed in 0.044840 second(s), 24 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表