当前位置: 首页>>代码示例>>C++>>正文


C++ UdpSocket::setDestination方法代码示例

本文整理汇总了C++中UdpSocket::setDestination方法的典型用法代码示例。如果您正苦于以下问题:C++ UdpSocket::setDestination方法的具体用法?C++ UdpSocket::setDestination怎么用?C++ UdpSocket::setDestination使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UdpSocket的用法示例。


在下文中一共展示了UdpSocket::setDestination方法的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();
//.........这里部分代码省略.........
开发者ID:critterandguitari,项目名称:Organelle_UI,代码行数:101,代码来源:main.cpp


注:本文中的UdpSocket::setDestination方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。