• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sendPacket函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: sendPacket

void LLXfer::resendLastPacket()
{
	mRetries++;
	sendPacket(mPacketNum);
}
开发者ID:OS-Development,项目名称:VW.Kirsten,代码行数:5,代码来源:llxfer.cpp


示例2: sendPacket

void SshSendFacility::sendUserAuthServiceRequestPacket()
{
    m_outgoingPacket.generateUserAuthServiceRequestPacket();
    sendPacket();
}
开发者ID:mornelon,项目名称:QtCreator_compliments,代码行数:5,代码来源:sshsendfacility.cpp


示例3: preparePacket

AREXPORT bool ArDPPTU::init(void)
{
  preparePacket();
  myPacket.byteToBuf(ArDPPTUCommands::INIT);
  if (!sendPacket(&myPacket))
  {
    ArLog::log(ArLog::Terse, "ArDPPTU: Error sending INIT to PTU! (Write error?)");
    return false;
  }

  myPan = -1;  //myPan and myTilt set to -1 for initial positioning
  myTilt = -1;

  setMovePower(PAN, LOW);
  setMovePower(TILT, LOW);
  setHoldPower(PAN, OFF);
  setHoldPower(PAN, OFF);


  switch(myDeviceType) {
    case PANTILT_PTUD47:
      //Assuming default accel and slew rates
      myPanSlew = 40;
      myBasePanSlew = 40;
      myTiltSlew = 40;
      myBaseTiltSlew = 40;
      myPanAccel = 80;
      myTiltAccel = 80;
      break;
    case PANTILT_PTUD46:
    case PANTILT_DEFAULT:
    default:
      //Assuming default accel and slew rates
      myPanSlew = 40; // 1000 positions/sec
      myBasePanSlew = 40; // 1000 positions/sec
      myTiltSlew = 40; // 1000 positions/sec
      myBaseTiltSlew = 40; // 1000 positions/sec
      myPanAccel = 80; // 2000 positions/sec^2
      myTiltAccel = 80; // 2000 positions/sec^2
      break;
  }

  if(myDeviceType == PANTILT_DEFAULT)
  {
    // query resolution, conversion factors will be 
    // set again based on responses (replacing default value set 
    // in constructor)
    preparePacket();
    myPacket.byteToBuf('P');
    myPacket.byteToBuf('R');
    if(!sendPacket(&myPacket))
      ArLog::log(ArLog::Terse, "ArDPPTU: Warning: write error sending pan resolution query");
    // We can't distinguish PR and TR responses based on their content alone, so
    // we have to query pan resolution (PR), then after receiving resolution
    // response, query TR. (see readPacket() for TR).
	///@todo query the device for pan and tilt limits, and when response is received, call ArPTZ::setLimits() to change.
  }

  query();   // do first position query

  if (!panTilt(0,0))
    return false;

  myInit = true;

  return true;
}
开发者ID:PSU-Robotics-Countess-Quanta,项目名称:Countess-Quanta-Control,代码行数:67,代码来源:ArDPPTU.cpp


示例4: cycle

int cycle(Client* c, Timer* timer)
{
    // read the socket, see what work is due
    unsigned short packet_type = readPacket(c, timer);

    int len = 0,
        rc = SUCCESS;

    switch (packet_type)
    {
        case CONNACK:
        case PUBACK:
        case SUBACK:
            break;
        case PUBLISH:
        {
            MQTTString topicName;
            MQTTMessage msg;
            if (MQTTDeserialize_publish((unsigned char*)&msg.dup, (int*)&msg.qos, (unsigned char*)&msg.retained, (unsigned short*)&msg.id, &topicName,
               (unsigned char**)&msg.payload, (int*)&msg.payloadlen, c->readbuf, c->readbuf_size) != 1)
                goto exit;
            deliverMessage(c, &topicName, &msg);
            if (msg.qos != QOS0)
            {
                if (msg.qos == QOS1)
                    len = MQTTSerialize_ack(c->buf, c->buf_size, PUBACK, 0, msg.id);
                else if (msg.qos == QOS2)
                    len = MQTTSerialize_ack(c->buf, c->buf_size, PUBREC, 0, msg.id);
                if (len <= 0)
                    rc = FAILURE;
                   else
                       rc = sendPacket(c, len, timer);
                if (rc == FAILURE)
                    goto exit; // there was a problem
            }
            break;
        }
        case PUBREC:
        {
            unsigned short mypacketid;
            unsigned char dup, type;
            if (MQTTDeserialize_ack(&type, &dup, &mypacketid, c->readbuf, c->readbuf_size) != 1)
                rc = FAILURE;
            else if ((len = MQTTSerialize_ack(c->buf, c->buf_size, PUBREL, 0, mypacketid)) <= 0)
                rc = FAILURE;
            else if ((rc = sendPacket(c, len, timer)) != SUCCESS) // send the PUBREL packet
                rc = FAILURE; // there was a problem
            if (rc == FAILURE)
                goto exit; // there was a problem
            break;
        }
        case PUBCOMP:
            break;
        case PINGRESP:
            c->ping_outstanding = 0;
            break;
    }
    keepalive(c);
exit:
    if (rc == SUCCESS)
        rc = packet_type;
    return rc;
}
开发者ID:yanlunyao,项目名称:SmartStoreGateway,代码行数:63,代码来源:mt_client.c


示例5: sizeof

void AudioMixer::sendAudioEnvironmentPacket(SharedNodePointer node) {
    // Send stream properties
    bool hasReverb = false;
    float reverbTime, wetLevel;
    // find reverb properties
    for (int i = 0; i < _zoneReverbSettings.size(); ++i) {
        AudioMixerClientData* data = static_cast<AudioMixerClientData*>(node->getLinkedData());
        glm::vec3 streamPosition = data->getAvatarAudioStream()->getPosition();
        AABox box = _audioZones[_zoneReverbSettings[i].zone];
        if (box.contains(streamPosition)) {
            hasReverb = true;
            reverbTime = _zoneReverbSettings[i].reverbTime;
            wetLevel = _zoneReverbSettings[i].wetLevel;

            // Modulate wet level with distance to wall
            float MIN_ATTENUATION_DISTANCE = 2.0f;
            float MAX_ATTENUATION = -12; // dB
            glm::vec3 distanceToWalls = (box.getDimensions() / 2.0f) - glm::abs(streamPosition - box.calcCenter());
            float distanceToClosestWall = glm::min(distanceToWalls.x, distanceToWalls.z);
            if (distanceToClosestWall < MIN_ATTENUATION_DISTANCE) {
                wetLevel += MAX_ATTENUATION * (1.0f - distanceToClosestWall / MIN_ATTENUATION_DISTANCE);
            }
            break;
        }
    }
    
    AudioMixerClientData* nodeData = static_cast<AudioMixerClientData*>(node->getLinkedData());
    AvatarAudioStream* stream = nodeData->getAvatarAudioStream();
    bool dataChanged = (stream->hasReverb() != hasReverb) ||
    (stream->hasReverb() && (stream->getRevebTime() != reverbTime ||
                             stream->getWetLevel() != wetLevel));
    if (dataChanged) {
        // Update stream
        if (hasReverb) {
            stream->setReverb(reverbTime, wetLevel);
        } else {
            stream->clearReverb();
        }
    }

    // Send at change or every so often
    float CHANCE_OF_SEND = 0.01f;
    bool sendData = dataChanged || (randFloat() < CHANCE_OF_SEND);

    if (sendData) {
        auto nodeList = DependencyManager::get<NodeList>();

        unsigned char bitset = 0;

        int packetSize = sizeof(bitset);

        if (hasReverb) {
            packetSize += sizeof(reverbTime) + sizeof(wetLevel);
        }

        auto envPacket = NLPacket::create(PacketType::AudioEnvironment, packetSize);

        if (hasReverb) {
            setAtBit(bitset, HAS_REVERB_BIT);
        }

        envPacket->writePrimitive(bitset);

        if (hasReverb) {
            envPacket->writePrimitive(reverbTime);
            envPacket->writePrimitive(wetLevel);
        }
        nodeList->sendPacket(std::move(envPacket), *node);
    }
}
开发者ID:GabrielPathfinder,项目名称:hifi,代码行数:70,代码来源:AudioMixer.cpp


示例6: sendPacket

bool PcapLiveDevice::sendPacket(Packet* packet)
{
	RawPacket* rawPacket = packet->getRawPacket();
	return sendPacket(*rawPacket);
}
开发者ID:kingjason,项目名称:PcapPlusPlus,代码行数:5,代码来源:PcapLiveDevice.cpp


示例7: sendPacket

bool PacketHandler::handleQueryStatus(HANDLE_ARGS)
{
	QueryStatus response;
	return sendPacket(peer, reinterpret_cast<uint8*>(&response), sizeof(QueryStatus), 3);
}
开发者ID:Koanda,项目名称:HeroWars,代码行数:5,代码来源:Handlers.cpp


示例8: getMyNodeType


//.........这里部分代码省略.........
        // set our preferred PPS to be exactly evenly divided among all of the voxel servers... and allocate 1 PPS
        // for each unknown jurisdiction server
        perServerPPS = (totalPPS / inViewServers) - (unknownJurisdictionServers * perUnknownServer);
    } else {
        if (unknownJurisdictionServers > 0) {
            perUnknownServer = (totalPPS / unknownJurisdictionServers);
        }
    }

    if (wantExtraDebugging) {
        qCDebug(octree, "perServerPPS: %d perUnknownServer: %d", perServerPPS, perUnknownServer);
    }

    auto nodeList = DependencyManager::get<NodeList>();
    nodeList->eachNode([&](const SharedNodePointer& node){
        // only send to the NodeTypes that are serverType
        if (node->getActiveSocket() && node->getType() == serverType) {

            // get the server bounds for this server
            QUuid nodeUUID = node->getUUID();

            bool inView = false;
            bool unknownView = false;

            // if we haven't heard from this voxel server, go ahead and send it a query, so we
            // can get the jurisdiction...
            jurisdictions.lockForRead();
            if (jurisdictions.find(nodeUUID) == jurisdictions.end()) {
                jurisdictions.unlock();
                unknownView = true; // assume it's in view
                if (wantExtraDebugging) {
                    qCDebug(octree) << "no known jurisdiction for node " << *node << ", assume it's visible.";
                }
            } else {
                const JurisdictionMap& map = (jurisdictions)[nodeUUID];

                unsigned char* rootCode = map.getRootOctalCode();

                if (rootCode) {
                    VoxelPositionSize rootDetails;
                    voxelDetailsForCode(rootCode, rootDetails);
                    jurisdictions.unlock();
                    AACube serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s);

                    ViewFrustum::location serverFrustumLocation = _viewFrustum.cubeInFrustum(serverBounds);
                    if (serverFrustumLocation != ViewFrustum::OUTSIDE) {
                        inView = true;
                    } else {
                        inView = false;
                    }
                } else {
                    jurisdictions.unlock();
                    if (wantExtraDebugging) {
                        qCDebug(octree) << "Jurisdiction without RootCode for node " << *node << ". That's unusual!";
                    }
                }
            }

            if (inView) {
                _octreeQuery.setMaxQueryPacketsPerSecond(perServerPPS);
                if (wantExtraDebugging) {
                    qCDebug(octree) << "inView for node " << *node << ", give it budget of " << perServerPPS;
                }
            } else if (unknownView) {
                if (wantExtraDebugging) {
                    qCDebug(octree) << "no known jurisdiction for node " << *node << ", give it budget of "
                    << perUnknownServer << " to send us jurisdiction.";
                }

                // set the query's position/orientation to be degenerate in a manner that will get the scene quickly
                // If there's only one server, then don't do this, and just let the normal voxel query pass through
                // as expected... this way, we will actually get a valid scene if there is one to be seen
                if (totalServers > 1) {
                    _octreeQuery.setCameraPosition(glm::vec3(-0.1,-0.1,-0.1));
                    const glm::quat OFF_IN_NEGATIVE_SPACE = glm::quat(-0.5, 0, -0.5, 1.0);
                    _octreeQuery.setCameraOrientation(OFF_IN_NEGATIVE_SPACE);
                    _octreeQuery.setCameraNearClip(0.1f);
                    _octreeQuery.setCameraFarClip(0.1f);
                    if (wantExtraDebugging) {
                        qCDebug(octree) << "Using 'minimal' camera position for node" << *node;
                    }
                } else {
                    if (wantExtraDebugging) {
                        qCDebug(octree) << "Using regular camera position for node" << *node;
                    }
                }
                _octreeQuery.setMaxQueryPacketsPerSecond(perUnknownServer);
            } else {
                _octreeQuery.setMaxQueryPacketsPerSecond(0);
            }

            // setup the query packet
            auto queryPacket = NLPacket::create(packetType);
            _octreeQuery.getBroadcastData(reinterpret_cast<unsigned char*>(queryPacket->getPayload()));

            // ask the NodeList to send it
            nodeList->sendPacket(std::move(queryPacket), *node);
        }
    });
}
开发者ID:MarcelEdward,项目名称:hifi,代码行数:101,代码来源:OctreeHeadlessViewer.cpp


示例9: rp_sendPacket

int rp_sendPacket(char const *ifname, int sock, const void *pkt, int size) {
   PPPoEConnection conn;
   conn.ifName=const_cast<char*>(ifname);
   return sendPacket(&conn, sock, static_cast<PPPoEPacket*>(const_cast<void*>(pkt)), size);
}
开发者ID:BackupTheBerlios,项目名称:speedmodem50b,代码行数:5,代码来源:interface.cpp


示例10: processDatagram

int processDatagram()
{
	packetHeader header = readHeader(messageBuf);
	int packetType = header.packetType;
	
	// If filename
	if(packetType == DATA)
	{
		// Get filename, print message
		char* fileName = arrSubset(messageBuf, HDRSIZE, DATAFIELDSIZE);
		printf("Received request for file: %s\n", fileName);

		// Read file into file buffer
		readFile(fileName);
		base = 0;
		nextPacket = 0;
		end = cwnd;
		for(nextPacket; nextPacket <= end; nextPacket++)
		{
			if(nextPacket == maxPacket)
			{
				break;
			}
			sendPacket(nextPacket);
		}
	}
	// If ACK
	else if (packetType == ACK)
	{
		int seqNumber = header.seqNumber;
		int ignore = isPacketBad(pl, pc);
		if(ignore == 1)
		{
			printf("Packet with ACK #%d was 'lost', ignoring\n", seqNumber * DATAFIELDSIZE); 
			return 0;
		}
		else if(ignore == 2)
		{
			printf("Packet with ACK #%d was corrupted, ignoring\n", seqNumber * DATAFIELDSIZE);
			return 0;
		}
		else 
		{
			printf("Received packet with ACK for sequence #%d.\n", seqNumber * DATAFIELDSIZE);
		}
		
		// Stop if ACK last packet to send
		if (seqNumber == maxPacket - 1) {
			return 1;
		}		
		
		// Only send new packets if it's an unacked packet, we haven't reached the end, and we aren't retransmitting
		if(retransmitting != 1 && seqNumber >= base && nextPacket != maxPacket)
		{
			int diff = seqNumber - base;
			base = seqNumber + 1;
			end += diff + 1;
			for(nextPacket; nextPacket <= end; nextPacket++)
			{
				if(nextPacket == maxPacket)
				{
					break;
				}
				sendPacket(nextPacket); // Serve up next packet
			}
		}
	}
	else {
		fprintf(stderr, "Unknown packet type recieved!\n");
	}

	return 0;
}
开发者ID:rsoberano,项目名称:cs118-rouel-matt,代码行数:73,代码来源:sender.c


示例11: peerInfo


//.........这里部分代码省略.........
		0x80, 0x01, 0xff, 0x01, 0x4a, 0x08, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74,\
		0x5f, 0x54, 0x31, 0x5f, 0x43, 0x5f, 0x30, 0x34, 0x5f, 0x41, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00,\
		0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76,\
		0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00,\
		0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff,\
		0x01, 0x4a, 0x09, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x31,\
		0x5f, 0x43, 0x5f, 0x30, 0x33, 0x5f, 0x41, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
		0x00, 0xa0, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59,\
		0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00,\
		0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x0a,\
		0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x31, 0x5f, 0x43, 0x5f,\
		0x30, 0x31, 0x5f, 0x41, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02,\
		0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9,\
		0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8,\
		0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x0b, 0x00, 0x00, 0x40,\
		0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x31, 0x5f, 0x43, 0x5f, 0x30, 0x32, 0x5f,\
		0x41, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x03,\
		0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2,\
		0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38,\
		0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x0c, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75,\
		0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x32, 0x5f, 0x43, 0x5f, 0x30, 0x35, 0x5f, 0x41, 0x00, 0x74,\
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00,\
		0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74,\
		0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00,\
		0x00, 0x80, 0x01};

	uint8 turrets3[] = {0xff, 0x06, 0x4f, 0xa6, 0x0d, 0x00, 0x00, 0x40, 0x0d, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72,\
		0x72, 0x65, 0x74, 0x5f, 0x54, 0x32, 0x5f, 0x43, 0x5f, 0x30, 0x34, 0x5f, 0x41, 0x00, 0x74, 0x00,\
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5,\
		0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04,\
		0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00,\
		0x80, 0x01, 0xff, 0x01, 0x4a, 0x0e, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74,\
		0x5f, 0x54, 0x32, 0x5f, 0x43, 0x5f, 0x30, 0x33, 0x5f, 0x41, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00,\
		0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76,\
		0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00,\
		0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff,\
		0x01, 0x4a, 0x0f, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x32,\
		0x5f, 0x43, 0x5f, 0x30, 0x31, 0x5f, 0x41, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
		0x00, 0xa0, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59,\
		0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00,\
		0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x10,\
		0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x32, 0x5f, 0x43, 0x5f,\
		0x30, 0x32, 0x5f, 0x41, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02,\
		0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9,\
		0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8,\
		0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x11, 0x00, 0x00, 0x40,\
		0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x54, 0x75, 0x72,\
		0x72, 0x65, 0x74, 0x53, 0x68, 0x72, 0x69, 0x6e, 0x65, 0x5f, 0x41, 0x00, 0x02, 0x00, 0x00, 0x03,\
		0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2,\
		0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38,\
		0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x12, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75,\
		0x72, 0x72, 0x65, 0x74, 0x5f, 0x43, 0x68, 0x61, 0x6f, 0x73, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74,\
		0x53, 0x68, 0x72, 0x69, 0x6e, 0x65, 0x5f, 0x41, 0x00, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00,\
		0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74,\
		0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00,\
		0x00, 0x80, 0x01};

uint8 turrets4[] = {0xff, 0x07, 0x4f, 0xa6, 0x13, 0x00, 0x00, 0x40, 0x13, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72,\
		0x72, 0x65, 0x74, 0x5f, 0x54, 0x31, 0x5f, 0x4c, 0x5f, 0x30, 0x33, 0x5f, 0x41, 0x00, 0x74, 0x53,\
		0x68, 0x72, 0x69, 0x6e, 0x65, 0x5f, 0x41, 0x00, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5,\
		0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04,\
		0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00,\
		0x80, 0x01, 0xff, 0x01, 0x4a, 0x14, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74,\
		0x5f, 0x54, 0x31, 0x5f, 0x4c, 0x5f, 0x30, 0x32, 0x5f, 0x41, 0x00, 0x74, 0x53, 0x68, 0x72, 0x69,\
		0x6e, 0x65, 0x5f, 0x41, 0x00, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76,\
		0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00,\
		0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff,\
		0x01, 0x4a, 0x15, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x31,\
		0x5f, 0x43, 0x5f, 0x30, 0x36, 0x5f, 0x41, 0x00, 0x74, 0x53, 0x68, 0x72, 0x69, 0x6e, 0x65, 0x5f,\
		0x41, 0x00, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59,\
		0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00,\
		0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x16,\
		0x00, 0x00, 0x40, 0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x32, 0x5f, 0x4c, 0x5f,\
		0x30, 0x33, 0x5f, 0x41, 0x00, 0x74, 0x53, 0x68, 0x72, 0x69, 0x6e, 0x65, 0x5f, 0x41, 0x00, 0x02,\
		0x00, 0x00, 0x03, 0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9,\
		0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8,\
		0x18, 0x00, 0x38, 0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x17, 0x00, 0x00, 0x40,\
		0x40, 0x54, 0x75, 0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x32, 0x5f, 0x4c, 0x5f, 0x30, 0x32, 0x5f,\
		0x41, 0x00, 0x74, 0x53, 0x68, 0x72, 0x69, 0x6e, 0x65, 0x5f, 0x41, 0x00, 0x02, 0x00, 0x00, 0x03,\
		0x00, 0x1f, 0x00, 0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2,\
		0xb9, 0xa8, 0x74, 0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38,\
		0x14, 0x68, 0x00, 0x00, 0x80, 0x01, 0xff, 0x01, 0x4a, 0x18, 0x00, 0x00, 0x40, 0x40, 0x54, 0x75,\
		0x72, 0x72, 0x65, 0x74, 0x5f, 0x54, 0x32, 0x5f, 0x4c, 0x5f, 0x30, 0x31, 0x5f, 0x41, 0x00, 0x74,\
		0x53, 0x68, 0x72, 0x69, 0x6e, 0x65, 0x5f, 0x41, 0x00, 0x02, 0x00, 0x00, 0x03, 0x00, 0x1f, 0x00,\
		0xc5, 0x16, 0x68, 0x76, 0xdd, 0x46, 0x59, 0x5d, 0xe2, 0xf9, 0x33, 0x77, 0xf2, 0xb9, 0xa8, 0x74,\
		0x04, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xe8, 0xf8, 0x18, 0x00, 0x38, 0x14, 0x68, 0x00,\
		0x00, 0x80, 0x01, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00};

	HeroSpawnPacket *heroSpawn = HeroSpawnPacket::create(PKT_HeroSpawn,  peerInfo(peer)->name, peerInfo(peer)->nameLen, peerInfo(peer)->type, peerInfo(peer)->typeLen);

	sendPacket(peer, reinterpret_cast<uint8*>(heroSpawn), heroSpawn->getPacketLength(), 3);
	sendPacket(peer, reinterpret_cast<uint8*>(bounds), sizeof(bounds), 3);
	sendPacket(peer, reinterpret_cast<uint8*>(turrets1), sizeof(turrets1), 3);
	sendPacket(peer, reinterpret_cast<uint8*>(turrets2), sizeof(turrets2), 3);
	sendPacket(peer, reinterpret_cast<uint8*>(turrets3), sizeof(turrets3), 3);
	sendPacket(peer, reinterpret_cast<uint8*>(turrets4), sizeof(turrets4), 3);

	
	return true;
}
开发者ID:Koanda,项目名称:HeroWars,代码行数:101,代码来源:Handlers.cpp


示例12: disableWatchdogs

void FMS::periodic()
{
	if(isConnected())
	{
		//If it's time then send a heartbeat request
		if(millis() - fmsLastSeen > FMS_HEARTBEAT_DELAY) //Add stuff to prevent dropped packets maybe idc
		{
			disableWatchdogs(); // Make sure watchdogs don't die when checking on heartbeat
			//Serial.println(F("Checking on heartbeat")); //TODO: dleete this
			
			sendPacket(F("HB_LUB"));
			long hbStarted = millis();
			
			while(str_equals(readLine(), ""))
			{
				if(millis() - hbStarted > FMS_HEARTBEAT_TIMEOUT)
				{
					connectedToFMS = false;
					client.close();
					Serial.println(F("FMS connection dropped."));
					setState(DISABLED);
					enableWatchdogs();
					return;
				}
			}
			
			fmsLastSeen = millis();
			enableWatchdogs();
		}
		
		//handle packets from fms
		char* input = readLine();
		
		if(!str_equals(input, ""))
		{
			if(str_startsWith(input, "S_S_"))
			{
				str_replace(input, "S_S_", "");
				if(str_startsWith(input, "A"))
				{
					setState(AUTONOMOUS);
				} else
				if(str_startsWith(input, "D"))
				{
					setState(DISABLED);
				} else
				if(str_startsWith(input, "T"))
				{
					setState(TELEOP);
				}
				sendPacket(F("S_ACK"));
			}
			else
				Serial.println(input); //Something wrong happened so lets output it for debug
			
			fmsLastSeen = millis();
		}
	} else {
		disableWatchdogs();
		connect();
		enableWatchdogs();
	}
}
开发者ID:Team4159,项目名称:CardinalFMS-bot,代码行数:63,代码来源:FMS.cpp


示例13: tuntap_write

int tuntap_write(struct net_device *net_dev, void *buf, size_t count)
{
	if(net_dev->priv == NULL) return -1;
	return sendPacket((tap_win32*)net_dev->priv, buf, count);
}
开发者ID:comealong,项目名称:skyeye-plus,代码行数:5,代码来源:skyeye_net_tap_win32.c


示例14: AudioMixerClientData


//.........这里部分代码省略.........
            if (hasRatioChanged) {
                // set out min audability threshold from the new ratio
                _minAudibilityThreshold = LOUDNESS_TO_DISTANCE_RATIO / (2.0f * (1.0f - _performanceThrottlingRatio));
                qDebug() << "Minimum audability required to be mixed is now" << _minAudibilityThreshold;

                framesSinceCutoffEvent = 0;
            }
        }

        if (!hasRatioChanged) {
            ++framesSinceCutoffEvent;
        }

        quint64 now = usecTimestampNow();
        if (now - _lastPerSecondCallbackTime > USECS_PER_SECOND) {
            perSecondActions();
            _lastPerSecondCallbackTime = now;
        }

        nodeList->eachNode([&](const SharedNodePointer& node) {

            if (node->getLinkedData()) {
                AudioMixerClientData* nodeData = (AudioMixerClientData*)node->getLinkedData();

                // this function will attempt to pop a frame from each audio stream.
                // a pointer to the popped data is stored as a member in InboundAudioStream.
                // That's how the popped audio data will be read for mixing (but only if the pop was successful)
                nodeData->checkBuffersBeforeFrameSend();

                // if the stream should be muted, send mute packet
                if (nodeData->getAvatarAudioStream()
                    && shouldMute(nodeData->getAvatarAudioStream()->getQuietestFrameLoudness())) {
                    auto mutePacket = NLPacket::create(PacketType::NoisyMute, 0);
                    nodeList->sendPacket(std::move(mutePacket), *node);
                }

                if (node->getType() == NodeType::Agent && node->getActiveSocket()
                    && nodeData->getAvatarAudioStream()) {

                    int streamsMixed = prepareMixForListeningNode(node.data());

                    std::unique_ptr<NLPacket> mixPacket;

                    if (streamsMixed > 0) {
                        int mixPacketBytes = sizeof(quint16) + AudioConstants::NETWORK_FRAME_BYTES_STEREO;
                        mixPacket = NLPacket::create(PacketType::MixedAudio, mixPacketBytes);

                        // pack sequence number
                        quint16 sequence = nodeData->getOutgoingSequenceNumber();
                        mixPacket->writePrimitive(sequence);

                        // pack mixed audio samples
                        mixPacket->write(reinterpret_cast<char*>(_mixSamples),
                                         AudioConstants::NETWORK_FRAME_BYTES_STEREO);
                    } else {
                        int silentPacketBytes = sizeof(quint16) + sizeof(quint16);
                        mixPacket = NLPacket::create(PacketType::SilentAudioFrame, silentPacketBytes);

                        // pack sequence number
                        quint16 sequence = nodeData->getOutgoingSequenceNumber();
                        mixPacket->writePrimitive(sequence);

                        // pack number of silent audio samples
                        quint16 numSilentSamples = AudioConstants::NETWORK_FRAME_SAMPLES_STEREO;
                        mixPacket->writePrimitive(numSilentSamples);
                    }
开发者ID:GabrielPathfinder,项目名称:hifi,代码行数:67,代码来源:AudioMixer.cpp


示例15: sendPacket

/** A blank packet can be sent to exit monitor mode **/
AREXPORT bool ArDPPTU::blank(void)
{
  myPacket.empty();
  return sendPacket(&myPacket);
}
开发者ID:PSU-Robotics-Countess-Quanta,项目名称:Countess-Quanta-Control,代码行数:6,代码来源:ArDPPTU.cpp


示例16: sendPADI

/***********************************************************************
*%FUNCTION: sendPADI
*%ARGUMENTS:
* conn -- PPPoEConnection structure
*%RETURNS:
* Nothing
*%DESCRIPTION:
* Sends a PADI packet
***********************************************************************/
static void
sendPADI(PPPoEConnection *conn)
{
    PPPoEPacket packet;
    unsigned char *cursor = packet.payload;
    PPPoETag *svc = (PPPoETag *) (&packet.payload);
    UINT16_t namelen = 0;
    UINT16_t plen;
    int omit_service_name = 0;

    if (conn->serviceName) {
	namelen = (UINT16_t) strlen(conn->serviceName);
	if (!strcmp(conn->serviceName, "NO-SERVICE-NAME-NON-RFC-COMPLIANT")) {
	    omit_service_name = 1;
	}
    }

    /* Set destination to Ethernet broadcast address */
    memset(packet.ethHdr.h_dest, 0xFF, ETH_ALEN);
    memcpy(packet.ethHdr.h_source, conn->myEth, ETH_ALEN);

    packet.ethHdr.h_proto = htons(Eth_PPPOE_Discovery);
    packet.vertype = PPPOE_VER_TYPE(1, 1);
    packet.code = CODE_PADI;
    packet.session = 0;

    if (!omit_service_name) {
	plen = TAG_HDR_SIZE + namelen;
	CHECK_ROOM(cursor, packet.payload, plen);

	svc->type = TAG_SERVICE_NAME;
	svc->length = htons(namelen);

	if (conn->serviceName) {
	    memcpy(svc->payload, conn->serviceName, strlen(conn->serviceName));
	}
	cursor += namelen + TAG_HDR_SIZE;
    } else {
	plen = 0;
    }

    /* If we're using Host-Uniq, copy it over */
    if (conn->useHostUniq) {
	PPPoETag hostUniq;
	pid_t pid = getpid();
	hostUniq.type = htons(TAG_HOST_UNIQ);
	hostUniq.length = htons(sizeof(pid));
	memcpy(hostUniq.payload, &pid, sizeof(pid));
	CHECK_ROOM(cursor, packet.payload, sizeof(pid) + TAG_HDR_SIZE);
	memcpy(cursor, &hostUniq, sizeof(pid) + TAG_HDR_SIZE);
	cursor += sizeof(pid) + TAG_HDR_SIZE;
	plen += sizeof(pid) + TAG_HDR_SIZE;
    }

    /* Add our maximum MTU/MRU */
    if (MIN(lcp_allowoptions[0].mru, lcp_wantoptions[0].mru) > ETH_PPPOE_MTU) {
	PPPoETag maxPayload;
	UINT16_t mru = htons(MIN(lcp_allowoptions[0].mru, lcp_wantoptions[0].mru));
	maxPayload.type = htons(TAG_PPP_MAX_PAYLOAD);
	maxPayload.length = htons(sizeof(mru));
	memcpy(maxPayload.payload, &mru, sizeof(mru));
	CHECK_ROOM(cursor, packet.payload, sizeof(mru) + TAG_HDR_SIZE);
	memcpy(cursor, &maxPayload, sizeof(mru) + TAG_HDR_SIZE);
	cursor += sizeof(mru) + TAG_HDR_SIZE;
	plen += sizeof(mru) + TAG_HDR_SIZE;
    }

    packet.length = htons(plen);

    sendPacket(conn, conn->discoverySocket, &packet, (int) (plen + HDR_SIZE));
}
开发者ID:qwerty1023,项目名称:wive-rtnl-firmware,代码行数:80,代码来源:discovery.c


示例17: sendPADR

/***********************************************************************
*%FUNCTION: sendPADR
*%ARGUMENTS:
* conn -- PPPoE connection structur
*%RETURNS:
* Nothing
*%DESCRIPTION:
* Sends a PADR packet
***********************************************************************/
static void
sendPADR(PPPoEConnection *conn)
{
    PPPoEPacket packet;
    PPPoETag *svc = (PPPoETag *) packet.payload;
    unsigned char *cursor = packet.payload;

    UINT16_t namelen = 0;
    UINT16_t plen;

    if (conn->serviceName) {
	namelen = (UINT16_t) strlen(conn->serviceName);
    }
    plen = TAG_HDR_SIZE + namelen;
    CHECK_ROOM(cursor, packet.payload, plen);

    memcpy(packet.ethHdr.h_dest, conn->peerEth, ETH_ALEN);
    memcpy(packet.ethHdr.h_source, conn->myEth, ETH_ALEN);

    packet.ethHdr.h_proto = htons(Eth_PPPOE_Discovery);
    packet.vertype = PPPOE_VER_TYPE(1, 1);
    packet.code = CODE_PADR;
    packet.session = 0;

    svc->type = TAG_SERVICE_NAME;
    svc->length = htons(namelen);
    if (conn->serviceName) {
	memcpy(svc->payload, conn->serviceName, namelen);
    }
    cursor += namelen + TAG_HDR_SIZE;

    /* If we're using Host-Uniq, copy it over */
    if (conn->useHostUniq) {
	PPPoETag hostUniq;
	pid_t pid = getpid();
	hostUniq.type = htons(TAG_HOST_UNIQ);
	hostUniq.length = htons(sizeof(pid));
	memcpy(hostUniq.payload, &pid, sizeof(pid));
	CHECK_ROOM(cursor, packet.payload, sizeof(pid)+TAG_HDR_SIZE);
	memcpy(cursor, &hostUniq, sizeof(pid) + TAG_HDR_SIZE);
	cursor += sizeof(pid) + TAG_HDR_SIZE;
	plen += sizeof(pid) + TAG_HDR_SIZE;
    }

    /* Add our maximum MTU/MRU */
    if (MIN(lcp_allowoptions[0].mru, lcp_wantoptions[0].mru) > ETH_PPPOE_MTU) {
	PPPoETag maxPayload;
	UINT16_t mru = htons(MIN(lcp_allowoptions[0].mru, lcp_wantoptions[0].mru));
	maxPayload.type = htons(TAG_PPP_MAX_PAYLOAD);
	maxPayload.length = htons(sizeof(mru));
	memcpy(maxPayload.payload, &mru, sizeof(mru));
	CHECK_ROOM(cursor, packet.payload, sizeof(mru) + TAG_HDR_SIZE);
	memcpy(cursor, &maxPayload, sizeof(mru) + TAG_HDR_SIZE);
	cursor += sizeof(mru) + TAG_HDR_SIZE;
	plen += sizeof(mru) + TAG_HDR_SIZE;
    }

    /* Copy cookie and relay-ID if needed */
    if (conn->cookie.type) {
	CHECK_ROOM(cursor, packet.payload,
		   ntohs(conn->cookie.length) + TAG_HDR_SIZE);
	memcpy(cursor, &conn->cookie, ntohs(conn->cookie.length) + TAG_HDR_SIZE);
	cursor += ntohs(conn->cookie.length) + TAG_HDR_SIZE;
	plen += ntohs(conn->cookie.length) + TAG_HDR_SIZE;
    }

    if (conn->relayId.type) {
	CHECK_ROOM(cursor, packet.payload,
		   ntohs(conn->relayId.length) + TAG_HDR_SIZE);
	memcpy(cursor, &conn->relayId, ntohs(conn->relayId.length) + TAG_HDR_SIZE);
	cursor += ntohs(conn->relayId.length) + TAG_HDR_SIZE;
	plen += ntohs(conn->relayId.length) + TAG_HDR_SIZE;
    }

    packet.length = htons(plen);
    sendPacket(conn, conn->discoverySocket, &packet, (int) (plen + HDR_SIZE));
}
开发者ID:qwerty1023,项目名称:wive-rtnl-firmware,代码行数:86,代码来源:discovery.c


示例18: sendPacket

bool Adafruit_BluefruitLE_SPI::sendInitializePattern(void)
{
  return sendPacket(SDEP_CMDTYPE_INITIALIZE, NULL, 0, 0);
}
开发者ID:HelenMelonz,项目名称:Adafruit_Bluefruit_transmit_receive,代码行数:4,代码来源:Adafruit_BluefruitLE_SPI.cpp


示例19: bytes2Packet


//.........这里部分代码省略.........
       // the packet is assembled and ready
       // increase number of packets received
       if (ReceivedPacketsNum<2) {
         ReceivedPacketsNum++;
         ReceivedPackets[ReceivedPacketsNum-1] = bytes2Packet(CurrentPacket);
         
       } else // raise overflow flag
            PacketQueueOverflow = true;       
       // disposing CurrentPacket
       free(CurrentPacket);
       // resetting the RoboNetDevice
       state = stIdle;
       PacketReceiverID = 0;
       TotalFrames = 0;
       FramesReceived = 0;
      }
       else if (state == stWaitingAcknowledge) { // waiting for acknowledge 
                // checking time ellapsed
                unsigned long currentTime = millis();
                unsigned long transmissionElapsed = currentTime - TransmissionStartTime;
                
                if (transmissionElapsed > PACKET_SENDING_TIMEOUT)
                { // transmission timedout
                    // raising error flag
                    Serial.println("Packet Sending Timedout!");
                    PacketSendTimeout = true;
                    // quiting everything and resetting
                    free(CurrentPacket);
                    
                    PacketSenderID = 0;
                    PacketReceiverID = 0;
                    TotalFrames = 0;
                    FramesSent = 0;
                    FramesReceived = 0;
                    state = stIdle;
                }
                else
                {
                    unsigned long elapsed = currentTime - FrameTransmissionStartTime;
                    
                    if (elapsed > FRAME_ACKNOWLEDGE_TIMEOUT)
                    { // timeout occured
                    Serial.println("Acknowledge timeout!");
                        // attempting to resend the frame
                        state = stSending; // sending again
                        sendNextFrame();
                    }
                }
            }
            else if (state == stReceiving)
            { // receiving a packet
                unsigned long currentTime = millis();
                unsigned long receptionElapsed = currentTime - ReceptionStartTime;
                if (receptionElapsed > PACKET_SENDING_TIMEOUT)
                { // packet's timedout
                    // raising error flag
                    PacketReceiveTimeout = true;
                    // disposing packet
                    free(CurrentPacket);
                    // resetting
                    PacketReceiverID = 0;
                    PacketSenderID = 0;
                    TotalFrames = 0;
                    FramesSent = 0;
                    FramesReceived = 0;
                    state = stIdle;
                }
                else
                {
                    // checking time elapsed since last acknowledgement
                    unsigned long elapsed = currentTime - FrameReceptionStartTime;
                    if (elapsed > FRAME_ACKNOWLEDGE_TIMEOUT)
                    { // next frame timedout
                        // sending a new acknowledgement
                        sendAcknowledge(PacketReceiverID);
                        // reseting time
                        FrameReceptionStartTime = millis();
                        state = stReceiving;
                    }
                }
            } else if (state==stIdle) {
                      if (OutboundPacketsNum>0) { // outbound queue is not empty. must initiate transmission
                        // removing a packet from the outbound queue  
                        EZPacket* outpacket = OutboundPackets[0];
                        
                        OutboundPa 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sendReply函数代码示例发布时间:2022-05-30
下一篇:
C++ sendOutputEvent函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap