Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 1697 → Rev 1698

/dongfang_FC_rewrite_tool/src/dongfang/mkt/main/SendCommand.java
0,0 → 1,35
package dongfang.mkt.main;
 
import java.io.IOException;
import java.io.PrintStream;
 
import dongfang.mkt.comm.FrameQueue;
import dongfang.mkt.comm.serial.RXTXSerialPort;
import dongfang.mkt.frames.ConfirmFrame;
import dongfang.mkt.frames.ExternalControlRequestFrame;
 
public class SendCommand {
private static final PrintStream STDERR = System.out;
private void sendCommand(final FrameQueue q, final int command) throws IOException {
ExternalControlRequestFrame f = new ExternalControlRequestFrame();
try {
f.setCommand(command);
f.setFrameNum(1); // 0 does not work.
q.sendRequest(f);
ConfirmFrame cf = (ConfirmFrame) q.getResponseFor(f, 2000);
System.out.println("Confirmed: " + cf);
} catch (IOException ex) {
STDERR.println(ex);
}
}
 
public static void main(String[] args) throws IOException {
SendCommand test = new SendCommand();
int command = Integer.parseInt(args[0]);
RXTXSerialPort _port = new RXTXSerialPort();
_port.init(null);
FrameQueue q = new FrameQueue(_port);
test.sendCommand(q, command);
q.kill();
}
}