Exemplo n.º 1
0
    bool ReadEeprom_v2::Response::matchFailResponse(const WirelessPacket& packet)
    {
        WirelessPacket::Payload payload = packet.payload();

        //check the main bytes of the packet
        if(packet.deliveryStopFlags().toInvertedByte() != 0x07 ||                    //delivery stop flag
           packet.type() != WirelessPacket::packetType_nodeErrorReply ||             //app data type
           packet.nodeAddress() != m_nodeAddress ||                                  //node address
           payload.size() != 0x05 ||                                                 //payload length
           payload.read_uint16(0) != WirelessProtocol::cmdId_readEeprom_v2 ||        //command ID
           payload.read_uint16(2) != m_eepromAddress                                 //eeprom address
           )
        {
            //failed to match some of the bytes
            return false;
        }

        //if we made it here, the packet matches the response pattern

        //get the error code from the response
        m_success = false;
        m_errorCode = static_cast<WirelessPacket::ResponseErrorCode>(packet.payload().read_uint8(4));

        return true;
    }
    bool BaseStation_ReadEeprom_v2::Response::matchFailResponse(const WirelessPacket& packet)
    {
        WirelessPacket::Payload payload = packet.payload();

        //check the main bytes of the packet
        if(packet.deliveryStopFlags().toInvertedByte() != 0x07 ||                        //delivery stop flag
           packet.type() != WirelessPacket::packetType_baseErrorReply ||                 //app data type
           packet.nodeAddress() != WirelessProtocol::BASE_STATION_ADDRESS ||             //node address
           payload.size() != 0x05 ||                                                     //payload length
           payload.read_uint16(0) != WirelessProtocol::cmdId_base_readEeprom_v2 ||       //command ID
           payload.read_uint16(2) != m_eepromAddress                                     //eeprom address
           )
        {
            //failed to match some of the bytes
            return false;
        }

        //read the error code from the response
        m_errorCode = static_cast<WirelessPacket::ResponseErrorCode>(payload.read_uint8(4));

        //set the result to failure
        m_success = false;

        return true;
    }
    bool StartNonSyncSampling_v2::Response::match(const WirelessPacket& packet)
    {
        WirelessPacket::Payload payload = packet.payload();

        //check the main bytes of the packet
        if( packet.deliveryStopFlags().toInvertedByte() != 0x07 ||                      //delivery stop flag
            packet.type() != WirelessPacket::packetType_nodeSuccessReply ||             //app data type
            packet.nodeAddress() != m_nodeAddress ||                                    //node address
            payload.size() != 0x02 ||                                                   //payload length
            payload.read_uint16(0) != WirelessProtocol::cmdId_startLdc_v2               //Command ID
            )            
        {
            //failed to match some of the bytes
            return false;
        }

        //if we made it here, the packet matches the response pattern
        m_success = true;

        //we have fully matched the response
        m_fullyMatched = true;

        //notify that the response was matched
        m_matchCondition.notify();

        return true;
    }
Exemplo n.º 4
0
    bool ReadEeprom_v2::Response::matchSuccessResponse(const WirelessPacket& packet)
    {
        WirelessPacket::Payload payload = packet.payload();

        uint8 dsf = packet.deliveryStopFlags().toInvertedByte();

        //check the main bytes of the packet
        if((dsf != 0x07 && dsf != 0x00) ||                                      //delivery stop flag (Unfortunately some nodes report 0x00 and some report 0x07)
           packet.type() != 0x00 ||                                             //app data type
           packet.nodeAddress() != m_nodeAddress ||                             //node address
           payload.size() != 0x06 ||                                            //payload length
           payload.read_uint16(0) != WirelessProtocol::cmdId_readEeprom_v2 ||   //command ID
           payload.read_uint16(2) != m_eepromAddress                            //eeprom address
           )
        {
            //failed to match some of the bytes
            return false;
        }

        //if we made it here, the packet matches the response pattern

        //get the eeprom value from the response
        m_success = true;
        m_errorCode = WirelessPacket::error_none;
        m_eepromValue = packet.payload().read_uint16(4);

        return true;
    }
Exemplo n.º 5
0
    bool LongPing::Response::match(const WirelessPacket& packet)
    {
        WirelessPacket::Payload payload = packet.payload();

        //check the main bytes of the packet
        if( packet.deliveryStopFlags().toInvertedByte() != 0x07 ||    //delivery stop flag
            packet.type() != 0x02 ||                                  //app data type
            packet.nodeAddress() != m_nodeAddress ||                  //node address
            payload.size() != 0x02 ||                                 //payload length
            payload.read_uint16(0) != 0x0000
            )            
        {
            //failed to match some of the bytes
            return false;
        }

        //if we made it here, the packet matches the response pattern

        //store the node and base RSSI values with the PingResponse
        m_result = PingResponse::ResponseSuccess(packet.nodeRSSI(), packet.baseRSSI());

        //we have fully matched the response
        m_fullyMatched = true;

        //notify that the response was matched
        m_matchCondition.notify();

        m_success = true;

        return true;
    }
Exemplo n.º 6
0
bool AutoCal::Response::match_nodeReceived(const WirelessPacket& packet)
{
    WirelessPacket::Payload payload = packet.payload();

    //check the main bytes of the packet
    if(packet.deliveryStopFlags().toByte() != 0x07 ||	//delivery stop flag
            packet.type() != 0x20 ||							//app data type
            packet.nodeAddress() != m_nodeAddress ||			//node address
            payload.size() != 0x07							//payload length
      )
    {
        //failed to match some of the bytes
        return false;
    }

    //Command ID
    if(payload.read_uint16(0) != 0x0064)
    {
        return false;
    }

    //if the status flag is success (0)
    if(payload.read_uint8(2) == 0)
    {
        m_calStarted = true;

        //only want to read the time until completion if the cal has started
        m_timeUntilCompletion = payload.read_float(3);
    }

    return true;
}
    bool BaseStation_RfSweepStart::Response::matchSuccessResponse(const WirelessPacket& packet)
    {
        WirelessPacket::Payload payload = packet.payload();

        //check the main bytes of the packet
        if(packet.deliveryStopFlags().toInvertedByte() != 0x07 ||                   //delivery stop flag
           packet.type() != WirelessPacket::packetType_baseSuccessReply ||          //app data type
           packet.nodeAddress() != WirelessProtocol::BASE_STATION_ADDRESS ||        //node address
           payload.size() != 16 ||                                                  //payload length
           payload.read_uint16(0) != WirelessProtocol::cmdId_base_rfScan ||         //command ID
           payload.read_uint16(2) != m_options ||
           payload.read_uint32(4) != m_min ||
           payload.read_uint32(8) != m_max ||
           payload.read_uint32(12) != m_interval
           )
        {
            //failed to match some of the bytes
            return false;
        }

        //set the result to success
        m_success = true;

        return true;
    }
    bool BaseStation_SetBeacon_v2::Response::matchFailResponse(const WirelessPacket& packet)
    {
        WirelessPacket::Payload payload = packet.payload();

        //check the main bytes of the packet
        if(packet.deliveryStopFlags().toInvertedByte() != 0x07 ||                        //delivery stop flag
           packet.type() != WirelessPacket::packetType_baseErrorReply ||                 //app data type
           packet.nodeAddress() != WirelessProtocol::BASE_STATION_ADDRESS ||             //node address
           payload.size() != 0x07 ||                                                     //payload length
           payload.read_uint16(0) != WirelessProtocol::cmdId_base_setBeacon ||           //command ID
           payload.read_uint32(2) != m_beaconStartTime                                   //beacon timestamp
           )
        {
            //failed to match some of the bytes
            return false;
        }

        //Not doing anything with the error code as of now
        //uint8 errorCode = payload.read_uint8(6);

        //set the result to failure
        m_success = false;

        return true;
    }
Exemplo n.º 9
0
    bool BaseStation_Ping_v2::Response::match(const WirelessPacket& packet)
    {
        WirelessPacket::Payload payload = packet.payload();

        //check the main bytes of the packet
        if(packet.deliveryStopFlags().toInvertedByte() != 0x07 ||               //delivery stop flag
           packet.type() != 0x31 ||                                             //app data type
           packet.nodeAddress() != WirelessProtocol::BASE_STATION_ADDRESS ||    //node address
           payload.size() != 0x02 ||                                            //payload length
           payload.read_uint16(0) != WirelessProtocol::cmdId_basePing_v2        //command id
           )
        {
            //failed to match some of the bytes
            return false;
        }

        //if we made it here, the packet matches the response pattern

        //the ping was a success
        m_success = true;

        //we have fully matched the response
        m_fullyMatched = true;

        //notify that the response was matched
        m_matchCondition.notify();

        return true;
    }
    bool AsyncDigitalAnalogPacket::integrityCheck(const WirelessPacket& packet)
    {
        WirelessPacket::Payload payload = packet.payload();

        //verify the payload size
        if(payload.size() < PAYLOAD_OFFSET_CHANNEL_DATA)
        {
            //payload is too small to be valid
            return false;
        }

        //verify the delivery stop flags are what we expected
        if(!packet.deliveryStopFlags().pc)
        {
            //packet not intended for the PC
            return false;
        }

        //read the data type
        uint8 dataType = payload.read_uint8(PAYLOAD_OFFSET_DATA_TYPE);

        //verify the data type
        if(dataType < WirelessTypes::dataType_first || dataType > WirelessTypes::dataType_last)
        {
            //the data type is invalid
            return false;
        }

        //verify the packet type is correct
        if(packet.type() != packetType_AsyncDigitalAnalog)
        {
            //packet is not an Async Digital packet
            return false;
        }

        //calculate the number of active channels
        uint32 channels = ChannelMask(payload.read_uint16(PAYLOAD_OFFSET_CHANNEL_MASK)).count();

        //check that there are active channels
        if(channels == 0)
        {
            //no active channels
            return false;
        }

        //packet looks valid
        return true;
    }
Exemplo n.º 11
0
	bool HclSmartBearing_RawPacket::integrityCheck_baseBoard(const WirelessPacket::Payload& payload)
	{
		//check payload size is exactly correct
		if(payload.size() != 75)
		{
			return false;
		}

		//packet looks valid
		return true;
	}
Exemplo n.º 12
0
bool AutoCal::Response::match_shmLink(const WirelessPacket& packet)
{
    WirelessPacket::Payload payload = packet.payload();

    std::size_t payloadLen = payload.size();

    //check the main bytes of the packet
    if(packet.deliveryStopFlags().toByte() != 0x07 ||		//delivery stop flag
            packet.type() != WirelessPacket::packetType_reply ||	//app data type
            packet.nodeAddress() != m_nodeAddress ||				//node address
            payloadLen != 22										//payload length
      )
    {
        //failed to match some of the bytes
        return false;
    }

    //Command ID
    if(payload.read_uint16(0) != 0x0064)
    {
        return false;
    }

    //Pass/Fail Flag
    m_completionFlag = static_cast<WirelessTypes::AutoCalCompletionFlag>(payload.read_uint8(2));

    //Info Bytes
    for(std::size_t i = 3; i < payloadLen; ++i)
    {
        //add all of the payload info bytes to m_infoBytes
        m_infoBytes.push_back(payload.read_uint8(i));
    }

    //setting success to true if it got this packet, even if the cals applied might be bad
    m_success = true;

    return true;
}
Exemplo n.º 13
0
    bool AutoBalance_v2::Response::match(const WirelessPacket& packet)
    {
        WirelessPacket::Payload payload = packet.payload();

        //check the main bytes of the packet
        if(packet.deliveryStopFlags().toInvertedByte() != 0x07 ||               //delivery stop flag
           packet.type() != WirelessPacket::packetType_nodeSuccessReply ||      //app data type
           packet.nodeAddress() != m_nodeAddress ||                             //node address
           payload.size() != 0x10 ||                                            //payload length
           payload.read_uint16(0) != WirelessProtocol::cmdId_autoBalance_v2 ||  //command id
           payload.read_uint8(2) != m_channelNumber ||                          //channel number (echo)
           payload.read_float(3) != m_targetPercent                             //target percent (echo)
           )
        {
            //failed to match some of the bytes
            return false;
        }

        //if we made it here, the packet matches the response pattern

        //error code
        m_result.m_errorCode = static_cast<WirelessTypes::AutoBalanceErrorFlag>(payload.read_uint8(7));

        //sampled value
        m_result.m_percentAchieved = payload.read_float(8);

        //hardware offset
        m_result.m_hardwareOffset = static_cast<uint16>(payload.read_uint32(12));

        switch(m_result.m_errorCode)
        {
            case WirelessTypes::autobalance_success:
            case WirelessTypes::autobalance_maybeInvalid:
                m_success = true;

            default:
                m_success = false;
        }

        //we have fully matched the response
        m_fullyMatched = true;

        //notify that the response was matched
        m_matchCondition.notify();

        return true;
    }
Exemplo n.º 14
0
    bool BufferedLdcPacket::integrityCheck(const WirelessPacket& packet)
    {
        WirelessPacket::Payload payload = packet.payload();

        //verify the payload size
        if(payload.size() < PAYLOAD_OFFSET_CHANNEL_DATA)
        {
            //payload must be at least a certain length
            return false;
        }

        //verify the app id
        if(payload.read_uint8(PAYLOAD_OFFSET_APP_ID) != APP_ID_VAL)
        {
            //application id is incorrect
            return false;
        }

        //verify the delivery stop flags are what we expected
        if(!packet.deliveryStopFlags().pc)
        {
            //packet not intended for the PC
            return false;
        }

        //read the data type
        uint8 dataType = payload.read_uint8(PAYLOAD_OFFSET_DATA_TYPE);

        //verify the data type
        if(dataType < WirelessTypes::dataType_first || dataType > WirelessTypes::dataType_last)
        {
            //the data type is invalid
            return false;
        }

        //verify the packet type is correct
        if(packet.type() != packetType_BufferedLDC)
        {
            //packet is not a Buffered LDC packet
            return false;
        }

        //calculate the number of active channels
        uint32 channels = ChannelMask(payload.read_uint8(PAYLOAD_OFFSET_CHANNEL_MASK)).count();

        //calculate the size of a single data point
        uint32 dataSize = WirelessTypes::dataTypeSize(static_cast<WirelessTypes::DataType>(dataType));

        uint32 recordSize = channels * dataSize;

        //if record size is zero, something is wrong. Bail now before divide by zero
        if(recordSize <= 0)
        {
            return false;
        }

        //the number of channel data bytes
        size_t numChannelBytes = payload.size() - PAYLOAD_OFFSET_CHANNEL_DATA;

        //verify that there are actually channel data bytes
        if(numChannelBytes == 0)
        {
            return false;
        }

        //verify the payload contains a correct number of bytes
        if(numChannelBytes % recordSize != 0)
        {
            return false;
        }

        //packet looks valid
        return true;
    }
Exemplo n.º 15
0
    bool DiagnosticPacket::integrityCheck(const WirelessPacket& packet)
    {
        WirelessPacket::Payload payload = packet.payload();

        //verify the minimum payload size
        if(payload.size() < 7)
        {
            return false;
        }

        //verify the delivery stop flags are what we expected
        if(!packet.deliveryStopFlags().pc)
        {
            //packet not intended for the PC
            return false;
        }

        //verify the packet type is correct
        if(packet.type() != packetType_diagnostic)
        {
            //packet is not an LDC packet
            return false;
        }

        //verify packet interval
        if(payload.read_uint16(2) == 0)
        {
            //packet interval should never be 0 (invalid payload)
            return false;
        }

        DataBuffer bytes(payload);

        //skip the sample rate and tick bytes
        bytes.skipBytes(4);

        //verify the payload is correct
        while(bytes.moreToRead())
        {
            uint8 infoLen = bytes.read_uint8();

            if(infoLen == 0)
            {
                //no info length should be 0 (invalid payload)
                return false;
            }

            //verify we can read all the bytes in the length described
            if(bytes.bytesRemaining() < infoLen)
            {
                //can't read all the bytes (invalid payload)
                return false;
            }

            //skip passed the bytes being asked to read
            bytes.skipBytes(infoLen);
        }

        //packet looks valid
        return true;
    }