summaryrefslogtreecommitdiff
path: root/roombacomm-client/src/com/hackingroomba/roombacomm/IdoTest1.java
blob: 0bb2d2671d7f9188bbb987fb64794717e368facd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.hackingroomba.roombacomm;

public class IdoTest1 {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {

		RoombaCommSerial roomba = new RoombaCommSerial();
		    String[] ports = roomba.listPorts();               // if implemented
		    roomba.setProtocol("OI");
		    roomba.connect("/dev/ttyUSB0");
		    roomba.startup();
		    //roomba.control();
//		    roomba.send(new byte[] {(byte) 136, (byte) 9});
//		    Thread.sleep((long)15);
//		    roomba.send(new byte[] {(byte) 141, (byte) 1});
		    //roomba.send(9);
	        //roomba.max();
	        //roomba.send(new int[] {( 136, 0});
			//
		    byte cmd[] = { (byte)roomba.SENSORS, (byte)0};
		    boolean success = roomba.send(cmd);
		    String s = roomba.getSensorsAsString();
		    System.out.println(s);
		    //boolean success = roomba.updateSensors();
		    //roomba.send(new byte[] {(byte)148, (byte)1, (byte)2});
		    //roomba.getSensorData(4);
		    //roomba.sensors(2);
		    roomba.send(new byte[] {(byte) 136, (byte) 255});
		    roomba.disconnect();

	}

}