Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 1689 → Rev 1690

/dongfang_FC_rewrite_tool/src/dongfang/mkt/main/IMUConfigurator.java
79,10 → 79,13
private static void readConfiguration(String portIdentifier, String fileName) throws IOException {
IMUConfiguration cs = readConfiguration(portIdentifier);
if (cs != null) {
FileWriter fw = new FileWriter(fileName);
fw.write(cs.toXML());
fw.close();
if (fileName != null) {
FileWriter fw = new FileWriter(fileName);
fw.write(cs.toXML());
fw.close();
}
}
System.out.println(cs.toXML());
}
 
private static WriteIMUConfigurationRequestFrame parseXMLIMUConfiguration(InputStream input) throws IOException {
187,12 → 190,12
public static void main(String[] args) throws IOException {
if (!"r".equals(args[0]) && !"w".equals(args[0])) help();
if ("w".equals(args[0]) && (args.length!=2)) help();
if ("r".equals(args[0]) && (args.length!=2)) help();
if ("r".equals(args[0]) && (args.length>2)) help();
 
String portIdentifier = null;
if ("r".equals(args[0])) {
readConfiguration(portIdentifier, args[1]);
readConfiguration(portIdentifier, args.length<2 ? null : args[1]);
} else {
writeConfiguration(portIdentifier, args[1]);
}
/dongfang_FC_rewrite_tool/src/dongfang/mkt/main/RCDump.java
0,0 → 1,81
package dongfang.mkt.main;
 
import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Date;
 
import dongfang.mkt.comm.FrameQueue;
import dongfang.mkt.comm.MKConnection;
import dongfang.mkt.comm.serial.RXTXSerialPort;
import dongfang.mkt.frames.ReadRCChannelsRequestFrame;
import dongfang.mkt.frames.ReadRCChannelsResponseFrame;
 
public class RCDump {
private static final PrintStream STDERR = System.out;
 
interface Logger {
void start(String timestamp) throws IOException;
void log(ReadRCChannelsResponseFrame f, long timestamp) throws IOException;
void end() throws IOException;
}
 
static class ConsoleRCLogger implements Logger {
public void start(String logId) {}
 
public void log(ReadRCChannelsResponseFrame f, long timestamp) {
if (f == null) {
System.out.println("Oops, null response frame.");
return;
}
System.out.println(f);
}
 
public void end() {}
}
 
private static Logger createLogger() throws IOException {
Logger consoleLogger = new ConsoleRCLogger();
return consoleLogger;
}
 
private void rcDump(final FrameQueue q, final Logger logger) throws IOException {
long timer = 0;
ReadRCChannelsRequestFrame f = new ReadRCChannelsRequestFrame();
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
Long firsttimestamp = null;
while (!in.ready())
try {
long now = System.currentTimeMillis();
if (now - timer > 500) {
timer = now;
q.sendRequest(f);
ReadRCChannelsResponseFrame rf = (ReadRCChannelsResponseFrame) q.getResponseFor(f, 500);
long timestamp = System.currentTimeMillis();
if (firsttimestamp == null) {
firsttimestamp = timestamp;
timestamp = 0;
} else {
timestamp -= firsttimestamp;
}
logger.log(rf, timestamp);
}
} catch (IOException ex) {
STDERR.println(ex);
}
}
 
public static void main(String[] args) throws IOException {
RCDump test = new RCDump();
RXTXSerialPort _port = new RXTXSerialPort();
_port.init(null);
FrameQueue q = new FrameQueue(_port);
Logger logger = createLogger();
logger.start(new Date().toGMTString());
test.rcDump(q, logger);
logger.end();
}
}