Search in sources :

Example 31 with BowlerDatagram

use of com.neuronrobotics.sdk.common.BowlerDatagram in project java-bowler by NeuronRobotics.

the class UDPBowlerConnection method getAllAddresses.

/**
 * @return
 */
public ArrayList<InetAddress> getAllAddresses() {
    if (addrs == null) {
        addrs = new ArrayList<InetAddress>();
        try {
            // Generate a ping command
            BowlerDatagram ping = BowlerDatagramFactory.build(new MACAddress(), new PingCommand());
            ping.setUpstream(false);
            Log.info("Sending synchronization ping: \n" + ping);
            // send it to the UDP socket
            write(ping.getBytes());
            // wait for all devices to report back
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    return addrs;
}
Also used : MACAddress(com.neuronrobotics.sdk.common.MACAddress) BowlerDatagram(com.neuronrobotics.sdk.common.BowlerDatagram) IOException(java.io.IOException) InetAddress(java.net.InetAddress) PingCommand(com.neuronrobotics.sdk.commands.bcs.core.PingCommand)

Aggregations

BowlerDatagram (com.neuronrobotics.sdk.common.BowlerDatagram)31 ByteList (com.neuronrobotics.sdk.common.ByteList)9 MACAddress (com.neuronrobotics.sdk.common.MACAddress)5 IOException (java.io.IOException)5 InvalidResponseException (com.neuronrobotics.sdk.common.InvalidResponseException)4 ArrayList (java.util.ArrayList)4 PingCommand (com.neuronrobotics.sdk.commands.bcs.core.PingCommand)3 GetChannelModeCommand (com.neuronrobotics.sdk.commands.bcs.io.GetChannelModeCommand)2 GetValueCommand (com.neuronrobotics.sdk.commands.bcs.io.GetValueCommand)2 InvalidConnectionException (com.neuronrobotics.sdk.common.InvalidConnectionException)2 RpcEncapsulation (com.neuronrobotics.sdk.common.RpcEncapsulation)2 PIDCommandException (com.neuronrobotics.sdk.pid.PIDCommandException)2 SocketException (java.net.SocketException)2 Test (org.junit.Test)2 GetChannelModeListCommand (com.neuronrobotics.sdk.commands.bcs.io.GetChannelModeListCommand)1 GetDyIOChannelCountCommand (com.neuronrobotics.sdk.commands.bcs.io.GetDyIOChannelCountCommand)1 SetChannelModeCommand (com.neuronrobotics.sdk.commands.bcs.io.setmode.SetChannelModeCommand)1 ConfigurePIDCommand (com.neuronrobotics.sdk.commands.bcs.pid.ConfigurePIDCommand)1 ControlAllPIDCommand (com.neuronrobotics.sdk.commands.bcs.pid.ControlAllPIDCommand)1 ConfigureDynamicPIDCommand (com.neuronrobotics.sdk.commands.bcs.pid.DyPID.ConfigureDynamicPIDCommand)1