本文整理汇总了C++中UdpSocket::readBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ UdpSocket::readBuffer方法的具体用法?C++ UdpSocket::readBuffer怎么用?C++ UdpSocket::readBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UdpSocket
的用法示例。
在下文中一共展示了UdpSocket::readBuffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[]) {
uint32_t seconds = 0;
char udpPacketIn[256];
//uint8_t osc_packet_in[256];
uint8_t i = 0;
int len = 0;
int page = 0;
Timer screenFpsTimer, screenLineTimer, knobPollTimer, pingTimer, upTime;
screenFpsTimer.reset();
knobPollTimer.reset();
screenLineTimer.reset();
pingTimer.reset();
upTime.reset();
// set locale so sorting happens in right order
//std::setlocale(LC_ALL, "en_US.UTF-8");
// for setting real time scheduling
/*struct sched_param par;
par.sched_priority = 10;
printf("settin priority to: %d\n", 10);
if (sched_setscheduler(0,SCHED_FIFO,&par) < 0){
printf("failed to set rt scheduling\n");
}*/
udpSock.setDestination(4000, "localhost");
OSCMessage msgIn;
ui.buildMenu();
ui.drawPatchList();
// send ready to wake up MCU
// MCU is ignoring stuff over serial port until this message comes through
// don't empty the message because it gets sent out periodically incase MCU resets
OSCMessage rdyMsg("/ready");
rdyMsg.add(1);
rdyMsg.send(dump);
// send it a few times just in case
for(i = 0; i<4; i++) {
slip.sendMessage(dump.buffer, dump.length, serial);
usleep(20000); // wait 20 ms
}
//playFirst();
quit = 0;
// full udp -> serial -> serial -> udp
for (;;){
// receive udp, send to serial
len = udpSock.readBuffer(udpPacketIn, 256, 0);
if (len > 0){
msgIn.empty();
for (i = 0; i < len; i++){
msgIn.fill(udpPacketIn[i]);
}
if(!msgIn.hasError()){
msgIn.dispatch("/oled/vumeter", vuMeter, 0);
msgIn.dispatch("/oled/line/1", setPatchScreenLine1, 0);
msgIn.dispatch("/oled/line/2", setPatchScreenLine2, 0);
msgIn.dispatch("/oled/line/3", setPatchScreenLine3, 0);
msgIn.dispatch("/oled/line/4", setPatchScreenLine4, 0);
msgIn.dispatch("/oled/line/5", setPatchScreenLine5, 0);
msgIn.dispatch("/oled/aux/line/1", setAuxScreenLine1, 0);
msgIn.dispatch("/oled/aux/line/2", setAuxScreenLine2, 0);
msgIn.dispatch("/oled/aux/line/3", setAuxScreenLine3, 0);
msgIn.dispatch("/oled/aux/line/4", setAuxScreenLine4, 0);
msgIn.dispatch("/oled/aux/line/5", setAuxScreenLine5, 0);
msgIn.dispatch("/oled/aux/clear", auxScreenClear, 0);
msgIn.dispatch("/ready", sendReady, 0);
msgIn.dispatch("/shutdown", sendShutdown, 0);
msgIn.dispatch("/led", setLED, 0);
msgIn.dispatch("/oled/setscreen", setScreen, 0);
msgIn.dispatch("/reload", reload, 0);
msgIn.dispatch("/quitmother", quitMother, 0);
msgIn.dispatch("/screenshot", screenShot, 0);
msgIn.dispatch("/pgmchg", programChange, 0);
msgIn.dispatch("/getPatchName", getPatchName, 0);
}
else {
printf("bad message\n");
}
msgIn.empty();
}
// receive serial, send udp
if(slip.recvMessage(serial)) {
udpSock.writeBuffer(slip.decodedBuf, slip.decodedLength);
// check if we need to do something with this message
msgIn.empty();
msgIn.fill(slip.decodedBuf, slip.decodedLength);
msgIn.dispatch("/enc", encoderInput, 0);
msgIn.dispatch("/encbut", encoderButton, 0);
msgIn.empty();
//.........这里部分代码省略.........