Skip to content

Commit

Permalink
added simple java test
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge committed May 31, 2016
1 parent a7c0013 commit 7fe4ace
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pymavlink/generator/java/examples/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
all: build

build:
mkdir -p com/MAVLink
mavgen.py --lang Java --wire-protocol=1.0 ../../../../message_definitions/v1.0/ardupilotmega.xml -o com/MAVLink
mkdir -p build
javac -d build test.java com/MAVLink/*.java com/MAVLink/common/*.java com/MAVLink/ardupilotmega/*.java

clean:
rm -rf build com/MAVLink
32 changes: 32 additions & 0 deletions pymavlink/generator/java/examples/test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import com.MAVLink.MAVLinkPacket;
import com.MAVLink.common.*;
import com.MAVLink.Parser;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class test {

public static void main(String[] args) {
Parser mavParser = new Parser();
try {
FileInputStream tlog = new FileInputStream(args[0]);
try {
while(tlog.available() > 0) {
MAVLinkPacket packet = mavParser.mavlink_parse_char(tlog.read());
if(packet != null){
System.out.println("msgid: " + packet.msgid);
}
}
System.out.println("End tlog");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

0 comments on commit 7fe4ace

Please sign in to comment.