这篇教程C++ transmit函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中transmit函数的典型用法代码示例。如果您正苦于以下问题:C++ transmit函数的具体用法?C++ transmit怎么用?C++ transmit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了transmit函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: allocatevoid AudioInputI2SQuad::update(void){ audio_block_t *new1, *new2, *new3, *new4; audio_block_t *out1, *out2, *out3, *out4; // allocate 4 new blocks new1 = allocate(); new2 = allocate(); new3 = allocate(); new4 = allocate(); // but if any fails, allocate none if (!new1 || !new2 || !new3 || !new4) { if (new1) { release(new1); new1 = NULL; } if (new2) { release(new2); new2 = NULL; } if (new3) { release(new3); new3 = NULL; } if (new4) { release(new4); new4 = NULL; } } __disable_irq(); if (block_offset >= AUDIO_BLOCK_SAMPLES) { // the DMA filled 4 blocks, so grab them and get the // 4 new blocks to the DMA, as quickly as possible out1 = block_ch1; block_ch1 = new1; out2 = block_ch2; block_ch2 = new2; out3 = block_ch3; block_ch3 = new3; out4 = block_ch4; block_ch4 = new4; block_offset = 0; __enable_irq(); // then transmit the DMA's former blocks transmit(out1, 0); release(out1); transmit(out2, 1); release(out2); transmit(out3, 2); release(out3); transmit(out4, 3); release(out4); } else if (new1 != NULL) { // the DMA didn't fill blocks, but we allocated blocks if (block_ch1 == NULL) { // the DMA doesn't have any blocks to fill, so // give it the ones we just allocated block_ch1 = new1; block_ch2 = new2; block_ch3 = new3; block_ch4 = new4; block_offset = 0; __enable_irq(); } else { // the DMA already has blocks, doesn't need these __enable_irq(); release(new1); release(new2); release(new3); release(new4); } } else { // The DMA didn't fill blocks, and we could not allocate // memory... the system is likely starving for memory! // Sadly, there's nothing we can do. __enable_irq(); }}
开发者ID:Ben-Rheinland,项目名称:Audio,代码行数:78,
示例2: transmitvoidScrobSocket::stop(){ transmit( "STOP c=bof/n" );}
开发者ID:AICIDNN,项目名称:lastfm-desktop,代码行数:5,
示例3: whilevoid CDExtraClientThread::transmit(){ m_encodeData.clear(); m_dongle->setMode(DVDMODE_ENCODE); // Pause until all the silence data has been processed by the AMBE2020 unsigned int startCount = 30U; while (startCount > 0U) { unsigned char frame[DV_FRAME_LENGTH_BYTES]; unsigned int n = m_encodeData.getData(frame, VOICE_FRAME_LENGTH_BYTES); if (n > 0U) startCount--; Sleep(FRAME_TIME_MS / 4UL); } wxString rpt1 = m_reflector; rpt1.Append(wxT(" ")); rpt1.Truncate(LONG_CALLSIGN_LENGTH - 1U); rpt1.Append(m_module); wxString rpt2 = m_reflector; rpt2.Append(wxT(" ")); rpt2.Truncate(LONG_CALLSIGN_LENGTH - 1U); rpt2.Append(wxT('G')); CHeaderData* header = new CHeaderData(m_callsign, wxT("DNGL"), wxT("CQCQCQ "), rpt1, rpt2); m_slowDataEncoder.reset(); m_slowDataEncoder.setHeaderData(*header);#if defined(DUMP_AMBE) m_dumper = new CDVTOOLFileWriter; bool res = m_dumper->open(*header); if (!res) { delete m_dumper; m_dumper = NULL; } else { wxLogMessage(wxT("Dumping AMBE to %s"), m_dumper->getFileName().c_str()); m_dumper->writeHeader(*header); }#endif if (!m_message.IsEmpty()) m_slowDataEncoder.setMessageData(m_message); m_protocol.writeHeader(*header); delete header; m_frameCount = 20U; unsigned int endCount = 30U; // While transmitting and not exiting for (;;) { unsigned char frame[DV_FRAME_LENGTH_BYTES]; unsigned int n = m_encodeData.getData(frame, VOICE_FRAME_LENGTH_BYTES); if (n > 0U) { if (m_frameCount == 20U) { // Put in the data resync pattern ::memcpy(frame + VOICE_FRAME_LENGTH_BYTES, DATA_SYNC_BYTES, DATA_FRAME_LENGTH_BYTES); m_frameCount = 0U; } else { // Tack the slow data on the end m_slowDataEncoder.getData(frame + VOICE_FRAME_LENGTH_BYTES); m_frameCount++; } if (m_transmit != CLIENT_TRANSMIT) endCount--;#if defined(DUMP_AMBE) if (m_dumper != NULL) m_dumper->writeFrame(frame, DV_FRAME_LENGTH_BYTES);#endif // Send the AMBE and slow data frame if (endCount == 0U || m_killed) { m_protocol.writeData(frame, DV_FRAME_LENGTH_BYTES, true); break; } else { m_protocol.writeData(frame, DV_FRAME_LENGTH_BYTES, false); } if (m_tx) { if (m_squelchInvert) { if (m_controller->getSquelch()) { transmit(false); m_tx = false; } } else { if (!m_controller->getSquelch()) { transmit(false); m_tx = false; } } } } Sleep(FRAME_TIME_MS / 4UL); }//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:opendv-svn,代码行数:101,
示例4: _tmain//.........这里部分代码省略......... if ((index != WSA_WAIT_FAILED) && (index != WSA_WAIT_TIMEOUT)) { WSAEnumNetworkEvents(SocketArray[index], EventArray[index], &NetworkEvents); WSAResetEvent(EventArray[index]); toProxy = (index % 2) ? true : false; secondIndex = toProxy ? index + 1 : index - 1; if ((NetworkEvents.lNetworkEvents & FD_ACCEPT) && (NetworkEvents.iErrorCode[FD_ACCEPT_BIT] == 0)) { ClientSocket = accept(ListenSocket, NULL, NULL); if (INVALID_SOCKET == ClientSocket) wprintf(L"Invalid socket/n"); ProxySocket = socket(AF_INET, SOCK_STREAM, 0); if (INVALID_SOCKET == ProxySocket) wprintf(L"INVALID_SOCKET ERROR!!!/n"); iResult = connect(ProxySocket, remoteAddr->ai_addr, sizeof(SOCKADDR)); if (iResult != 0) { wprintf(L"Connection failed with error: %d/n", WSAGetLastError()); return -1; } printConnections(++connections); if (createEv(&NewEvent)) return -1; SocketArray[EventTotal] = ClientSocket; EventArray[EventTotal] = NewEvent; //------------------------- // Associate event types FD_READ and FD_CLOSE // with the client socket and NewEvent iResult = WSAEventSelect(SocketArray[EventTotal], EventArray[EventTotal], FD_READ | FD_CLOSE); if (iResult != 0) { wprintf(L"WSAEventSelect failed with error: %d/n", WSAGetLastError()); return -1; } EventTotal++; if (createEv(&NewEvent)) return -1; SocketArray[EventTotal] = ProxySocket; EventArray[EventTotal] = NewEvent; //------------------------- // Associate event types FD_READ and FD_CLOSE // with the proxy socket and NewEvent iResult = WSAEventSelect(SocketArray[EventTotal], EventArray[EventTotal], FD_READ | FD_CLOSE); if (iResult != 0) { wprintf(L"WSAEventSelect failed with error: %d/n", WSAGetLastError()); return -1; } EventTotal++; } if ((NetworkEvents.lNetworkEvents & FD_READ) && (NetworkEvents.iErrorCode[FD_READ_BIT] == 0)) { // transfers data iResult = transmit( &SocketArray[index], &SocketArray[secondIndex], toProxy, previousMessagesArray, index, targetName, hostName, remoteAddr->ai_addr, &EventArray[index]); if (iResult < 0) return -1; } if (NetworkEvents.lNetworkEvents & FD_CLOSE) { closesocket(SocketArray[secondIndex]); closesocket(SocketArray[index]); WSACloseEvent(EventArray[secondIndex]); WSACloseEvent(EventArray[index]); // Move from the top to the free place SocketArray[index] = toProxy ? SocketArray[EventTotal - 2] : SocketArray[EventTotal - 1]; SocketArray[secondIndex] = toProxy ? SocketArray[EventTotal - 1] : SocketArray[EventTotal - 2]; EventArray[index] = toProxy ? EventArray[EventTotal - 2] : EventArray[EventTotal - 1]; EventArray[secondIndex] = toProxy ? EventArray[EventTotal - 1] : EventArray[EventTotal - 2]; EventTotal -= 2; printConnections(--connections); } } } return 0;}
开发者ID:evgen941,项目名称:NegotiateProxy,代码行数:101,
示例5: uart1servvoid uart1serv(){ int r; int cts = 1; int rxtid; int txtid; int client_tid; char buf[BUFSIZE]; char dummy; /* We can receive a max of 64-bits from the controller at once, so have a * buffer of twice that size. The queue is controlled by head and tail, items * are removed from the head of the queue and removed from the tail. * XXX, ugh this should be moved into a library... */ char input_queue[QUEUESIZE]; int head = 0, tail = 0; int reader_queue[2]; // their TIDs char output_queue[OQUEUESIZE]; int ohead = 0, otail = 0; reader_queue[0] = 0; reader_queue[1] = 0; RegisterAs("com1");// DPRINTOK ("Creating uart1 rx notifier./n"); rxtid = Create(INTERRUPT, notifier_uart1rx); if (rxtid < 0) PANIC;// DPRINTOK ("Creating uart1 tx notifier./n"); txtid = Create(INTERRUPT, notifier_uart1tx); if (txtid < 0) PANIC; FOREVER { r = Receive(&client_tid, buf, BUFSIZE);// DPRINTOK("UART1: received from client tid %d, mesg of size %d, first char" // " %c/r/n", client_tid, r, buf[0]); if (r < 0 || r > BUFSIZE) PANIC; switch (buf[0]) { case 'i': // from client, reentrant getc if (head == tail) { Reply (client_tid, NULL, 0); } else { r = Reply(client_tid, &input_queue[head], 1); head = (head + 1) % QUEUESIZE; } break; case 'r': // from rxtd if (client_tid != rxtid) { DPRINTERR("UART1: WTF notifier didn't send us this RX, %d did/r/n", client_tid); PANIC; } if (Reply(client_tid, NULL, 0) != 0) PANIC; /* Too bad if we overrun the circular buffer. It should be big enough */ input_queue[tail] = buf[1]; tail = (tail + 1) % QUEUESIZE; // bwprintf (COM2, "got %c/n", buf[1]); if (reader_queue[0]) { // someone is waiting if (Reply(reader_queue[0], &input_queue[head], 1) != 0) PANIC; head = (head + 1) % QUEUESIZE; } break; case 'g': // from getc client if (head == tail) { // circular buffer is empty reader_queue[0] = client_tid; } else { r = Reply(client_tid, &input_queue[head], 1); head = (head + 1) % QUEUESIZE; //r = Reply(reader_queue[0], &input_queue[head++], 1); if (r != 0) { DPRINTERR("UART1: reply failed with %d retval to client tid %d/r/n", r, reader_queue[0]); PANIC; } } break; case 't': // from txtd if (client_tid != txtid) { DPRINTERR ("non-client sent a tx interrupt message./n"); PANIC; } if (cts >= 1) { DPRINTHUH ("Train controller reset maybe?"); Reply (client_tid, NULL, 0); } cts = 1; if (ohead != otail) { ohead = transmit (output_queue, ohead, otail); cts = 0; Reply (client_tid, &dummy, 1); // we need interrupts on for the cts stuff } else { Reply (client_tid, NULL, 0); // 0 means don't turn interrupts back on } break; case 'p': // from putc client //if (Reply(txtid, "putchar plz") != 0) PANIC; output_queue[otail] = buf[1]; otail = (otail + 1) % OQUEUESIZE; if (cts == 1) { ohead = transmit (output_queue, ohead, otail); cts = 0; //bwprintf (COM2, "sent a char (putc), now cts %d/n", cts); }//.........这里部分代码省略.........
开发者ID:kspaans,项目名称:StrombolOS,代码行数:101,
示例6: mainint main(int argc, char** argv) { struct option long_options[] = { { "gpio", 1, 0, 0 }, { "address", 1, 0, 0 }, { "command", 1, 0, 0 }, { "receiver", 1, 0, 0 }, { "retry", 1, 0, 0 }, { NULL, 0, 0, 0 } }; unsigned int address = 0; unsigned char receiver = 1; long int a2i; int gpio = -1; char command = UNKNOWN; char *end; int retry = 5, i, c; if (setuid(0)) { perror("setuid"); return -1; } while (1) { c = getopt_long(argc, argv, "", long_options, &i); if (c == -1) break; switch (c) { case 0: if (strcmp(long_options[i].name, "gpio") == 0) { a2i = strtol(optarg, &end, 10); if (errno == ERANGE && (a2i == LONG_MAX || a2i == LONG_MIN)) { break; } gpio = a2i; } else if (strcmp(long_options[i].name, "address") == 0) { a2i = strtol(optarg, &end, 10); if (errno == ERANGE && (a2i == LONG_MAX || a2i == LONG_MIN)) { break; } address = a2i; } else if (strcmp(long_options[i].name, "receiver") == 0) { a2i = strtol(optarg, &end, 10); if (errno == ERANGE && (a2i == LONG_MAX || a2i == LONG_MIN)) { break; } receiver = a2i; } else if (strcmp(long_options[i].name, "command") == 0) { command = get_command_char(optarg); } else if (strcmp(long_options[i].name, "command") == 0) { a2i = strtol(optarg, &end, 10); if (errno == ERANGE && (a2i == LONG_MAX || a2i == LONG_MIN)) { break; } retry = a2i; } break; default: usage(argv[0]); } } if (command == UNKNOWN || address == 0 || gpio == -1 || receiver == 0) { usage(argv[0]); } // store pid and lock it store_pid(); if (wiringPiSetup() == -1) { fprintf(stderr, "Wiring Pi not installed"); return -1; } openlog("homeasy", LOG_PID | LOG_CONS, LOG_USER); syslog(LOG_INFO, "remote: %d, receiver, %d, command: %d/n", address, receiver, command); closelog(); pinMode(gpio, OUTPUT); piHiPri(99); for (c = 0; c != retry; c++) { for (i = 0; i < 5; i++) { transmit(gpio, address, receiver, command); } sleep(1); } return 0;}
开发者ID:safchain,项目名称:domiotools,代码行数:86,
示例7: whilevoid CSoundCardRepeaterTXRXThread::run(){ // Wait here until we have the essentials to run while (!m_killed && (m_soundcard == NULL || m_protocolHandler == NULL || m_rptCallsign.IsEmpty() || m_rptCallsign.IsSameAs(wxT(" ")) || m_controller == NULL)) ::wxMilliSleep(500UL); // 1/2 sec if (m_killed) return; m_stopped = false; m_controller->setActive(false); m_controller->setRadioTransmit(false); m_pollTimer.start(); wxDateTime dateTime = wxDateTime::Now(); m_lastHour = dateTime.GetHour(); m_inBuffer.clear(); wxLogMessage(wxT("Starting the sound card transmitter and receiver thread")); unsigned int count = 0U; wxStopWatch timer; while (!m_killed) { timer.Start(); // Process the incoming D-Star transmission receiveRadio(); // Process network traffic receiveNetwork(); repeaterStateMachine(); // Send the network poll if needed and restart the timer if (m_pollTimer.hasExpired()) {#if defined(__WINDOWS__) m_protocolHandler->writePoll(wxT("win_sound-") + VERSION);#else m_protocolHandler->writePoll(wxT("linux_sound-") + VERSION);#endif m_pollTimer.reset(); } // Clock the heartbeat output every one second count++; if (count == 50U) { m_controller->setHeartbeat(); count = 0U; } // Set the output state if (m_tx || (m_activeHangTimer.isRunning() && !m_activeHangTimer.hasExpired())) { m_controller->setActive(true); } else { m_controller->setActive(false); m_activeHangTimer.stop(); } // Check the shutdown state, state changes are done here to bypass the state machine which is // frozen when m_disable is asserted m_disable = m_controller->getDisable(); if (m_disable) { if (m_rptState != DSRS_SHUTDOWN) { m_watchdogTimer.stop(); m_activeHangTimer.stop(); m_hangTimer.stop(); m_networkBuffer.clear(); m_bitBuffer.clear(); m_networkRun = 0U; m_networkStarted = false; m_controller->setActive(false); m_controller->setRadioTransmit(false); m_rptState = DSRS_SHUTDOWN; } } else { if (m_rptState == DSRS_SHUTDOWN) { m_watchdogTimer.stop(); m_hangTimer.stop(); m_rptState = DSRS_LISTENING; m_protocolHandler->reset(); } } // Send the output data if (m_networkStarted) transmitNetwork(); else if (m_networkRun >= NETWORK_RUN_FRAME_COUNT) transmitNetwork(); else transmit(); getStatistics(); unsigned int ms = timer.Time(); clock(ms);//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:opendv-svn,代码行数:101,
示例8: start_Protocolvoid start_Protocol(int *sock_fd,char* filename, unsigned long long int bytesToTransfer){ unsigned long long int transferred = 0; unsigned long long int window_size = 1; unsigned long long int packet_size = 10000; //840 unsigned long long int current_seq=1; unsigned long long int last_ack; unsigned long long int last_packet_size; unsigned long long int total_ack; unsigned long long int count_receive=0; unsigned long long int window_id=0; unsigned long long int start_seq=0; unsigned long long int end_seq=0; unsigned long long int start[5000],end[5000]; unsigned long long int offset[5000]; unsigned long long int current_packet_size[5000]; unsigned long long int total_message_size[5000]; char * mssg_pointer[5000]; int change_window=0; int all_delivered=0; int max_size; while(transferred<bytesToTransfer) { if(packet_size>(bytesToTransfer-transferred))// only one packet needs to be send { window_size=1; packet_size=bytesToTransfer-transferred; //fprintf(stderr,"Last packet /n"); } int i; start[0]=transferred; end[0]=transferred+packet_size; window_id=0; change_window++; for(i=1;i<window_size;i++) { start[i]=end[i-1]; if(start[i]+packet_size>=bytesToTransfer) { packet_size=bytesToTransfer-start[i]; //this is the last packet last_packet_size=packet_size; window_size=i+1; //this will be the new max size of last window end[i]=start[i]+packet_size; //fprintf(stderr,"Last packet /n"); break; } end[i]=start[i]+packet_size; //fprintf(stderr,"transferred =%d start %d end %d/n",transferred,start[i],end[i]); } start_seq=current_seq; max_size=window_size; for(i=0;i<window_size;i++) { offset[i]=start[i]; current_packet_size[i]=end[i]-start[i]; if(offset[i]+current_packet_size[i]==bytesToTransfer) { total_ack=current_seq-1; //fprintf(stderr,"Last packet /n"); end_seq=current_seq; current_seq=0; all_delivered=1; } mssg_pointer[i]=create_message(current_packet_size[i],offset[i],current_seq,window_size,window_id,change_window); total_message_size[i]=total_length; //current_seq!=0 && current_seq!=1217 && current_seq!=2100 && current_seq!=3500 && current_seq!=5000 //if(current_seq%4!=0)//drop every odd seq packet //{ if(transmit(mssg_pointer[i],sock_fd,total_message_size[i])==1) { if(current_seq!=0) current_seq++; transferred+=current_packet_size[i]; } else// something bad happened , go for retransmission { fprintf(stderr,"Window retransmit unexpected behavior /n"); transferred-=current_packet_size[i]; i--; //window_id/2; } window_id++; //} //else //{ // transferred+=current_packet_size[i]; // if(current_seq!=0) // current_seq++; //just for simulating forced drop // window_id++; //just for simulating forced drop // fprintf(stderr,"droped %d/n",current_seq-1); //} } //fprintf(stderr," round over window size was %d /n",window_size); /******************************Window has been sent look for ACK******************************************/ //change_window=0; end_seq=start_seq;//.........这里部分代码省略.........
开发者ID:guptadipanshu,项目名称:Network,代码行数:101,
示例9: allocatevoid AudioInputAnalogStereo::update(void){ audio_block_t *new_left=NULL, *out_left=NULL; audio_block_t *new_right=NULL, *out_right=NULL; uint32_t i, dc; int32_t tmp; int16_t s, *p, *end; //Serial.println("update"); // allocate new block (ok if both NULL) new_left = allocate(); if (new_left == NULL) { new_right = NULL; } else { new_right = allocate(); if (new_right == NULL) { release(new_left); new_left = NULL; } } __disable_irq(); if (offset_left < AUDIO_BLOCK_SAMPLES || offset_right < AUDIO_BLOCK_SAMPLES) { // the DMA hasn't filled up both blocks if (block_left == NULL) { block_left = new_left; offset_left = 0; new_left = NULL; } if (block_right == NULL) { block_right = new_right; offset_right = 0; new_right = NULL; } __enable_irq(); if (new_left) release(new_left); if (new_right) release(new_right); return; } // the DMA filled blocks, so grab them and get the // new blocks to the DMA, as quickly as possible out_left = block_left; out_right = block_right; block_left = new_left; block_right = new_right; offset_left = 0; offset_right = 0; __enable_irq(); // Find and subtract DC offset... We use an average of the // last 16 * AUDIO_BLOCK_SAMPLES samples. dc = 0; for (i = 0; i < 16; i++) { dc += left_dc_average_hist[i]; } dc /= 16 * AUDIO_BLOCK_SAMPLES; left_dc_average_hist[current_dc_average_index] = 0; p = out_left->data; end = p + AUDIO_BLOCK_SAMPLES; do { left_dc_average_hist[current_dc_average_index] += (uint16_t)(*p); tmp = (uint16_t)(*p) - (int32_t)dc; s = signed_saturate_rshift(tmp, 16, 0); *p++ = s; } while (p < end); dc = 0; for (i = 0; i < 16; i++) { dc += right_dc_average_hist[i]; } dc /= 16 * AUDIO_BLOCK_SAMPLES; right_dc_average_hist[current_dc_average_index] = 0; p = out_right->data; end = p + AUDIO_BLOCK_SAMPLES; do { right_dc_average_hist[current_dc_average_index] += (uint16_t)(*p); tmp = (uint16_t)(*p) - (int32_t)dc; s = signed_saturate_rshift(tmp, 16, 0); *p++ = s; } while (p < end); current_dc_average_index = (current_dc_average_index + 1) % 16; // then transmit the AC data transmit(out_left, 0); release(out_left); transmit(out_right, 1); release(out_right);}
开发者ID:dturner,项目名称:Audio,代码行数:88,
示例10: transmit void NodeHandshakeExtension::HandshakeEndpoint::send(const dtn::data::Bundle &b) { transmit(b); }
开发者ID:aayushjr,项目名称:ibrdtn,代码行数:4,
示例11: send_full_statmsg_std//.........这里部分代码省略......... if (v > 0xFFFF) v = 0xFFFF; msg.str = ctBEu16( static_cast<u16>(v) ); } else { msg.str = 0; } if (uoclient_general.dexterity.any) { long v = chr->attribute(uoclient_general.dexterity.id).effective(); if (v > 0xFFFF) v = 0xFFFF; msg.dex = ctBEu16( static_cast<u16>(v) ); } else { msg.dex = 0; } if (uoclient_general.intelligence.any) { long v = chr->attribute(uoclient_general.intelligence.id).effective(); if (v > 0xFFFF) v = 0xFFFF; msg.intel = ctBEu16( static_cast<u16>(v) ); } else { msg.intel = 0; } if (uoclient_general.stamina.any) { long v = chr->vital(uoclient_general.stamina.id).current_ones(); if (v > 0xFFFF) v = 0xFFFF; msg.stamina = ctBEu16( static_cast<u16>(v) ); v = chr->vital( uoclient_general.stamina.id ).maximum_ones(); if (v > 0xFFFF) v = 0xFFFF; msg.max_stamina = ctBEu16( static_cast<u16>(v) ); } else { msg.stamina = 0; msg.max_stamina = 0; } if (uoclient_general.mana.any) { long v = chr->vital(uoclient_general.mana.id).current_ones(); if (v > 0xFFFF) v = 0xFFFF; msg.mana = ctBEu16( static_cast<u16>(v) ); v = chr->vital(uoclient_general.mana.id).maximum_ones(); if (v > 0xFFFF) v = 0xFFFF; msg.max_mana = ctBEu16( static_cast<u16>(v) ); } else { msg.mana = 0; msg.max_mana = 0; } msg.gold = ctBEu32( chr->gold_carried() ); // Adjusted to work with Physical Resist if AOS client, and AOS Resistances enabled. if( (client->UOExpansionFlag & AOS) && client->aosresist ) msg.AR = (chr->element_resist.physical < 0)?ctBEu16(0x10000+chr->element_resist.physical):ctBEu16(chr->element_resist.physical); else msg.AR = ctBEu16( chr->ar() ); msg.weight = ctBEu16( static_cast<u16>(chr->weight()) ); if ( msg.moreinfo >= 4 ) { msg.statcap = ctBEu16( chr->expanded_statbar.statcap ); msg.followers = chr->expanded_statbar.followers; msg.followers_max = chr->expanded_statbar.followers_max; msg.fireresist = (chr->element_resist.fire < 0)?ctBEu16(0x10000+chr->element_resist.fire):ctBEu16(chr->element_resist.fire); msg.coldresist = (chr->element_resist.cold < 0)?ctBEu16(0x10000+chr->element_resist.cold):ctBEu16(chr->element_resist.cold); msg.poisonresist = (chr->element_resist.poison < 0)?ctBEu16(0x10000+chr->element_resist.poison):ctBEu16(chr->element_resist.poison); msg.energyresist = (chr->element_resist.energy < 0)?ctBEu16(0x10000+chr->element_resist.energy):ctBEu16(chr->element_resist.energy); msg.luck = ctBEu16( chr->expanded_statbar.luck ); msg.damage_min = ctBEu16( chr->min_weapon_damage() ); msg.damage_max = ctBEu16( chr->max_weapon_damage() ); msg.titching = ctBEu32( chr->expanded_statbar.tithing ); } transmit(client, &msg, cfBEu16(msg.msglen) );}
开发者ID:alucardxlx,项目名称:polserver-zulu,代码行数:101,
示例12: NVIC_TRIGGER_INTERRUPT//runs in ISRvoid AudioPlaySdAac::update(void){ audio_block_t *block_left; audio_block_t *block_right; //paused or stopped ? if (playing != codec_playing) return; //chain decoder-interrupt. //to give the user-sketch some cpu-time, only chain //if the swi is not active currently. //In addition, check before if there waits work for it. int db = decoding_block; if (!NVIC_IS_ACTIVE(IRQ_AUDIOCODEC)) if (decoded_length[db]==0) NVIC_TRIGGER_INTERRUPT(IRQ_AUDIOCODEC); //determine the block we're playing from int playing_block = 1 - db; if (decoded_length[playing_block] <= 0) { stop(); return; } // allocate the audio blocks to transmit block_left = allocate(); if (block_left == NULL) return; int pl = play_pos; if (aacFrameInfo.nChans == 2) { // if we're playing stereo, allocate another // block for the right channel output block_right = allocate(); if (block_right == NULL) { release(block_left); return; } memcpy_frominterleaved(block_left->data, block_right->data, buf[playing_block] + pl); pl += AUDIO_BLOCK_SAMPLES * 2 ; transmit(block_left, 0); transmit(block_right, 1); release(block_right); decoded_length[playing_block] -= AUDIO_BLOCK_SAMPLES * 2; } else { // if we're playing mono, no right-side block // let's do a (hopefully good optimized) simple memcpy memcpy(block_left->data, buf[playing_block] + pl, AUDIO_BLOCK_SAMPLES * sizeof(short)); pl += AUDIO_BLOCK_SAMPLES; transmit(block_left, 0); transmit(block_left, 1); decoded_length[playing_block] -= AUDIO_BLOCK_SAMPLES; } samples_played += AUDIO_BLOCK_SAMPLES; release(block_left); //Switch to the next block if we have no data to play anymore: if ((decoded_length[playing_block] == 0) ) { decoding_block = playing_block; play_pos = 0; } else play_pos = pl;}
开发者ID:FrankBoesing,项目名称:Arduino-Teensy-Codec-lib,代码行数:75,
示例13: ROS_INFOvoid hbl2350::initController(void){ ROS_INFO("Initializing..."); sleep(1); transmit(2, "^ECHOF", 1 ); sleep(TIME_BETWEEN_COMMANDS); // Echo is disabled transmit(1, "# C"); sleep(TIME_BETWEEN_COMMANDS); // Clear buffer transmit(1, "?P"); sleep(TIME_BETWEEN_COMMANDS); // Request power readings transmit(1, "?V"); sleep(TIME_BETWEEN_COMMANDS); // Request voltage readings transmit(1, "?T"); sleep(TIME_BETWEEN_COMMANDS); // Request temperature readings transmit(1, "?FS"); sleep(TIME_BETWEEN_COMMANDS); // Request status flag transmit(1, "?FF"); sleep(TIME_BETWEEN_COMMANDS); // Request fault flag transmit(1, "?CB"); sleep(TIME_BETWEEN_COMMANDS); // Request absolute hall count// transmit(1, "?CBR"); sleep(TIME_BETWEEN_COMMANDS); transmit(1, "# 10" ); sleep(TIME_BETWEEN_COMMANDS); // Repeat buffer every 10 ms /* transmit(4, "^CPRI", 1, 0, 0 ); sleep(TIME_BETWEEN_COMMANDS); // Serial is first and only priority transmit(2, "^RWD", 1000 ); sleep(TIME_BETWEEN_COMMANDS); // One second watchdog transmit(3, "^BLFB", 1, 1 ); sleep(TIME_BETWEEN_COMMANDS); // Use hall sensors as motor feedback transmit(3, "^BLFB", 2, 1 ); sleep(TIME_BETWEEN_COMMANDS); // Use hall sensors as motor feedback transmit(3, "^BLSTD", 1, 2 ); sleep(TIME_BETWEEN_COMMANDS); // Stall detection [email C++ transmit_chars函数代码示例 C++ translation函数代码示例
|