- try {
- while (true) {
- if (dataInput.available() > 0) {
- //String msg = dataInput.readLine();
- LCDPrinter.print(Character.toChars(dataInput.read()).toString());
- }
- }
- }
- catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public static void SendMessage(String message){
- writer.println(message);
- writer.flush();
- }
-
- public static BTMemory getBTMemory(boolean master, final String rovername) {
- if (master) {
- return new BTMemory() {
- @Override
- public void setup() {
- //LCD.drawString("Create connection", 0, 0);
- BTConnector btconnector = new BTConnector();
- //LCD.drawString("BTConnector created", 0, 1);
- connection = btconnector.connect(rovername, NXTConnection.RAW);
- //LCD.drawString("Connection created", 0, 2);
- dataInput = connection.openDataInputStream();
- dataOutput = connection.openOutputStream();
- writer = new PrintWriter(dataOutput);
- //LCD.drawString("Input output created", 0, 3);