当前位置: 首页>>代码示例>>C++>>正文


C++ WirelessPacket类代码示例

本文整理汇总了C++中WirelessPacket的典型用法代码示例。如果您正苦于以下问题:C++ WirelessPacket类的具体用法?C++ WirelessPacket怎么用?C++ WirelessPacket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了WirelessPacket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

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;
}
开发者ID:estump,项目名称:MSCL,代码行数:32,代码来源:AutoCal.cpp

示例2:

    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;
    }
开发者ID:LORD-MicroStrain,项目名称:MSCL,代码行数:25,代码来源:BaseStation_RfSweepStart.cpp

示例3:

    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;
    }
开发者ID:LORD-MicroStrain,项目名称:MSCL,代码行数:27,代码来源:StartNonSyncSampling_v2.cpp

示例4:

    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;
    }
开发者ID:LORD-MicroStrain,项目名称:MSCL,代码行数:28,代码来源:ReadEeprom_v2.cpp

示例5:

    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;
    }
开发者ID:LORD-MicroStrain,项目名称:MSCL,代码行数:25,代码来源:BaseStation_SetBeacon_v2.cpp

示例6:

    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;
    }
开发者ID:LORD-MicroStrain,项目名称:MSCL,代码行数:25,代码来源:BaseStation_ReadEeprom_v2.cpp

示例7: integrityCheck

    bool HclSmartBearing_CalPacket::integrityCheck(const WirelessPacket& packet)
    {
        //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_HclSmartBearing_Calibrated)
        {
            //packet is not a Sync Sampling packet
            return false;
        }

        const WirelessPacket::Payload& payload = packet.payload();

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

        return true;
    }
开发者ID:LORD-MicroStrain,项目名称:MSCL,代码行数:26,代码来源:HclSmartBearing_CalPacket.cpp

示例8:

    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;
    }
开发者ID:LORD-MicroStrain,项目名称:MSCL,代码行数:29,代码来源:BaseStation_Ping_v2.cpp

示例9: switch

    bool WirelessParser::isDuplicate(const WirelessPacket& packet)
    {
        uint16 uniqueId;
        uint32 packetsNode = packet.nodeAddress();

        //check the packet type
        switch(packet.type())
        {
            //get the unique id depending on the type of packet
            case WirelessPacket::packetType_LDC:                    uniqueId = LdcPacket::getUniqueId(packet);                      break;
            case WirelessPacket::packetType_SyncSampling:           uniqueId = SyncSamplingPacket::getUniqueId(packet);             break;
            case WirelessPacket::packetType_BufferedLDC:            uniqueId = BufferedLdcPacket::getUniqueId(packet);              break;
            case WirelessPacket::packetType_LDC_16ch:               uniqueId = LdcPacket_16ch::getUniqueId(packet);                 break;
            case WirelessPacket::packetType_SyncSampling_16ch:      uniqueId = SyncSamplingPacket_16ch::getUniqueId(packet);        break;
            case WirelessPacket::packetType_BufferedLDC_16ch:       uniqueId = BufferedLdcPacket_16ch::getUniqueId(packet);         break;
            case WirelessPacket::packetType_AsyncDigital:           uniqueId = AsyncDigitalPacket::getUniqueId(packet);             break;
            case WirelessPacket::packetType_AsyncDigitalAnalog:     uniqueId = AsyncDigitalAnalogPacket::getUniqueId(packet);       break;
            case WirelessPacket::packetType_diagnostic:             uniqueId = DiagnosticPacket::getUniqueId(packet);               break;
            case WirelessPacket::packetType_roller:                 uniqueId = RollerPacket::getUniqueId(packet);                   break;

            //isn't a valid data packet that has a unique id, so we can't check for duplicates
            case WirelessPacket::packetType_nodeDiscovery:
            case WirelessPacket::packetType_nodeDiscovery_v2:
            case WirelessPacket::packetType_nodeDiscovery_v3:
            case WirelessPacket::packetType_nodeDiscovery_v4:
            case WirelessPacket::packetType_SHM:
            case WirelessPacket::packetType_beaconEcho:
            case WirelessPacket::packetType_rfScanSweep:
            default:
                return false;
        }

        //if we found the packet's node address in the lastPacketMap
        if(m_lastPacketMap.find(packetsNode) != m_lastPacketMap.end())
        {
            //if the unique id in the lastPacketMap matches the uniqueId from this packet
            if(m_lastPacketMap[packetsNode] == uniqueId)
            {
                //it is a duplicate packet
                return true;
            }
        }

        //update or set m_lastPacketMap's uniqueId for this node
        m_lastPacketMap[packetsNode] = uniqueId;

        //it is not a duplicate packet
        return false;    
    }
开发者ID:fsaks,项目名称:MSCL,代码行数:49,代码来源:WirelessParser.cpp

示例10: buildWriteEepromResponse

WirelessPacket buildWriteEepromResponse(int nodeAddress)
{
	Bytes payload;
	payload.push_back(0x00);
	payload.push_back(0x04);

	//build the correct packet response first
	WirelessPacket packet;
	packet.deliveryStopFlags(DeliveryStopFlags::fromByte(0x00));
	packet.type(static_cast<WirelessPacket::PacketType>(0x00));
	packet.nodeAddress(nodeAddress);
	packet.payload(payload);

	return packet;
}
开发者ID:estump,项目名称:MSCL,代码行数:15,代码来源:Test_WriteEeprom.cpp

示例11: buildAutoCalNodeRecResponse

WirelessPacket buildAutoCalNodeRecResponse(int nodeAddress)
{
	ByteStream payload;
	payload.append_uint16(0x0064);	//cmd id
	payload.append_uint8(0x00);	//status flag
	payload.append_float(5.0f);	//time to completion

	WirelessPacket packet;
	packet.deliveryStopFlags(DeliveryStopFlags::fromByte(0x07));
	packet.type(WirelessPacket::packetType_NodeReceived);
	packet.nodeAddress(nodeAddress);
	packet.payload(payload.data());

	return packet;
}
开发者ID:estump,项目名称:MSCL,代码行数:15,代码来源:Test_AutoCal.cpp

示例12: integrityCheck

    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;
    }
开发者ID:LORD-MicroStrain,项目名称:MSCL,代码行数:48,代码来源:AsyncDigitalAnalogPacket.cpp

示例13: buildSyncSamplingResponse

WirelessPacket buildSyncSamplingResponse(uint16 nodeAddress)
{
    Bytes payload;
    payload.push_back(0x00);
    payload.push_back(0x3B);
    payload.push_back(0x00);

    //build the correct packet response first
    WirelessPacket packet;
    packet.deliveryStopFlags(DeliveryStopFlags::fromInvertedByte(0x07));
    packet.type(static_cast<WirelessPacket::PacketType>(0x00));
    packet.nodeAddress(nodeAddress);
    packet.payload(payload);

    return packet;
}
开发者ID:LORD-MicroStrain,项目名称:MSCL,代码行数:16,代码来源:Test_StartSyncSampling.cpp

示例14: number

    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;
    }
开发者ID:fsaks,项目名称:MSCL,代码行数:47,代码来源:AutoBalance_v2.cpp

示例15: integrityCheck

	bool HclSmartBearing_RawPacket::integrityCheck(const WirelessPacket& packet)
	{
		//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_HclSmartBearing_Raw)
		{
			//packet is not a Sync Sampling packet
			return false;
		}

		const WirelessPacket::Payload& payload = packet.payload();

		//verify the payload size
		if(payload.size() < 4)
		{
			//each of these packets has at least the 4 main bytes in its header
			return false;
		}

		//read the app id
		RawPacketId appId = static_cast<RawPacketId>(payload.read_uint8(PAYLOAD_OFFSET_APP_ID));

		switch(appId)
		{
			case rawPacket_baseBoard:
				return integrityCheck_baseBoard(payload);

			case rawPacket_strainBoard:
				//TODO: parse the strain board packet
				return false;

			case rawPacket_inertialBoard:
				//TODO: parse the inertial board packet
				return false;

			default:
				//invalid app id
				return false;
		}
	}
开发者ID:estump,项目名称:MSCL,代码行数:46,代码来源:HclSmartBearing_RawPacket.cpp


注:本文中的WirelessPacket类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。