Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 1558 → Rev 1559

/dongfang_FC_rewrite_tool/src/dongfang/mkt/main/UniversalConfigurator.java
31,7 → 31,7
private static void configure(UniversalWriteParamSetRequestFrame frame,
int parameterSetNumber) throws IOException {
MKCommPort port = new RXTXSerialPort();
port.init("COM10");
port.init(null);
FrameQueue q = new FrameQueue(port);
 
frame.setConfigurationSetNumber(parameterSetNumber);
61,7 → 61,31
configure(frame, parameterSetNumber);
}
 
private static ConfigSet readConfiguration(int parameterSetNumber)
private static ConfigSet readConfiguration(int parameterSetNumber) throws IOException {
MKCommPort port = new RXTXSerialPort();
port.init(null);
FrameQueue q = new FrameQueue(port);
ConfigSet cs = null;
 
UniversalReadParamSetRequestFrame frame = new UniversalReadParamSetRequestFrame();
frame.setConfigurationSetNumber(parameterSetNumber);
q.sendRequest(frame);
UniversalReadParamSetResponseFrame r = (UniversalReadParamSetResponseFrame) q.getResponseFor(frame, 3000);
if (r == null) {
System.err.println("ERROR. Timeout waiting for response.");
} else {
int paramSetVersion = r.getConfigurationVersion();
int[] data = r.getData();
cs = ConfigSet.parseXMLConfigSet(paramSetVersion);
cs.setData(data);
System.out.println(cs.toXML());
}
q.kill();
return cs;
}
 
/*
private static ConfigSet simpleReadConfiguration(int parameterSetNumber)
throws IOException {
MKCommPort port = new RXTXSerialPort();
port.init(null);
78,14 → 102,13
} else {
int paramSetVersion = r.getConfigurationVersion();
int[] data = r.getData();
 
cs = ConfigSet.parseXMLConfigSet(paramSetVersion);
cs.setData(data);
// System.out.println(cs.toXML());
for (int i=0; i<data.length; i++)
System.out.println(data[i]);
}
q.kill();
return cs;
}
*/
 
private static void readConfiguration(String s_parameterSetNumber,
String fileName) throws IOException {
210,7 → 233,7
}
 
public static void main(String[] args) throws IOException {
if (args.length != 3 || (!"r".equals(args[0]) && !"w".equals(args[0]))) {
if (("w".equals(args[0]) && args.length != 3) || ("r".equals(args[0]) && args.length != 2)) {
System.err
.println("Usage: UniversalConfigurator r [parameter set number to read from] [filename to write to]");
System.err
219,7 → 242,7
}
 
if ("r".equals(args[0])) {
readConfiguration(args[1], args[2]);
readConfiguration(Integer.parseInt(args[1]));
} else {
writeConfiguration(args[1], args[2]);
}