示例#1
0
void VoxelTerrain:: execute()
{
  //pro vstupni cloud
  // udelat octree
  pcl::octree::OctreePointCloud<pcl::PointXYZI> oc (m_resolution);
  oc.setInputCloud (m_baseCloud->get_Cloud());
  oc.addPointsFromInputCloud ();
  // zjistit vsechny voxely
  std::vector<pcl::PointXYZI, Eigen::aligned_allocator<pcl::PointXYZI> > voxels;
  oc.getOccupiedVoxelCenters(voxels);

  // zjistit rozsah x y osy a podle toho hledat voxely ktere jsou nejníž
  double x_max,x_min,y_max,y_min,z_min,z_max;
  oc.getBoundingBox(x_min,y_min,z_min,x_max,y_max,z_max);

  oc.deleteTree();
emit percentage( 20);
  // z voxels udelat mracno bodu
  pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_voxels (new pcl::PointCloud<pcl::PointXYZI>);
  cloud_voxels->points.resize(voxels.size());
  #pragma omp parallel for
  for(int r=0; r < voxels.size(); r++)
  {
    cloud_voxels->points.at(r) = voxels.at(r);
  }
  cloud_voxels->width = cloud_voxels->points.size ();
  cloud_voxels->height = 1;
  cloud_voxels->is_dense = true;
emit percentage( 40);
  // spis boxsearch a pro kazdy voxel najit sousedy v danem boxu, pokud nenajde žadny bod niž než je on sam uložit jeho ID..
  pcl::octree::OctreePointCloudSearch<pcl::PointXYZI> ocs (m_resolution);

  ocs.setInputCloud (cloud_voxels);
  ocs.addPointsFromInputCloud ();
  std::vector< int > low_voxels;
  for (int q =0; q < voxels.size(); q++)
  {
    std::vector< int > ind;
    Eigen::Vector3f low(voxels.at(q).x-m_resolution/2, voxels.at(q).y-m_resolution/2,z_min);
    Eigen::Vector3f high(voxels.at(q).x+m_resolution/2, voxels.at(q).y+m_resolution/2,voxels.at(q).z);
    if(ocs.boxSearch(low,high,ind) <2)
    {
      if(ind.size() == 0)
        continue;
      // pokud jsou voxely vyskove pouze res od sebe
      if(ind.size()==1)
        low_voxels.push_back(q);
    }
  }
  emit percentage( 80);
  ocs.deleteTree();

  // jeste by to chtelo trochu prefiltrovat aby byl opravdu jen voxely terenu




  boost::shared_ptr<std::vector<int> > indicesptr (new std::vector<int> (low_voxels));
  pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_vege (new pcl::PointCloud<pcl::PointXYZI>);
  pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_terrain (new pcl::PointCloud<pcl::PointXYZI>);
  pcl::ExtractIndices<pcl::PointXYZI> extract;
     // Extract the inliers
  extract.setInputCloud (cloud_voxels);
  extract.setIndices (indicesptr);
  extract.setNegative (false);
  extract.filter (*cloud_terrain);
  extract.setNegative (true);
  extract.filter (*cloud_vege);

  m_vegetation->set_Cloud(cloud_vege);
  m_terrain->set_Cloud(cloud_terrain);

   sendData();
emit percentage( 99);
}
示例#2
0
void WebServer::HTTPResponse::sendData(const char* pData, size_t length) {
	sendData((uint8_t*) pData, length);
} // sendData
示例#3
0
/**
 * \brief Store data record
 */
void Storage::storeDataRecord(struct metadata *mdata)
{
	offset = 0;

	record.clear();
	record += "{\"@type\": \"ipfix.entry\", \"ipfix\": {";

	struct ipfix_template *templ = mdata->record.templ;
	uint8_t *data_record = (uint8_t*) mdata->record.record;
	
	/* get all fields */
	for (uint16_t count = 0, index = 0; count < templ->field_count; ++count, ++index) {
		/* Get Enterprise number and ID */
		id = templ->fields[index].ie.id;
		length = templ->fields[index].ie.length;
		enterprise = 0;
		
		if (id & 0x8000) {
			id &= 0x7fff;
			enterprise = templ->fields[++index].enterprise_number;
		}
		
		/* Get element informations */
		struct ipfix_element& element = elements[enterprise][id];
		if (element.type == UNKNOWN && element.name.empty()) {
			element.name = rawName(enterprise, id);
			elements[enterprise][id] = element;
			MSG_DEBUG(msg_module, "Unknown element (%s)", element.name.c_str());
		}

		if (count > 0) {
			record += ", ";
		}

		record += "\"";
		record += element.name;
		record += "\": \"";

		switch (element.type) {
		case PROTOCOL:
			record += translator.formatProtocol(read8(data_record + offset));
			break;
		case FLAGS:
			record += translator.formatFlags(read16(data_record + offset));
			break;
		case IPV4:
			record += translator.formatIPv4(read32(data_record + offset));
			break;
		case IPV6:{
			READ_BYTE_ARR(addr6, data_record + offset, IPV6_LEN);
			record += translator.formatIPv6(addr6);
			break;}
		case MAC: {
			READ_BYTE_ARR(addrMac, data_record + offset, MAC_LEN);
			record += translator.formatMac(addrMac);
			break;}
		case TSTAMP_SEC:
			record += translator.formatTimestamp(read64(data_record + offset), t_units::SEC);
			break;
		case TSTAMP_MILLI:
			record += translator.formatTimestamp(read64(data_record + offset), t_units::MILLISEC);
			break;
		case TSTAMP_MICRO:
			record += translator.formatTimestamp(read64(data_record + offset), t_units::MICROSEC);
			break;
		case TSTAMP_NANO:
			record += translator.formatTimestamp(read64(data_record + offset), t_units::NANOSEC);
			break;
		case STRING:
			readString(length, data_record, offset);
			break;
		case RAW:
			readRawData(length, data_record, offset);
			break;
		default:
			readRawData(length, data_record, offset);
			break;
		}

		record += "\"";

		offset += length;
	}
	
	/* Store metadata */
	if (processMetadata) {
		record += "}, \"metadata\": {";
		storeMetadata(mdata);
	}
	
	record += "}}\n";
	sendData();
}
示例#4
0
INT32 _mongoSession::_reply( MsgOpReply *replyHeader,
                             const CHAR *pBody,
                             const INT32 len )
{
   INT32 rc         = SDB_OK ;
   INT32 offset     = 0 ;
   mongoMsgReply reply ;
   bson::BSONObjBuilder bob ;
   bson::BSONObj bsonBody ;

   reply.header.id = 0 ;
   reply.header.responseTo = replyHeader->header.requestID ;
   reply.header.opCode = dbReply ;
   reply.header._flags = 0 ;
   reply.header._version = 0 ;
   reply.header.reservedFlags = 0 ;
   reply.cursorId = ( -1 == replyHeader->contextID ?
                            0 : replyHeader->contextID ) ;
   reply.startingFrom = replyHeader->startFrom ;
   if ( _converter->getParser().withCmd || _needReply )
   {
      reply.nReturned = replyHeader->numReturned > 0 ? replyHeader->numReturned : 1 ;
   }
   else
   {
      reply.nReturned = replyHeader->numReturned ;
   }

   if ( !_converter->getParser().withCmd && reply.nReturned > 0 )
   {
      while ( offset < len )
      {
         bsonBody.init( pBody + offset ) ;
         _outBuffer.write( bsonBody.objdata(), bsonBody.objsize() ) ;
         offset += ossRoundUpToMultipleX( bsonBody.objsize(), 4 ) ;
      }
      pBody = _outBuffer.data() ;
      reply.header.len = sizeof( mongoMsgReply ) + _outBuffer.size() ;
   }
   else
   {
      if ( pBody )
      {
         bsonBody.init( pBody ) ;
         if ( !bsonBody.hasField( "ok" ))
         {
            bob.append( "ok",
                        0 == replyHeader->flags ? TRUE : replyHeader->flags ) ;
            bob.appendElements( bsonBody ) ;
            pBody = bob.done().objdata() ;
            reply.header.len = sizeof( mongoMsgReply ) + bob.done().objsize() ;
         }
         else
         {
            reply.header.len = sizeof( mongoMsgReply ) + len ;
         }
      }
      else
      {
         bob.append( "ok", 1.0 ) ;
         pBody = bob.done().objdata() ;
         reply.header.len = sizeof( mongoMsgReply ) + bob.done().objsize() ;
      }
   }

   rc = sendData( (CHAR *)&reply, sizeof( mongoMsgReply ) ) ;
   if ( rc )
   {
      PD_LOG( PDERROR, "Session[%s] failed to send response header, rc: %d",
              sessionName(), rc ) ;
      goto error ;
   }

   if ( pBody )
   {
      rc = sendData( pBody, reply.header.len - sizeof( mongoMsgReply ) ) ;
      if ( rc )
      {
         PD_LOG( PDERROR, "Session[%s] failed to send response body, rc: %d",
                          sessionName(), rc ) ;
         goto error ;
      }
   }

   bob.decouple() ;

done:
   return rc ;
error:
   goto done ;
}
示例#5
0
void TM16XX::clearDisplay()
{
  for (int i = 0; i < displays; i++) {
    sendData(i << 1, 0);
  }
}
示例#6
0
文件: client.c 项目: mannias/SO
void grabNewEmails() {
	sendData(0, fillMessageData("mail", "receive", username), sizeof(Message));
	getResponce(0);
}
示例#7
0
bool deviceTransaction(iguanaDev *idev,       /* required */
                       dataPacket *request,   /* required */
                       dataPacket **response) /* optional */
{
    bool retval = false;
    packetType *type;

    /* For old devices setting pin configs actually becomes 2
       requests, awkward, but the way it has to be to support old
       firmware. */
    if (idev->version <= 3 && 
        (request->code == IG_DEV_SETPINCONFIG ||
         request->code == IG_DEV_GETPINCONFIG))
        return oldPinConfig(idev, request, response);

    type = checkIncomingProtocol(idev, request, response == NULL);
    if (type)
    {
        unsigned char msg[MAX_PACKET_SIZE] = {CTL_START, CTL_START, CTL_TODEV};
        uint64_t then, now;
        int length = MIN_CTL_LENGTH, result, sent = 0;

#ifdef LIBUSB_NO_THREADS
        bool unlocked = false;
#endif

        /* possibly change the code, then translate for the device */
        switch(request->code)
        {
        case IG_DEV_GETID:
            msg[CODE_OFFSET] = IG_DEV_EXECUTE;
            break;
            
        case IG_DEV_SETID:
        {
            unsigned char *block;
            block = generateIDBlock((char*)request->data, idev->version);
            free(request->data);
            request->data = block;
            request->dataLen = 68;

            msg[CODE_OFFSET] = IG_DEV_WRITEBLOCK;
            break;
        }

        /* clear the features if any page is written since this could
           change the returned timings */
        case IG_DEV_WRITEBLOCK:
            idev->features = UNKNOWN_FEATURES;
        default:
            msg[CODE_OFFSET] = request->code;
            break;
        }
        if (! translateDevice(msg + CODE_OFFSET, idev->version, false))
            message(LOG_ERROR, "Failed to translate code for device.\n");

        /* compute the outgoing checksum for IG_DEV_WRITEBLOCK */
        if (msg[CODE_OFFSET] == IG_DEV_WRITEBLOCK &&
            request->dataLen == 68)
        {
            int x;
            uint32_t chksum = 0;
            for(x = 4; x < 68; x++)
                chksum += request->data[x];
            request->data[2] = (chksum & 0xFF00) >> 8;
            request->data[3] = chksum & 0xFF;
        }

        /* SEND and PINBURST do not get their data packed into the
           request packet, unlike everything else. */
        if (request->code != IG_DEV_SEND &&
            request->code != IG_DEV_RESEND &&
            request->code != IG_DEV_PINBURST &&
            request->code != IG_DEV_REPEATER)
        {
            if (request->code != IG_DEV_SETPINCONFIG)
            {
                sent = request->dataLen;
                /* this is only used to get addresses in WRITEBLOCK */
                if (sent > 4)
                    sent = 4;
                memcpy(msg + MIN_CTL_LENGTH, request->data, sent);
                length += sent;
            }
        }
        /* as of version 3 SEND and PINBURST require a length argument */
        else if (idev->version >= 3)
        {
            int dataPos = MIN_CTL_LENGTH;
            if (request->code == IG_DEV_RESEND)
            {
                /* prepare to append the channels and carrier */
                request->data = realloc(request->data, MAX_PACKET_SIZE);
                request->dataLen = MAX_PACKET_SIZE;

                 /* the size will be overwritten in the device firmware */
                request->data[dataPos++] = 0xFF;
            }
            else
                msg[length++] = (unsigned char)request->dataLen;

            /* select which channels to transmit on */
            if (request->code == IG_DEV_SEND ||
                request->code == IG_DEV_RESEND ||
                request->code == IG_DEV_REPEATER)
            {
                if (request->code == IG_DEV_RESEND)
                    request->data[dataPos++] = idev->channels;
                else
                    msg[length++] = idev->channels;

                /* is the carrier frequency finally adjustable? */
                if ((idev->version & 0x00FF) &&
                    (idev->version & 0xFF00))
                {
                    unsigned char *delays;
                    /* the cycle count WAS stable so default to that count: */
                    uint8_t loopCycles = 5 + 5 + 7 + 6 + 6 + 7 + \
                                         (5 + 7) + (5 + 7) + 5;
                    /* we can use the cycle count provided by the
                       firmware with body-4 */
                    if ((idev->version & 0x00FF) >= 0x0004 &&
                        checkFeatures(idev, UNKNOWN_FEATURES))
                        loopCycles = idev->cycles;

                    /* compute the delay length off the carrier */
                    if (request->code == IG_DEV_RESEND)
                        delays = request->data + dataPos;
                    else
                    {
                        delays = msg + length;
                        length += 2;
                    }
                    computeCarrierDelays(idev->carrier, delays, loopCycles);
                }
            }
        }


#ifdef LIBUSB_NO_THREADS_OPTION
        if (idev->libusbNoThreads)
#endif
#ifdef LIBUSB_NO_THREADS
        {
            /* force the reader to give up the lock */
            idev->needToWrite = true;
            EnterCriticalSection(&idev->devLock);
            idev->needToWrite = false;
        }
#endif

        /* flush any extraneous CTL_TODEV responses */
        flushToDevResponsePackets(idev);
        /* time the transfer */
        then = microsSinceX();
        result = interruptSend(idev->usbDev, msg, length,
                               idev->settings->sendTimeout);
        /* error if we were not able to write ALL the data */
        if (result != length)
            printError(LOG_ERROR,
                       "failed to write control packet", idev->usbDev);
        /* if there is more data need to transmit the data stream
           before releasing the devLock */
        else if (request->dataLen > sent &&
                 ! sendData(idev,
                            request->data + sent, request->dataLen - sent,
                            idev->version < 3 && request->code == IG_DEV_SEND))
            message(LOG_ERROR, "Failed to send IR data.\n");
        /* if no ack is necessary then return success now */
        else if (! type->ack)
            retval = true;
        else
        {
            int amount;

#ifdef LIBUSB_NO_THREADS_OPTION
            if (idev->libusbNoThreads)
#endif
#ifdef LIBUSB_NO_THREADS
            {
                /* unlock as soon as possible after all data has been sent */
                LeaveCriticalSection(&idev->devLock);
                unlocked = true;
            }
#endif

            /* using sendTimeout to ensure reader has necessary time
               to recieve the ack */
            amount = notified(idev->responsePipe[READ],
                              idev->settings->sendTimeout);
            if (amount < 0)
                message(LOG_ERROR, "Failed to read control ack: %s\n",
                        translateError(errno));
            else if (amount > 0)
            {
                dataPacket *pos;

                EnterCriticalSection(&idev->listLock);
                pos = idev->response;

                /* un-translate the SETID/WRITEBLOCK codes */
                if (request->code == IG_DEV_SETID &&
                    pos->code == IG_DEV_WRITEBLOCK)
                    pos->code = IG_DEV_SETID;

                errno = EINVAL;
                if (pos->code != IG_DEV_INVALID_ARG)
                {
                    if (pos->code != request->code)
                        message(LOG_ERROR,
                                "Bad ack for send: 0x%x != 0x%x\n",
                                pos->code, request->code);
                    else if (! payloadMatch((unsigned char)type->inData, (unsigned char)pos->dataLen))
                        message(LOG_ERROR, "Response size does not match specification (version 0x%x: %d != %d)\n", idev->version, pos->dataLen,type->inData);
                    else
                    {
                        /* store the retrieved response */
                        if (response != NULL)
                            *response = pos;
                        else
                            freeDataPacket(pos);
                        pos = NULL;

                        /* how long did this all take? */
                        now = microsSinceX();
                        message(LOG_INFO,
                                "Transaction: 0x%x (%lld microseconds)\n",
                                request->code, now - then);
                        retval = true;
                    }
                }

                freeDataPacket(pos);
                idev->response = NULL;
                LeaveCriticalSection(&idev->listLock);
            }
            else
            {
                message(LOG_INFO,
                        "Timeout while waiting for response from device.\n");
                errno = ETIMEDOUT;
            }
        }

#ifdef LIBUSB_NO_THREADS_OPTION
        if (idev->libusbNoThreads)
#endif
#ifdef LIBUSB_NO_THREADS
            /* certain errors may result in unlocking here */
            if (!unlocked)
                LeaveCriticalSection(&idev->devLock);
#endif
    }
示例#8
0
void Serveur::leave(QString chan)
{
    sendData(parseCommande("/part "+chan+ " "+msgQuit));
}
示例#9
0
void Serveur::readServeur()
{
        QString message=QString::fromUtf8(this->readAll());


	QString currentChan=tab->tabText(tab->currentIndex());

	if(message.startsWith("PING :"))
	{
		QStringList liste=message.split(" ");
		QString msg="PONG "+liste.at(1);
		sendData(msg);
	}
	else if(message.contains("Nickname is already in use."))
	{
        pseudo=pseudo+"_2";
		pseudo.remove("\r\n");
		sendData("NICK "+pseudo);
		emit pseudoChanged(pseudo);
        ecrire("-> Name changed to "+pseudo);
	}
        else if(updateUsers==true)
	{
		updateUsersList("",message);
	}

    QStringList list=message.split("\r\n");
        foreach(QString msg,list)
        {
            if(msg.contains(QRegExp(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9][email protected][a-zA-Z0-9\\/\\.-]+ PRIVMSG ([a-zA-Z0-9\\#]+) :(.+)")))
            {
                QRegExp reg(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9][email protected][a-zA-Z0-9\\/\\.-]+ PRIVMSG ([a-zA-Z0-9\\#]+) :(.+)");
                QString msg2=msg;
                    ecrire(msg.replace(reg,"\\2 <b>&lt;\\1&gt;</b> \\3"),"",msg2.replace(reg,"\\2 <\\1> \\3"));
            }
            else if(msg.contains(QRegExp(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9][email protected][a-zA-Z0-9\\/\\.-]+ JOIN ([a-zA-Z0-9\\#]+)")))
            {
                QRegExp reg(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9][email protected][a-zA-Z0-9\\/\\.-]+ JOIN ([a-zA-Z0-9\\#]+)");
                QString msg2=msg;
                ecrire(msg.replace(reg,"\\2 <i>-> \\1 join \\2</i><br />"),"",msg2.replace(reg,"-> \\1 join \\2"));
                updateUsersList(msg.replace(reg,"\\2"));
            }
            else if(msg.contains(QRegExp(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9][email protected][a-zA-Z0-9\\/\\.-]+ PART ([a-zA-Z0-9\\#]+)")))
            {
                QRegExp reg(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9][email protected][a-zA-Z0-9\\/\\.-]+ PART ([a-zA-Z0-9\\#]+) :(.+)");
                QString msg2=msg;
                ecrire(msg.replace(reg,"\\2 <i>-> \\1 quit \\2 (\\3)</i><br />"),"",msg2.replace(reg,"-> \\1 quit \\2"));
                updateUsersList(msg.replace(reg,"\\2"));
            }
            else if(msg.contains(QRegExp(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9][email protected][a-zA-Z0-9\\/\\.-]+ QUIT (.+)")))
            {
                QRegExp reg(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9][email protected][a-zA-Z0-9\\/\\.-]+ QUIT (.+)");
                QString msg2=msg;
                ecrire(msg.replace(reg,"\\2 <i>-> \\1 quit this server (\\2)</i><br />"),"",msg2.replace(reg,"-> \\1 left"));
                updateUsersList(msg.replace(reg,"\\2"));
            }
            else if(msg.contains(QRegExp(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9][email protected][a-zA-Z0-9\\/\\.-]+ NICK :(.+)")))
            {
                QRegExp reg(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9][email protected][a-zA-Z0-9\\/\\.-]+ NICK :(.+)");
                QString msg2=msg;
                ecrire(msg.replace(reg,"<i>\\1 is now called \\2</i><br />"),"",msg2.replace(reg,"-> \\1 is now called \\2"));
                updateUsersList(currentChan);
            }
            else if(msg.contains(QRegExp(":([a-zA-Z0-9]+)\\![a-zA-Z0-9][email protected][a-zA-Z0-9\\/\\.-]+ KICK ([a-zA-Z0-9\\#]+) ([a-zA-Z0-9]+) :(.+)")))
            { 
                QRegExp reg(":([a-zA-Z0-9]+)\\!~[a-zA-Z0-9][email protected][a-zA-Z0-9\\/\\.-]+ KICK ([a-zA-Z0-9\\#]+) ([a-zA-Z0-9]+) :(.+)");
                QString msg2=msg;
                ecrire(msg.replace(reg,"\\2 <i>-> \\1 kicked \\3 (\\4)</i><br />"),"",msg2.replace(reg,"-> \\1 quit \\3"));
                updateUsersList(msg.replace(reg,"\\2"));
            }
            else if(msg.contains(QRegExp(":([a-zA-Z0-9]+)\\![a-zA-Z0-9][email protected][a-zA-Z0-9\\/\\.-]+ NOTICE ([a-zA-Z0-9]+) :(.+)")))
            {
                if(conversations.contains(currentChan))
                {
                    QRegExp reg(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9][email protected][a-zA-Z0-9\\/\\.-]+ NOTICE [a-zA-Z0-9]+ :(.+)");
                    ecrire(msg.replace(reg,"<b>[NOTICE] <i>\\1</i> : \\2 <br />"),currentChan);
                }
                else if(currentChan==serveur)
                {
                    QRegExp reg(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9][email protected][a-zA-Z0-9\\/\\.-]+ NOTICE [a-zA-Z0-9]+ :(.+)");
                    ecrire(msg.replace(reg,"<b>[NOTICE] <i>\\1</i> : \\2 <br />"));
                }
            }
            else if(msg.contains("/MOTD command."))
            {
             joins();


            }



        }

        //}
}
示例#10
0
void eDVBCISlot::process_tpdu(unsigned char tpdu_tag, __u8* data, int asn_data_length, int con_id)
{
	switch (tpdu_tag)
	{
		case T_C_T_C_REPLY:
			printf("Got CTC Replay (slot %d, con %d)\n", getSlotID(), connection_id);

			tx_time.tv_sec = 0;

			state = stateInserted;

			//answer with data last (and if we have with data)
			sendData(NULL, 0);

			break;
		case T_DELETE_T_C:
//FIXME: close sessions etc; reset ?
//we must answer here with t_c_replay
			printf("Got \"Delete Transport Connection\" from module ->currently not handled!\n");
			break;
		case T_D_T_C_REPLY:
			printf("Got \"Delete Transport Connection Replay\" from module!\n");
			break;
		case T_REQUEST_T_C:
			printf("Got \"Request Transport Connection\" from Module ->currently not handled!\n");
			break;
		case T_DATA_MORE:
		{
			int new_data_length = receivedLen + asn_data_length;
			printf("Got \"Data More\" from Module\n");
			__u8 *new_data_buffer = (__u8*) realloc(receivedData, new_data_length);
			receivedData = new_data_buffer;
			memcpy(receivedData + receivedLen, data, asn_data_length);
			receivedLen = new_data_length;
			tx_time.tv_sec = 0;
			break;
		}
		case T_DATA_LAST:
#ifdef x_debug
			printf("Got \"Data Last\" from Module\n");
#endif
			tx_time.tv_sec = 0;
			/* single package */
			if (receivedData == NULL)
			{
				printf("->single package\n");
#ifdef x_debug
				printf("calling receiveData with data (len %d)> ", asn_data_length);
				for (int i = 0;i < asn_data_length; i++)
					printf("%02x ", data[i]);
				printf("\n");
#endif
				eDVBCISession::receiveData(this, data, asn_data_length);
				eDVBCISession::pollAll();
			}
			else
			{
				/* chained package */
				int new_data_length = receivedLen + asn_data_length;
				printf("->chained data\n");
				__u8 *new_data_buffer = (__u8*) realloc(receivedData, new_data_length);
				receivedData = new_data_buffer;
				memcpy(receivedData + receivedLen, data, asn_data_length);
				receivedLen = new_data_length;
#ifdef x_debug
				printf("calling receiveData with data (len %d)> ", asn_data_length);
				for (int i = 0;i < receivedLen; i++)
					printf("%02x ", receivedData[i]);
				printf("\n");
#endif
				eDVBCISession::receiveData(this, receivedData, receivedLen);
				eDVBCISession::pollAll();
//fixme: must also be moved in e2 behind the data processing ;)
				free(receivedData);
				receivedData = NULL;
				receivedLen = 0;
			}
			break;
		case T_SB:
		{
#ifdef x_debug
			printf("Got \"SB\" from Module\n");
#endif
			if (data[0] & 0x80)
			{
				printf("->data ready (%d)\n", getSlotID());
				// send the RCV and ask for the data
				unsigned char send_data[5];
				send_data[0] = getSlotID();
				send_data[1] = connection_id;
				send_data[2] = T_RCV;
				send_data[3] = 1;
				send_data[4] = connection_id;
				write(fd, send_data, 5);
				gettimeofday(&tx_time, 0);
			}
			else
			{
				tx_time.tv_sec = 0;
			}
			break;
		}
		default:
			printf("unhandled tpdu_tag 0x%0x\n", tpdu_tag);
	}
}
// move one servo at goal position 0 - 1024
void HerkulexClass::moveOne(int servoID, int Goal, int pTime, int iLed)
{
  if (Goal > 1023 || Goal < 0) return;              // speed (goal) non correct
  if ((pTime <0) || (pTime > 2856)) return;

  // Position definition
  int posLSB=Goal & 0X00FF;								// MSB Pos
  int posMSB=(Goal & 0XFF00) >> 8;						// LSB Pos

  //led 
  int iBlue=0;
  int iGreen=0;
  int iRed=0;
  switch (iLed) {
  case 1:
    iGreen=1;
    break;
  case 2:
    iBlue=1;
    break;
  case 3:
    iRed=1;
    break;
  }
  int SetValue=iGreen*4+iBlue*8+iRed*16;	//assign led value 

  playTime=int((float)pTime/11.2);			// 8. Execution time

  pSize = 0x0C;          			    	// 3.Packet size 7-58
  cmd   = HSJOG;              				// 5. CMD

  data[0]=posLSB;               			// 8. speedLSB
  data[1]=posMSB;               			// 9. speedMSB
  data[2]=SetValue;                         // 10. Mode=0;
  data[3]=servoID;                    		// 11. ServoID

    pID=servoID^playTime;

  lenghtString=4;             				// lenghtData

  ck1=checksum1(data,lenghtString);			//6. Checksum1
  ck2=checksum2(ck1);						//7. Checksum2

  pID=servoID;

  dataEx[0] = 0xFF;				// Packet Header
  dataEx[1] = 0xFF;				// Packet Header	
  dataEx[2] = pSize;	 		// Packet Size
  dataEx[3] = pID;				// Servo ID
  dataEx[4] = cmd;				// Command Ram Write
  dataEx[5] = ck1;				// Checksum 1
  dataEx[6] = ck2;				// Checksum 2
  dataEx[7] = playTime;  		// Execution time	
  dataEx[8] = data[0];
  dataEx[9] = data[1];
  dataEx[10] = data[2];
  dataEx[11] = data[3];

  sendData(dataEx, pSize);

}
示例#12
0
unsigned NetClient::sendString(const std::string &s) throw(const SocketException &)
{
  return sendData(s.data(), s.length());
}
示例#13
0
void expanderReset(void)
{
	sendData(0xF);
}
示例#14
0
void IDW:: execute()
{
//get resolution of input cloud
  pcl::PointXYZI minp,maxp;
  pcl::getMinMax3D(*m_baseCloud->get_Cloud(),minp,maxp);
    //float res = in->get_intValue()/100.0;
  pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_idw (new pcl::PointCloud<pcl::PointXYZI>);


  pcl::octree::OctreePointCloudSearch<pcl::PointXYZI> ocs (m_resolution);
  ocs.setInputCloud (m_baseCloud->get_Cloud());
  ocs.addPointsFromInputCloud ();


  float lenght = maxp.x - minp.x + m_resolution;
  int per = 90/lenght;
  int percent =0;
emit percentage(percent+=5);
  for(float i = minp.x; i <  (maxp.x+m_resolution); i= i + m_resolution)
  {
    for(float j = minp.y; j <  (maxp.y+m_resolution);j = j + m_resolution)
    {
      std::vector<int> pIv;
      std::vector<float> pSv;
      pcl::PointXYZI spV;
      float z_coor=0;
      spV.x = i;
      spV.y = j;
      spV.z = (minp.z+maxp.z)/2;
      if(ocs.nearestKSearch(spV, m_pointsnum*3, pIv, pSv) > 0 )
      {

        for(int c=0; c< pIv.size(); c++)
        {
          z_coor +=m_baseCloud->get_Cloud()->points.at(pIv.at(c)).z;
        }
        z_coor/=pIv.size();
      }
      std::vector<int> pointIv;
      std::vector<float> pointSv;
      pcl::PointXYZI searchPointVV;
        // pro dany bod najdi 10 nejblizsich bodu
      searchPointVV.x = i;
      searchPointVV.y = j;
      searchPointVV.z = z_coor;


      if(ocs.nearestKSearch(searchPointVV, m_pointsnum, pointIv, pointSv) > 0 )
      {

        float w_sum = 0;
        float z_sum = 0;
        float intensity = m_baseCloud->get_Cloud()->points.at(pointIv.at(0)).intensity;

        // w_sum
        for(int q =0; q <pointIv.size(); q++)
        {
          float w = 1/pointSv.at(q);
          w_sum+= w;
        }
        //z_sum
        for(int e = 0; e < pointIv.size(); e++)
        {
          float w = 1/pointSv.at(e);
          float z= (w * m_baseCloud->get_Cloud()->points.at(pointIv.at(e)).z)/w_sum ;
          z_sum+= z;
        }
        pcl::PointXYZI bod;
        bod.x= searchPointVV.x;
        bod.y= searchPointVV.y;
        bod.z= z_sum;
        bod.intensity= intensity;
        //#pragma omp critical
        cloud_idw->points.push_back(bod);
        }
      }
      emit percentage(percent+= per);
    }
    cloud_idw->width = cloud_idw->points.size ();
    cloud_idw->height = 1;
    cloud_idw->is_dense = true;

    m_output->set_Cloud(cloud_idw);
    emit percentage(100);
    sendData();
}
示例#15
0
int Client::sendData(SmartCom::string data)
{
	return sendData(data.c_str());
}
示例#16
0
文件: irc.cpp 项目: neiko/bottie
void Irc::parse(QString raw) {
  if (raw.startsWith(':'))
    raw = raw.right(raw.length() - 1);

#ifdef COLOR_WIPE
  QString xraw; int len = 0; int olen = raw.length();
  // dirty but useful color removal code
  do {
    do {
      if ( raw [len] == '\003' ) { // color, veo muuucho color
        len += 2;
        if ( raw [len].isNumber() ) len++;
        if ( raw [len] == ',' && raw [len+1].isDigit() ) { // color, veo aúuuun más color
          len += 2;
          if ( raw [len].isNumber() ) len++;
        }
      } else if ( raw [len] == '\002' || raw [len] == '\026' || raw [len] == '\035' ) // blablalba
        len++;
    } while ( raw [len] == '\003' || raw [len] == '\002'|| raw [len] == '\026'||
              raw [len] == '\035' ); // esto es una guarrada pero evita varios control codes consecutivos
      xraw.append(raw[len]);
      len++;
  } while( len < olen );
  raw = xraw;
#endif

  QStringList matrix = raw.split(' ');
  if( matrix[0] == "PING" ) { // Recibido ping, pongoneamos.
    sendData("PONG " + matrix[1]);
    emit PingPong();

  } else if ( matrix[0] == "ERROR" ) { // error de conexion, whichever
    emit connError(raw.right(raw.length() - 7)); //quita el "ERROR :" del principio y deja el msj limpio

  } else if ( matrix[1] == "PRIVMSG" || matrix[1] == "NOTICE" ) {
    QString nick = matrix[0].left(matrix[0].indexOf('!'));
    QString message = raw.right((raw.length() - 2) - raw.indexOf(" :"));
    QString mask = matrix[0].mid(matrix[0].indexOf('!') + 1,(matrix[0].indexOf(" PRIVMSG") - nick.length()));

    if ( matrix[1] == "PRIVMSG" ) {
      if ( matrix[2].startsWith("#") ) { // mensaje de canal
        if ( message.startsWith("\001") ) // /ctcp
          if ( message.startsWith("\001ACTION ")) // me
            emit chanme ( nick, mask, matrix[2], message.right((message.length() - 8)) );
          else
            emit chanctcp ( nick, mask, matrix[2], message.right((message.length() - 1)) );
        else
          emit chanmsg ( nick, mask, matrix[2], message );
      } else { // mensaje en privado
        if ( message.startsWith("\001") ) // /me
          if ( message.startsWith("\001ACTION ")) // me
            emit queryme ( nick, mask, message.right((message.length() - 8)) );
          else
            emit queryctcp ( nick, mask, message.right((message.length() - 1)) );
        else
          emit querymsg ( nick, mask, message );
      }
    } else if ( matrix[1] == "NOTICE" ) {
      if ( matrix[2].startsWith("#") ) { // notice en canal
        emit channotice ( nick, mask, matrix[2], message );
      } else { // notice en privado
        emit querynotice ( nick, mask, message );
      }
    }
  } else if ( matrix[1] == "JOIN" ) { //join a un canal
    QString nick = matrix[0].left(matrix[0].indexOf('!'));
    QString mask = matrix[0].mid(matrix[0].indexOf('!') + 1,(matrix[0].indexOf(" JOIN") - nick.length()));
    if( matrix[2].startsWith(':') )
        emit join(nick,mask,matrix[2].right( matrix[2].length() -1 ));
      else
        emit join(nick,mask,matrix[2]);

  } else if ( matrix[1] == "PART" || matrix[1] == "QUIT" ) { //handled together
    QString message = "", chan = "";
    if (raw.indexOf(" :") != -1)
      message = raw.right((raw.length() - 2) - raw.indexOf(" :"));
    QString nick = matrix[0].left(matrix[0].indexOf('!'));
    QString mask = matrix[0].mid(matrix[0].indexOf('!') + 1,(matrix[0].indexOf(" PART") - nick.length()));

    if ( matrix[1] == "PART" ) {
      QString chan = raw.right((raw.length() - 1) - raw.indexOf(" #"));
      chan = chan.left(chan.indexOf(" :"));
      QString mask = matrix[0].mid(matrix[0].indexOf('!') + 1,(matrix[0].indexOf(" PART") - nick.length()));
      emit part(nick,mask,chan,message);
    } else if ( matrix[1] == "QUIT" ) {
      QString mask = matrix[0].mid(matrix[0].indexOf('!') + 1,(matrix[0].indexOf(" QUIT") - nick.length()));
      emit quit(nick,mask,message);
    }
  } else if ( matrix[1] == "NICK" ) {
    QString nick = matrix[0].left(matrix[0].indexOf('!'));
    QString mask = matrix[0].mid(matrix[0].indexOf('!') + 1,(matrix[0].indexOf(" NICK") - nick.length()));
    QString newnick = raw.right((raw.length() - 2) - raw.indexOf(" :"));
    if (newnick == ownNick)
      emit ownNickChange(newnick);
    emit nickChange(nick,mask,newnick);
  } else if ( matrix[1] == "MODE" ) { // cambio de modo, pero no sé si es de usuario o canal.
    if ( matrix[2].startsWith('#') ) { // c mode
      QString nick = matrix[0].left(matrix[0].indexOf('!'));
      QString mask = matrix[0].mid(matrix[0].indexOf('!') + 1,(matrix[0].indexOf(" MODE") - nick.length()));
      QString chan = matrix[2];
      QString mode = raw.right((raw.length() - raw.indexOf(" #")) - chan.length() - 2);
      emit modeChange(nick,mask,chan,mode);
    } else { // u mode
      if( matrix[3].startsWith(':') )
        emit umodeChange(matrix[0],matrix[2],matrix[3].right( matrix[3].length() -1 ));
      else
        emit umodeChange(matrix[0],matrix[2],matrix[3]);
    }
  } else if ( matrix[1] == "KICK" ) { // expulsión del canal
    if ( matrix[2].startsWith('#') ) { // c mode
      QString nick = matrix[0].left(matrix[0].indexOf('!'));
      QString mask = matrix[0].mid(matrix[0].indexOf('!') + 1,(matrix[0].indexOf(" KICK") - nick.length()));
      QString chan = matrix[2];
      QString kicked = matrix[3];
      QString message;
      if (raw.indexOf(" :") != -1)
        message = raw.right((raw.length() - 2) - raw.indexOf(" :"));
      emit kick(nick,mask,chan,kicked,message);
    }
    else // u mode
      emit umodeChange(matrix[0],matrix[2],raw.right((raw.length() - 2) - raw.indexOf(" :")));
  }
  bool isInt;
  int code_msg = matrix[1].toInt( &isInt );
  if( isInt ) {
    switch ( code_msg ) {
      case 001: // me es útil, así sé con qué nick entro xD
        emit ownNickChange(matrix[2]);
        ownNick = matrix[2];
        if (!chans.isEmpty()) {
          sendData("JOIN ",true);
          sendData(chans);
        }
        status = STATUS_IDLE;
        emit signedIn();
        break;
      case 254: // número de canales formados
        emit totalChans(matrix[3]);
      case 321: // chanlist begin
        handleChanlist(false);
        break;
      case 322: // chanlist
        handleChanlist(matrix[3],matrix[4],raw.right((raw.length() - 2) - raw.indexOf(" :")));
        break;
      case 323: // chanlist end
        handleChanlist(true);
        break;
      case 332: //topic
        emit topic(matrix[3],raw.right((raw.length() - 2) - raw.indexOf(" :")));
        break;
      case 333: //topic timestamp
        emit topicTime(matrix[3],matrix[4],matrix[5]);
        break;
      case 353: // names
        emit names(matrix[4], raw.right((raw.length() - 2) - raw.indexOf(" :")));
        break;
      case 366: // fin de /names
        emit namesEnd(matrix[3]);
        break;
      case 372: // texto de motd
        emit motd( raw.right((raw.length() - 2) - raw.indexOf(" :")));
        break;
      case 375: // inicio de motd
        emit motdStart( raw.right((raw.length() - 2) - raw.indexOf(" :")));
        break;
      case 376: // fin de motd
        emit motdEnd( raw.right((raw.length() - 2) - raw.indexOf(" :")));
        break;
      case 433: // nick en uso!
        getNewRandomNick();
        break;
      case 471:
        qDebug() << matrix[3] << "Cannot join channel (+l)";
        break;
      case 473:
        qDebug() << matrix[3] << "Cannot join channel (+i)";
        break;
      case 474:
        qDebug() << matrix[3] << "Cannot join channel (+b)";
        break;
      case 475:
        qDebug() << matrix[3] << "Cannot join channel (+k)";
        break;
      default:
        //qDebug() << "Numeric NO MANEJADO!" << matrix[1] << endl;
        break;
    }
  }
}
void oled_flush()
{
	resetPosition();

	/*shao CHIPSELECT(MODE_DATA)
	{
		debugPin_spi(HIGH);

		// Here we load a byte from the global variable buffer into a fast local variable.
		// This is done while we're waiting for the SPI transfer to complete.
		// Delay cycles is also used to replace loop_until_bit_is_set().
		// In total, we go from ~3.84ms transfer time of the basic loop to ~2.31ms using local variables and delay cycles. (4MHz SPI, 1KB frame buffer)
		// As an added bonus we clear the frame buffer with the extra clock cycles which means we don't have to wait for memset() to clear it later on.
		// The minimum possible transfer time for 4MHz SPI and 1KB frame buffer is 2.048ms. 12.5% overhead (1 cycle to read SPSR, 1 cycle to set SPDR)... not bad :3

		for(uint i=0;i<FRAME_BUFFER_SIZE;i++)
		{
			byte next = oledBuffer[i]; // Load next byte
			oledBuffer[i] = 0x00; // Clear buffer byte

			// At max speed SPI takes 16 cycles to send a byte
			// 8 cycles were used to increment the loop counter, compare the counter, loading next byte and clearing buffer byte
			// 8 cycles are left
			//shao __builtin_avr_delay_cycles(8);

			SPSR; // Need to read register to clear SPIF

			SPDR = next; // Send byte
		}

		// After sending the last byte the for loop exits, so we need to wait for the transfer to finish here
		//shao __builtin_avr_delay_cycles(14);
		SPSR;
		//loop_until_bit_is_set(SPSR, SPIF);

		// Original method
		//for(uint i=0;i<FRAME_BUFFER_SIZE;i++)
		//	spi_transfer_nr(oledBuffer[i]);

		debugPin_spi(LOW);
	}*/

    /*shao if (watchConfig.display180) 
    {
        for (uint i = (FRAME_BUFFER_SIZE-1); i >=0; i--) 
        {
            byte next = oledBuffer[i]; // Load next byte
            oledBuffer[i] = 0x00; // Clear buffer byte

            sendData(next);
        }
    }else
    {*/
        for (uint i = 0; i < FRAME_BUFFER_SIZE; i++) 
        {
            //Serial.print(oledBuffer[i]);
            byte next = oledBuffer[i]; // Load next byte
            oledBuffer[i] = 0x00; // Clear buffer byte

            sendData(next);
        }
    //shao }
}
示例#18
0
void BoxitSocket::sendData(quint16 msgID) {
    sendData(msgID, QByteArray());
}
示例#19
0
文件: client.c 项目: mannias/SO
void getFee(){
	sendData(0, fillMessageData("user", "fee", username), sizeof(Message));
	getResponce(0);
}
示例#20
0
static void sendCommand (const int command, const int chip)
{
    digitalWrite (RS, 0) ;
    sendData     (command, chip) ;
    digitalWrite (RS, 1) ;
}
示例#21
0
eBitrateCalc::eBitrateCalc(int pid, int dvbnamespace, int tsid, int onid, int refreshintervall, int buffer_size): m_size(0), m_refresh_intervall(refreshintervall)
{
	m_send_data_timer = eTimer::create(eApp);
	CONNECT(m_send_data_timer->timeout, eBitrateCalc::sendDataTimerTimeoutCB);
	eDVBChannelID chid; //(eDVBNamespace(dvbnamespace), eTransportStreamID(tsid), eOriginalNetworkID(onid));  <-- weird, that does not work
	chid.dvbnamespace = eDVBNamespace(dvbnamespace);
	chid.transport_stream_id = eTransportStreamID(tsid);
	chid.original_network_id = eOriginalNetworkID(onid);
	ePtr<eDVBResourceManager> res_mgr;
	eDVBResourceManager::getInstance(res_mgr);
	eUsePtr<iDVBChannel> channel;
	int success = 0;
	m_reader = NULL;
	if (!res_mgr->allocateChannel(chid, channel, false))
	{
		ePtr<iDVBDemux> demux;
		if (!channel->getDemux(demux))
		{
			if (!demux->createPESReader(eApp, m_reader))
			{
				if (!m_reader->connectRead(slot(*this, &eBitrateCalc::dataReady), m_pes_connection))
				{
					channel->connectStateChange(slot(*this, &eBitrateCalc::stateChange), m_channel_connection);
					success = 1;
				}
				else
					eDebug("[eBitrateCalc] connect pes reader failed...");
			}
			else
				eDebug("[eBitrateCalc] create PES reader failed...");
		}
		else 
			eDebug("[eBitrateCalc] getDemux failed...");
	}
	else
	{
		eDebug("[eBitrateCalc] allocate channel failed...trying pvr_allocate_demux");
		ePtr<eDVBAllocatedDemux> pvr_allocated_demux;
		int i = 0;
		if (!res_mgr->allocateDemux(NULL,pvr_allocated_demux,i))
		{
			eDVBDemux &demux = pvr_allocated_demux->get();
			if (!demux.createPESReader(eApp, m_reader))
			{
				if (!m_reader->connectRead(slot(*this, &eBitrateCalc::dataReady), m_pes_connection))
					success = 1;
				else
					eDebug("[eBitrateCalc] connect pes reader failed...");
			}
			else
				eDebug("[eBitrateCalc] create PES reader failed...");
		}
		else
			eDebug("[eBitrateCalc] allocate pvr_allocated_demux failed...");
	}
	if (m_reader and success)
	{
		clock_gettime(CLOCK_MONOTONIC, &m_start);
		m_reader->setBufferSize(buffer_size);
		m_reader->start(pid);
		m_send_data_timer->start(m_refresh_intervall, true);
	}
	else
		sendData(-1,0);
}
示例#22
0
void US2066::print(char c)
{
  sendData(c);
}
示例#23
0
/**
 * @brief Send data from a string to any connected partners.
 *
 * @param[in] str A string from which sequence of bytes will be used to send to the partner.
 */
void SockServ::sendData(std::string str) {
	sendData((uint8_t *)str.data(), str.size());
} // sendData
示例#24
0
void US2066::init() {
  // *** I2C initialization from the OLEDM1602 datasheet *** //
  delay(100);
  Wire.begin();
  
  
  //Disable internal regulator
  //sendCommand(0x2a); //RE=1
  //sendCommand(0x71);
  //sendCommand(0x00);
  //sendCommand(0x28); //RE=0, IS=0

  //set display to OFF
  sendCommand(0x08);

  //Set display clock devide ratio, oscillator freq
  sendCommand(0x2a); //RE=1
  sendCommand(0x79); //SD=1
  sendCommand(0xd5);
  sendCommand(0x70);
  sendCommand(0x78); //SD=0

  //Set display mode
  sendCommand(0x08);

  //Set remap
  sendCommand(0x06);

  //CGROM/CGRAM Management
  sendCommand(0x72);
  sendData(0x01);    //ROM A
  
  //Set OLED Characterization
  sendCommand(0x2a); //RE=1
  sendCommand(0x79); //SD=1
  
  
  //Set SEG pins Hardware configuration
  sendCommand(0xda);
  sendCommand(0x10);

  //Set contrast control
  sendCommand(0x81);
  sendCommand(0xff);

  //Set precharge period
  sendCommand(0xd9);
  sendCommand(0xf1);

  //Set VCOMH Deselect level
  sendCommand(0xdb); 
  sendCommand(0x30);

  //Exiting Set OLED Characterization
  sendCommand(0x78); //SD=0
  sendCommand(0x28); //RE=0, IS=0

  //Clear display
  sendCommand(0x01);

  //Set DDRAM Address
  sendCommand(0x80);

  delay(100);
  //Set display to ON
  sendCommand(0x0c);
  
  
}
示例#25
0
/**
 * @brief Send data to the HTTP caller.
 * Send the data to the HTTP caller.  No further data should be sent after this call.
 * @param [in] data The data to be sent to the HTTP caller.
 * @return N/A.
 */
void WebServer::HTTPResponse::sendData(const std::string& data) {
	sendData((uint8_t*) data.data(), data.length());
} // sendData
bool CTimeServerThread::send(const wxArrayString &words, unsigned int hour, unsigned int min)
{
    unsigned int idA = CHeaderData::createId();
    unsigned int idB = CHeaderData::createId();
    unsigned int idC = CHeaderData::createId();
    unsigned int idD = CHeaderData::createId();
    unsigned int idE = CHeaderData::createId();

    CHeaderData header;
    header.setMyCall1(m_callsign);
    header.setRptCall1(m_callsignG);
    header.setRptCall2(m_callsign);		// Just for the slow data header
    header.setYourCall(wxT("CQCQCQ  "));
    header.setDestination(m_address, G2_DV_PORT);

    wxString slowData;
    switch (m_language) {
    case LANG_DEUTSCH_1:
    case LANG_DEUTSCH_2:
        header.setMyCall2(wxT("ZEIT"));
        slowData.Printf(wxT("Es ist %02u:%02u Uhr"), hour, min);
        break;
    case LANG_FRANCAIS:
        header.setMyCall2(wxT("TIME"));
        slowData.Printf(wxT("Il est %02u:%02u"), hour, min);
        break;
    case LANG_NEDERLANDS:
        header.setMyCall2(wxT("TIJD"));
        slowData.Printf(wxT("Het is %02u:%02u"), hour, min);
        break;
    case LANG_SVENSKA:
        header.setMyCall2(wxT("TID "));
        slowData.Printf(wxT("Klockan ar %02u:%02u"), hour, min);
        break;
    case LANG_ENGLISH_US_1:
    case LANG_ENGLISH_UK_1:
        header.setMyCall2(wxT("TIME"));
        if (hour == 0U)
            slowData.Printf(wxT("It is 12:%02u AM"), min);
        else if (hour == 12U)
            slowData.Printf(wxT("It is 12:%02u PM"), min);
        else if (hour > 12U)
            slowData.Printf(wxT("It is %02u:%02u PM"), hour - 12U, min);
        else
            slowData.Printf(wxT("It is %02u:%02u AM"), hour, min);
        break;
    default:
        header.setMyCall2(wxT("TIME"));
        slowData.Printf(wxT("It is %02u:%02u"), hour, min);
        break;
    }

    m_encoder.setHeaderData(header);
    m_encoder.setTextData(slowData);

    m_in = 0U;

    if (m_format != FORMAT_TEXT_TIME) {
        wxString text = words.Item(0U);
        for (unsigned int i = 1U; i < words.GetCount(); i++) {
            text.Append(wxT(" "));
            text.Append(words.Item(i));
        }

        text.Replace(wxT("_"), wxT(" "));
        wxLogMessage(wxT("Sending voice \"%s\", sending text \"%s\""), text.c_str(), slowData.c_str());

        m_seqNo = 0U;

        // Build the audio
        lookup(wxT(" "));
        lookup(wxT(" "));
        lookup(wxT(" "));
        lookup(wxT(" "));

        for (unsigned int i = 0U; i < words.GetCount(); i++)
            lookup(words.Item(i));

        lookup(wxT(" "));
        lookup(wxT(" "));
        lookup(wxT(" "));
        lookup(wxT(" "));

        end();
    } else {
        wxLogMessage(wxT("Sending text \"%s\""), slowData.c_str());

        for (unsigned int i = 0U; i < 21U; i++) {
            CAMBEData* dataOut = new CAMBEData;
            dataOut->setDestination(m_address, G2_DV_PORT);
            dataOut->setSeq(i);

            unsigned char buffer[DV_FRAME_LENGTH_BYTES];
            ::memcpy(buffer + 0U, NULL_AMBE_DATA_BYTES, VOICE_FRAME_LENGTH_BYTES);

            // Insert sync bytes when the sequence number is zero, slow data otherwise
            if (i == 0U) {
                ::memcpy(buffer + VOICE_FRAME_LENGTH_BYTES, DATA_SYNC_BYTES, DATA_FRAME_LENGTH_BYTES);
                m_encoder.sync();
            } else {
                m_encoder.getTextData(buffer + VOICE_FRAME_LENGTH_BYTES);
            }

            dataOut->setData(buffer, DV_FRAME_LENGTH_BYTES);

            m_data[m_in] = dataOut;
            m_in++;
        }

        CAMBEData* dataOut = new CAMBEData;
        dataOut->setData(END_PATTERN_BYTES, DV_FRAME_LENGTH_BYTES);
        dataOut->setDestination(m_address, G2_DV_PORT);
        dataOut->setSeq(0U);
        dataOut->setEnd(true);

        m_data[m_in] = dataOut;
        m_in++;
    }

    if (m_in == 0U) {
        wxLogWarning(wxT("Not sending, no audio files loaded"));
        return false;
    }

    if (!m_callsignA.IsEmpty()) {
        header.setRptCall2(m_callsignA);
        header.setId(idA);
        sendHeader(header);
    }

    if (!m_callsignB.IsEmpty()) {
        header.setRptCall2(m_callsignB);
        header.setId(idB);
        sendHeader(header);
    }

    if (!m_callsignC.IsEmpty()) {
        header.setRptCall2(m_callsignC);
        header.setId(idC);
        sendHeader(header);
    }

    if (!m_callsignD.IsEmpty()) {
        header.setRptCall2(m_callsignD);
        header.setId(idD);
        sendHeader(header);
    }

    if (!m_callsignE.IsEmpty()) {
        header.setRptCall2(m_callsignE);
        header.setId(idE);
        sendHeader(header);
    }

    unsigned int out = 0U;

    wxStopWatch timer;
    timer.Start();

    for (;;) {
        unsigned int needed = timer.Time() / DSTAR_FRAME_TIME_MS;

        while (out < needed) {
            CAMBEData* data = m_data[out];
            m_data[out] = NULL;
            out++;

            if (!m_callsignA.IsEmpty()) {
                data->setId(idA);
                sendData(*data);
            }

            if (!m_callsignB.IsEmpty()) {
                data->setId(idB);
                sendData(*data);
            }

            if (!m_callsignC.IsEmpty()) {
                data->setId(idC);
                sendData(*data);
            }

            if (!m_callsignD.IsEmpty()) {
                data->setId(idD);
                sendData(*data);
            }

            if (!m_callsignE.IsEmpty()) {
                data->setId(idE);
                sendData(*data);
            }

            delete data;

            if (m_in == out)
                return true;
        }

        ::wxMilliSleep(10UL);
    }
}
示例#27
0
static inline int sendString(int player, char *str){ uint16_t length = strlen(str)+1; sendData(player,(void *) str,length);
  return SUCC;
}
示例#28
0
int Client::sendData(int data)
{
	return sendData(i2str(data));
}
示例#29
0
文件: ssl.cpp 项目: carrotli/ansql
int SSL_write(SSL* ssl, const void* buffer, int sz)
{
    return sendData(*ssl, buffer, sz);
}
示例#30
0
void TM1628::update() {
  for (int i=0; i<14; i++)
    sendData(i, buffer[i]);
}