本文整理汇总了C++中sendBuffer函数的典型用法代码示例。如果您正苦于以下问题:C++ sendBuffer函数的具体用法?C++ sendBuffer怎么用?C++ sendBuffer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sendBuffer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KeyPressHandling
void KeyPressHandling(void) {
char c;
if ( kbhit() ) {
c = getchar();
if ( c == 'c' ) {
printf("YOU HIT 'c' ...NOW QUITTING\n");
exit(1);
}
if ( c == 'h' ) {
DEBUG(LOG_NOTICE, "Arming home");
sendBuffer(&PowerlinkCommand[Pmax_ARMHOME]);
}
if ( c == 'd' ) {
DEBUG(LOG_NOTICE, "Disarm");
sendBuffer(&PowerlinkCommand[Pmax_DISARM]);
}
if ( c == 'a' ) {
DEBUG(LOG_NOTICE, "Arming away");
sendBuffer(&PowerlinkCommand[Pmax_ARMAWAY]);
}
if ( c == 'g' ) {
DEBUG(LOG_NOTICE, "Get Event log");
sendBuffer(&PowerlinkCommand[Pmax_GETEVENTLOG]);
}
if ( c == 'r' ) {
DEBUG(LOG_NOTICE, "Request Status Update");
sendBuffer(&PowerlinkCommand[Pmax_REQSTATUS]);
}
}
}
示例2: sendBuffer
DRIVER_ERROR Hbpl1::FormFeed ()
{
if (0 != m_numScanLines && m_pbyStripData && 0 != m_nStripSize)
{
++m_nBandCount;
m_pHbpl1Wrapper->Encapsulate(m_pbyStripData, m_nStripSize, m_nStripHeight, (void**)&m_pOutBuffer, &m_OutBuffSize);
sendBuffer(m_pOutBuffer, m_OutBuffSize);
memset(m_pbyStripData,0xFF,m_nStripSize);
}
while(m_nBandCount < m_numStrips)
{
++m_nBandCount;
m_pHbpl1Wrapper->Encapsulate(m_pbyStripData, m_nStripSize, m_nStripHeight, (void**)&m_pOutBuffer, &m_OutBuffSize);
sendBuffer(m_pOutBuffer, m_OutBuffSize);
}
m_pHbpl1Wrapper->EndPage((void**)&m_pOutBuffer, &m_OutBuffSize);
sendBuffer(m_pOutBuffer, m_OutBuffSize);
m_pHbpl1Wrapper->FreeBuffer(m_pOutBuffer,m_OutBuffSize);
m_nBandCount = 0;
return NO_ERROR;
}
示例3: sendBuffer
int CSocket::sendMessage(CBuffer& pSource, char* pIp, int pPort)
{
if(udp)
return sendBuffer(pSource, pIp, pPort);
CBuffer sendBuff;
sendBuff.writeuShort(pSource.length());
sendBuff.writeBuffer(pSource);
return sendBuffer(sendBuff);
}
示例4: RELEASE_LOG_IF_ALLOWED
void NetworkResourceLoader::didReceiveBuffer(Ref<SharedBuffer>&& buffer, int reportedEncodedDataLength)
{
if (!m_hasReceivedData) {
RELEASE_LOG_IF_ALLOWED("didReceiveBuffer: Started receiving data (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ")", m_parameters.webPageID, m_parameters.webFrameID, m_parameters.identifier);
m_hasReceivedData = true;
}
#if ENABLE(NETWORK_CACHE)
ASSERT(!m_cacheEntryForValidation);
if (m_bufferedDataForCache) {
// Prevent memory growth in case of streaming data.
const size_t maximumCacheBufferSize = 10 * 1024 * 1024;
if (m_bufferedDataForCache->size() + buffer->size() <= maximumCacheBufferSize)
m_bufferedDataForCache->append(buffer.get());
else
m_bufferedDataForCache = nullptr;
}
#endif
// FIXME: At least on OS X Yosemite we always get -1 from the resource handle.
unsigned encodedDataLength = reportedEncodedDataLength >= 0 ? reportedEncodedDataLength : buffer->size();
m_bytesReceived += buffer->size();
if (m_bufferedData) {
m_bufferedData->append(buffer.get());
m_bufferedDataEncodedDataLength += encodedDataLength;
startBufferingTimerIfNeeded();
return;
}
sendBuffer(buffer, encodedDataLength);
}
示例5: ConfigHeader_hton
void ConfigChannel::readParamArray(cvg_int id, cvg_char *buffer, cvg_int length) {
cvg_bool closeChannelOnError = true;
try {
ConfigHeader header;
header.signature = PROTOCOL_CONFIG_SIGNATURE;
header.info.mode = CONFIG_READ;
header.info.paramId = id;
header.info.dataLength = 0;
ConfigHeader_hton(&header);
sendBuffer(&header, sizeof(ConfigHeader), true);
recvBuffer(&header, sizeof(ConfigHeader));
ConfigHeader_ntoh(&header);
if ((header.info.mode != CONFIG_WRITE && header.info.mode != CONFIG_NACK) || header.info.paramId != id) {
throw cvgException("bad response");
}
if (header.info.dataLength > length) {
throw cvgException("data too long");
}
if (header.info.mode == CONFIG_NACK) {
closeChannelOnError = false;
throw cvgException("bad parameter specification");
}
recvBuffer(buffer, length);
} catch(cvgException e) {
if (closeChannelOnError) close();
throw cvgException(cvgString("[ConfigChannel] Error writing parameter ID ") + id + ". Reason: " + e.getMessage());
}
}
示例6: sendBuffer
void WorkerProtocolImpl::sendSolution(const SolutionCertificate& solution)
{
msgpack::sbuffer sbuf;
msgpack::pack(&sbuf, static_cast<message_id_t>(SOLUTION_REPORT_ID));
msgpack::pack(&sbuf, solution);
sendBuffer(socket, sbuf);
}
示例7: sendHeader
void Settings::sendSysInfo()
{
if ( debug )
{
Serial.println ( "[I] Getting sysinfo json" );
}
sendHeader ( 200, "text/json", getSysInfoSize () );
String json = "{";
json += "\"freememory\":\"" + ( String ) ESP.getFreeHeap () + "\",";
json += "\"deauthpackets\":\"" + ( String ) deauthpackets + "\",";
json += "\"beaconpackets\":\"" + ( String ) beaconpackets + "\",";
json += "\"uptime\":\"" + ( String ) millis () + "\",";
json += "\"ipaddress\":\"" + ( String ) WiFi.localIP ().toString () + "\",";
json += "\"gateway\":\"" + ( String ) WiFi.gatewayIP ().toString () + "\",";
json += "\"bootmode\":\"" + ( String ) ESP.getBootMode () + "\",";
json += "\"bootversion\":\"" + ( String ) ESP.getBootVersion () + "\",";
json += "\"sdkversion\":\"" + ( String ) ESP.getSdkVersion () + "\",";
json += "\"chipid\":\"" + ( String ) ESP.getChipId () + "\",";
json += "\"flashchipid\":\"" + ( String ) ESP.getFlashChipId () + "\",";
json += "\"flashchipsize\":\"" + ( String ) ESP.getFlashChipSize () + "\",";
json += "\"flashchiprealsize\":\"" +
( String ) ESP.getFlashChipRealSize () +
"\"}";
sendToBuffer ( json );
sendBuffer ();
if ( debug )
{
Serial.println ( "\n[+] Done" );
}
}
示例8: openUsbDevice
void Communicator::initiateUsbConnection(uint32_t vendorId, uint32_t productId, uint32_t sessionId)
{
openUsbDevice((uint16_t)vendorId, (uint16_t)productId); //initUsbDevice((uint16_t)vendorId, (uint16_t)productId);
if (isInitialized())
{
// send back the vendorId and productId
int len = 4 + 4 + (PTP_HEADER * 2);
uint8_t *buf = (uint8_t *)malloc(len);
bzero(&buf[0], len);
*(uint32_t *)&buf[0] = (uint32_t)htole32(len);
setPtpHeader(buf, 4, PTP_HEADER + 4 , 0x0002, 0x0001, sessionId);
*(uint16_t *)&buf[4 + PTP_HEADER] = htole16(mVendorId);
*(uint16_t *)&buf[4 + PTP_HEADER + 2] = htole16(mProductId);
syslog(LOG_INFO, "vendor: %d product: %d", mVendorId, mProductId);
syslog(LOG_INFO, "vendor: %d product: %d", htole16(mVendorId), htole16(mProductId));
setPtpHeader(buf, 4 + PTP_HEADER + 4, PTP_HEADER , 0x0003, 0x2001, sessionId);
sendBuffer(buf, len);
free(buf);
} else
sendResponsePacket(isInitialized() ? 0x2001 : 0x2002, sessionId);
}
示例9: packetManager
void packetManager(struct PlinkBuffer * commandBuffer) {
if (deFormatBuffer(commandBuffer)) {
DEBUG(LOG_DEBUG, "Packet received");
logBuffer(LOG_DEBUG,commandBuffer);
int cmd_not_recognized=1;
int i;
for (i=0;i<Pmax_NBCOMMAND;i++) {
if (findCommand(commandBuffer, &PmaxCommand[i])) {
PmaxCommand[i].action(commandBuffer);
cmd_not_recognized=0;
break;
}
}
if ( cmd_not_recognized==1 ) {
DEBUG(LOG_INFO, "Packet not recognized");
logBuffer(LOG_INFO, commandBuffer);
sendBuffer(&PowerlinkCommand[Pmax_ACK]);
}
}
else {
DEBUG(LOG_ERR, "Packet not correctly formated");
logBuffer(LOG_ERR,commandBuffer);
}
//command has been treated, reset the commandbuffer
commandBuffer->size=0;
DEBUG(LOG_DEBUG, "End of packet treatment");
}
示例10: throw
void PollUGenInternal::processBlock(bool& shouldDelete, const unsigned int blockID, const int /*channel*/) throw()
{
const int numSamplesToProcess = uGenOutput.getBlockSize();
float* outputSamples = uGenOutput.getSampleData();
float* const trigSamples = inputs[Trig].processBlock(shouldDelete, blockID, 0);
for(int sample = 0; sample < numSamplesToProcess; sample++)
{
float thisTrig = trigSamples[sample];
if(thisTrig > 0.f && lastTrig <= 0.f)
{
const int numChannels = inputs[Input].getNumChannels();
Buffer poll = Buffer::newClear(numChannels);
float * const pollSamples = poll.getData(0);
for(int channel = 0; channel < numChannels; channel++)
{
float* const inputSamples = inputs[Input].processBlock(shouldDelete, blockID, channel);
pollSamples[channel] = inputSamples[sample];
}
sendBuffer(poll);
}
*outputSamples++ = 0.f;
lastTrig = thisTrig;
}
}
示例11: memcpy
DRIVER_ERROR Hbpl1::Encapsulate (RASTERDATA *InputRaster, bool bLastPlane)
{
DRIVER_ERROR err = NO_ERROR;
++m_nScanLineCount;
if ( m_numScanLines == -1)
{
if((int)m_JA.media_attributes.printable_height % m_nStripHeight)
m_numStrips++;
err = m_pHbpl1Wrapper->InitStripBuffer(m_nScanLineSize * 3 * m_nStripHeight);
}
if (m_numScanLines < m_nStripHeight && m_pbyStripData)
{
memcpy((BYTE*)&(m_pbyStripData[m_numScanLines * m_nScanLineSize * 3]),InputRaster->rasterdata[COLORTYPE_COLOR],InputRaster->rastersize[COLORTYPE_COLOR]);
m_numScanLines++;
}
if (m_numScanLines >= m_nStripHeight && m_pbyStripData)
{
++m_nBandCount;
m_pHbpl1Wrapper->Encapsulate(m_pbyStripData, m_nStripSize, m_nStripHeight, (void**)&m_pOutBuffer, &m_OutBuffSize);
memset(m_pbyStripData,0xFF,m_nStripSize);
m_numScanLines = 0;
err = sendBuffer(static_cast<const BYTE *>(m_pOutBuffer), m_OutBuffSize);
m_pHbpl1Wrapper->FreeBuffer(m_pOutBuffer, m_OutBuffSize);
}
return err;
}
示例12: main
void main()
{
lcdInit();
spiOn();
spiOff();
sendByte(out);
sendArray(array);
lcdOn();
lcdOff();
sendBuffer();
sendPart(3, 7, LCD_Buffer);
clear();
clearPart(5, 76);
clearPartColor(5, 76, clBLACK);
setPenColor(clBLACK);
setBackColor(clWHITE);
delay_nsek(40);
scsOn();
scsOff();
i = getValue(LCD_Buffer, 23, 266);
setValue(LCD_Buffer, 23, 266, 0x3F);
setCharge();
resetCharge();
drawPixel(5, 5, LCD_Buffer);
drawVLine(5, 5, 5, LCD_Buffer);
drawHLine(5, 5, 5, LCD_Buffer);
drawLine(5, 5, 55, 55, LCD_Buffer);
drawRect(5, 5, 55, 55, LCD_Buffer);
drawFillRect(5, 5, 55, 55, clWHITE, LCD_Buffer);
drawCircle(10, 10, 5, LCD_Buffer);
}
示例13: htonl
void UDPThread::prepareBuffer() {
uint8_t *packetBuffer = new uint8_t[m_payloadSize];
uint8_t *data;
ssize_t transmittedBytes = 0;
uint16_t frameCount = 0;
struct CannelloniDataPacket *dataPacket;
struct timeval currentTime;
m_frameBuffer->swapBuffers();
if (m_sort)
m_frameBuffer->sortIntermediateBuffer();
std::list<canfd_frame*> *buffer = m_frameBuffer->getIntermediateBuffer();
data = packetBuffer+CANNELLONI_DATA_PACKET_BASE_SIZE;
for (auto it = buffer->begin(); it != buffer->end(); it++) {
canfd_frame *frame = *it;
/* Check for packet overflow */
if ((data-packetBuffer
+CANNELLONI_FRAME_BASE_SIZE
+canfd_len(frame)
+((frame->len & CANFD_FRAME)?sizeof(frame->flags):0)) > m_payloadSize) {
/* Move all remaining frames back to m_buffer */
m_frameBuffer->returnIntermediateBuffer(it);
break;
}
canid_t tmp = htonl(frame->can_id);
memcpy(data, &tmp, sizeof(canid_t));
/* += 4 */
data += sizeof(canid_t);
*data = frame->len;
/* += 1 */
data += sizeof(frame->len);
/* If this is a CAN FD frame, also send the flags */
if (frame->len & CANFD_FRAME) {
*data = frame->flags;
/* += 1 */
data += sizeof(frame->flags);
}
if ((frame->can_id & CAN_RTR_FLAG) == 0) {
memcpy(data, frame->data, canfd_len(frame));
data+=canfd_len(frame);
}
frameCount++;
}
dataPacket = (struct CannelloniDataPacket*) packetBuffer;
dataPacket->version = CANNELLONI_FRAME_VERSION;
dataPacket->op_code = DATA;
dataPacket->seq_no = m_sequenceNumber++;
dataPacket->count = htons(frameCount);
transmittedBytes = sendBuffer(packetBuffer, data-packetBuffer);
if (transmittedBytes != data-packetBuffer) {
lerror << "UDP Socket error. Error while transmitting" << std::endl;
} else {
m_txCount++;
}
m_frameBuffer->unlockIntermediateBuffer();
m_frameBuffer->mergeIntermediateBuffer();
delete[] packetBuffer;
}
示例14: sendBuffer
/**
* addModel() - adds an opulence model to collection
*
* @params *model being added
*/
void BufferCourier::addModel(Model *model)
{
model->id = activeModels.size();
activeModels.push_back(model);
sendBuffer(model);
}
示例15: receiveBuffer
Socket::Error Socket::bufferSize(unsigned bufsize)
{
Error err = receiveBuffer(bufsize);
if(err == errSuccess)
err = sendBuffer(bufsize);
return err;
}