Search in sources :

Example 1 with LynxDiscoveryResponse

use of com.qualcomm.hardware.lynx.commands.standard.LynxDiscoveryResponse in project robotcode by OutoftheBoxFTC.

the class LynxUsbDeviceImpl method onLynxDiscoveryResponseReceived.

protected void onLynxDiscoveryResponseReceived(LynxDatagram datagram) {
    LynxDiscoveryResponse incomingResponse = new LynxDiscoveryResponse();
    incomingResponse.setSerialization(datagram);
    incomingResponse.loadFromSerialization();
    RobotLog.vv(TAG, "onLynxDiscoveryResponseReceived()... module#=%d isParent=%s", incomingResponse.getDiscoveredModuleAddress(), Boolean.toString(incomingResponse.isParent()));
    try {
        // Be paranoid about duplicates
        synchronized (this.discoveredModules) {
            if (!this.discoveredModules.containsKey(datagram.getSourceModuleAddress())) {
                RobotLog.vv(TAG, "discovered lynx module#=%d isParent=%s", incomingResponse.getDiscoveredModuleAddress(), Boolean.toString(incomingResponse.isParent()));
                LynxModuleMeta meta = new LynxModuleMeta(incomingResponse.getDiscoveredModuleAddress(), incomingResponse.isParent());
                discoveredModules.put(meta.getModuleAddress(), meta);
            }
        }
    } finally {
        RobotLog.vv(TAG, "...onLynxDiscoveryResponseReceived()");
    }
}
Also used : LynxModuleMeta(com.qualcomm.robotcore.hardware.LynxModuleMeta) LynxDiscoveryResponse(com.qualcomm.hardware.lynx.commands.standard.LynxDiscoveryResponse)

Aggregations

LynxDiscoveryResponse (com.qualcomm.hardware.lynx.commands.standard.LynxDiscoveryResponse)1 LynxModuleMeta (com.qualcomm.robotcore.hardware.LynxModuleMeta)1