java—printwriter;我只能把我的第一个命令发送给阿杜伊诺的连环部队

yacmzcpb  于 2021-06-27  发布在  Java
关注(0)|答案(0)|浏览(197)

这是我的问题。我正在做一台机器,java程序通过arduino的serial.read()函数来控制arduino。ı为了与arduino通信,我使用了“printwriter和GetOutputStream”。我的问题是:“为什么我可以只发送一个命令,当我点击按钮?我想把这个列表中的每个列表成员一个接一个地发送给“我该怎么做,请帮忙”

private void otomatikmoddenemebutonuActionPerformed(java.awt.event.ActionEvent evt) {                                                        

try {

    BufferedReader bufReader = new BufferedReader(new FileReader("E:\\DenemeOtomatikKomutlar.txt"));
    ArrayList<String> listOfLines = new ArrayList<>();
    String line = bufReader.readLine(); 
    while (line != null) {
        listOfLines.add(line); line = bufReader.readLine(); 
    PrintWriter output = new PrintWriter(chosenPort.getOutputStream());

    for (int i = 0; i < listOfLines.size(); i++) {

        output.println(listOfLines.get(i));
        output.flush();

                 otodenemeTF.setText(listOfLines.get(3));

        }
    }
 bufReader.close();

} catch (FileNotFoundException ex) {
    Logger.getLogger(PaintMixer_JogModu.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
    Logger.getLogger(PaintMixer_JogModu.class.getName()).log(Level.SEVERE, null, ex);
} 
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题