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


C++ OSCMessage::send方法代码示例

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


在下文中一共展示了OSCMessage::send方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: send

void OSCBundle::send(Print &p){
    //don't send a bundle with errors
    if (hasError()){
        return;
    }
    //write the bundle header
    static uint8_t header[] = {'#', 'b', 'u', 'n', 'd', 'l', 'e', 0};
    p.write(header, 8);
    //write the timetag
{
    osctime_t time =  timetag;
    uint32_t d = BigEndian(time.seconds);
    uint8_t * ptr = (uint8_t *)    &d;
    p.write(ptr, 4);
    d = BigEndian(time.fractionofseconds);
    ptr = (uint8_t *)    &d;
    p.write(ptr, 4);
}

    //send the messages
    for (int i = 0; i < numMessages; i++){
        OSCMessage * msg = getOSCMessage(i);
        int msgSize = msg->bytes();
        //turn the message size into a pointer
        uint32_t s32 = BigEndian((uint32_t) msgSize);
        uint8_t * sptr = (uint8_t *) &s32;
        //write the messsage size
        p.write(sptr, 4);
        msg->send(p);
    }
}
开发者ID:ArduinoBR,项目名称:OSC,代码行数:31,代码来源:OSCBundle.cpp

示例2: setLED

void setLED(OSCMessage &msg){
    msg.send(dump);
    slip.sendMessage(dump.buffer, dump.length, serial);
}
开发者ID:critterandguitari,项目名称:Organelle_UI,代码行数:4,代码来源:main.cpp

示例3: 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;


    UdpSocket udpSock(4001);
    udpSock.setDestination(4000, "localhost");
 
    Serial serial;
    SLIPEncodedSerial slip;

    SimpleWriter dump;

    OSCMessage msgIn;
    
    printf("cool\n");

    // make an osc object
    // the message wants an OSC address as first argument
    OSCMessage msg("/sys/renumber");
    // msg.add(888);
       
    // this just dumps it into the simple writer dump
    msg.send(dump);

    printf("\n msg is %d bytes\n", dump.length);

    // print it out
    for (i = 0; i < dump.length; i++){
        printf("%x ", dump.buffer[i]);
    }

    // UDP send
    udpSock.writeBuffer(dump.buffer, dump.length);

    // serial send
    slip.sendMessage(dump.buffer, dump.length, serial);

    printf("\ndone, now gonna receive\n");


    // full udp -> serial -> serial -> udp
    for (;;){
        // receive udp, send to serial
        len = udpSock.readBuffer(udpPacketIn, 256, 0);
        if (len > 0){
            for (i = 0; i < len; i++){
                msgIn.fill(udpPacketIn[i]);
            }
            if(!msgIn.hasError()){
                msgIn.dispatch("/thing/test", gotone, 0);
                // send it along
                msgIn.send(dump);
                slip.sendMessage(dump.buffer, dump.length, serial);
            }
            else {
                printf("bad message");
            }
            msgIn.empty();
        }   

        // receive serial, send udp
        if(slip.recvMessage(serial)) {
            udpSock.writeBuffer(slip.decodedBuf, slip.decodedLength);
        }

        // sleep for 1ms
        usleep(1000);
    } // for;;
}
开发者ID:critterandguitari,项目名称:OSC-SimpleExample,代码行数:74,代码来源:main.cpp


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