/dongfang_FC_rewrite_tool/src/dongfang/mkt/comm/FrameQueue.java |
---|
17,7 → 17,7 |
private final MKOutputStream output; |
// private List responseQueue; |
private ResponseFrame lastResponseFrame; |
private boolean doQueue = true; |
private volatile boolean doQueue = true; |
class Receiver extends Thread { |
public void run() { |
47,7 → 47,9 |
super(); |
this.input = new MKInputStream (in); |
this.output = new MKOutputStream(out); |
new Receiver().start(); |
Receiver r = new Receiver(); |
r.setDaemon(false); |
r.start(); |
} |
public void sendRequest(RequestFrame f) throws IOException { |
/dongfang_FC_rewrite_tool/src/dongfang/mkt/comm/MKInputStream.java |
---|
447,9 → 447,9 |
VersionResponseFrame f = new VersionResponseFrame(address); |
f.setSWMajor(base64InputStream.readByte()); |
f.setSWMinor(base64InputStream.readByte()); |
f.setSWPatch(base64InputStream.readByte()); |
f.setProtoMajor(base64InputStream.readByte()); |
f.setProtoMinor(base64InputStream.readByte()); |
f.setSWPatch(base64InputStream.readByte()); |
f.setHardwareErrors(base64InputStream.readBytes(5)); |
result = f; |
break; |
/dongfang_FC_rewrite_tool/src/dongfang/mkt/frames/ExternalControlRequestFrame.java |
---|
35,8 → 35,8 |
int frameNum; // unsigned byte. |
int argument; // unsigned byte. Called "config" in MK code. |
ExternalControlRequestFrame(int address) { |
super(address); |
public ExternalControlRequestFrame() { |
super(FC_ADDRESS); |
} |
public int[] getDigital() { |
/dongfang_FC_rewrite_tool/src/dongfang/mkt/frames/VersionResponseFrame.java |
---|
89,6 → 89,8 |
} |
public String toString() { |
return getClass().getSimpleName() + ": SWMajor=" + SWMajor + ", SWMinor=" + SWMinor + ", SWPatch=" + SWPatch + ", protocolMajor="+protoMajor + ", protocolMinor=" + protoMinor; |
StringBuilder result = new StringBuilder(); |
result.append("SW=" + SWMajor + "." + SWMinor + "." + SWPatch + ", protocol=" + protoMajor + "." + protoMinor); |
result.append(); |
} |
} |
/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(); |
} |
} |