Usage method

OscMessage mesg;
mesg.setAddress("m");
mesg.addIntArg();
mesg.addIntArg();
mesg.addIntArg(); g_oscSend.sendMessage(mesg);

Take notes first , Do the procedure again

The whole message is put in an array

front 8 It starts with two characters   by #bundle\0

below 8 Two bytes to record the time   It's all here 1, In memory is 0 0 0 0 0 0 0 1

Next 4 Bytes Integers   , The number size here refers to ,osc The address of the address is the number of bytes from the end of the data ,( That is, the length of the received packet minus this value , Namely osc News Adrrs The location of )

Next is the address string   The size depends on the string size , then 4 Byte alignment , Not enough to make up for 4 Multiple

Here are the types of all the parameters   The first is comma , I don't know why ,   Here's the type , Here, if the quantity is not 4 We have to make up for the multiple of

Next is the memory for each parameter

type

enum TypeTagValues {
TRUE_TYPE_TAG = 'T',
FALSE_TYPE_TAG = 'F',
NIL_TYPE_TAG = 'N',
INFINITUM_TYPE_TAG = 'I',
INT32_TYPE_TAG = 'i',
FLOAT_TYPE_TAG = 'f',
CHAR_TYPE_TAG = 'c',
RGBA_COLOR_TYPE_TAG = 'r',
MIDI_MESSAGE_TYPE_TAG = 'm',
INT64_TYPE_TAG = 'h',
TIME_TAG_TYPE_TAG = 't',
DOUBLE_TYPE_TAG = 'd',
STRING_TYPE_TAG = 's',
SYMBOL_TYPE_TAG = 'S',
BLOB_TYPE_TAG = 'b',
ARRAY_BEGIN_TYPE_TAG = '[',
ARRAY_END_TYPE_TAG = ']'
};

among  bool   no memory , only one tag

int32   4 Bytes

float  4 Bytes

char   4 Bytes

int64  8 Bytes

double  8 Bytes

timetag   8 Bytes

string     Make up 4 Multiple

2018-4-28

Found a code implementation

enum class ArgType : char { INTEGER_32 = 'i', FLOAT = 'f', DOUBLE = 'd', STRING = 's', BLOB = 'b', MIDI = 'm', TIME_TAG = 't', INTEGER_64 = 'h', BOOL_T = 'T', BOOL_F = 'F', CHAR = 'c', NULL_T = 'N', IMPULSE = 'I', NONE = NULL_T };
void Bundle::setTimetag( uint64_t ntp_time )
{
uint64_t a = htonll( ntp_time );
ByteArray<> b;
memcpy( b.data(), reinterpret_cast<uint8_t*>( &a ), );
mDataBuffer->insert( mDataBuffer->begin() + , b.begin(), b.end() );
} void Bundle::initializeBuffer()
{
static const std::string id = "#bundle";
mDataBuffer.reset( new std::vector<uint8_t>( ) );
std::copy( id.begin(), id.end(), mDataBuffer->begin() + );
(*mDataBuffer)[] = ;
}
 size_t addressLen = mAddress.size() + getTrailingZeros( mAddress.size() );
auto typesSize = mDataViews.size() + ;
std::vector<char> typesArray( typesSize + getTrailingZeros( typesSize ) , ); typesArray[] = ',';
int i = ;
for( auto & dataView : mDataViews )
typesArray[i++] = Argument::translateArgTypeToCharType( dataView.getType() ); if( ! mCache )
mCache = ByteBufferRef( new ByteBuffer() ); size_t typesArrayLen = typesArray.size();
ByteArray<> sizeArray;
int32_t messageSize = addressLen + typesArrayLen + mDataBuffer.size();
auto endianSize = htonl( messageSize );
memcpy( sizeArray.data(), reinterpret_cast<uint8_t*>( &endianSize ), ); mCache->resize( + messageSize ); std::copy( sizeArray.begin(), sizeArray.end(), mCache->begin() );
std::copy( mAddress.begin(), mAddress.end(), mCache->begin() + );
std::copy( typesArray.begin(), typesArray.end(), mCache->begin() + + addressLen );
std::copy( mDataBuffer.begin(), mDataBuffer.end(), mCache->begin() + + addressLen + typesArrayLen ); auto dataPtr = mCache->data() + + addressLen + typesArrayLen;
for( auto & dataView : mDataViews ) {
if( dataView.needsEndianSwapForTransmit() )
dataView.swapEndianForTransmit( dataPtr );
}
static uint8_t getTrailingZeros( size_t bufferSize ) { return - ( bufferSize % ); }

As I explained before , Now this can be interpreted by yourself

UDP Network communication OSC More articles on the agreement

  1. UNIX Network programming —— Analyze a frame based on UDP Of TFTP Protocol frame

    The picture below is UDP Segment format of : comparison TCP Segment format ,UDP It's much simpler , There's nothing to say , It should be noted that UDP Data length means payload Plus the length of the head . The following analysis is based on UDP Of TFTP Protocol frame : Ethernet head 0000: ...

  2. Java The third stage of learning ( 8、 ... and : Network communication protocol 、UDP And TCP agreement )

    One . Network communication protocol 1. Concept : Multiple computers can be connected through computer network , Computers in the same network need to follow certain rules when connecting and communicating , In a computer network , These rules of connection and communication are called network communication protocols , Its transmission of data ...

  3. Analyze a frame based on UDP Of TFTP Protocol frame

    The picture below is UDP Segment format of : comparison TCP Segment format ,UDP It's much simpler , There's nothing to say , It should be noted that UDP Data length means payload Plus the length of the head . The following analysis is based on UDP Of TFTP Protocol frame : Ethernet head 0000: ...

  4. be based on FPGA Optical port communication development case | be based on Kintex-7 FPGA SFP+ Smooth spoken 10G UDP Network communication development case

    Preface Since the famous Chinese physicist Mr. Kao Kun proposed " Optical transmission theory ", Practical optical fiber transmission products began with 1976 year , Experienced PDH→SDH→DWDM→ASON→MSTP Development history of . At the beginning of this century ,ASON/OADM ...

  5. 【RL-TCPnet Online tutorial 】 The first 16 Chapter UDP Basic knowledge of user datagram protocol

    The first 16 Chapter       UDP Basic knowledge of user datagram protocol This chapter will explain UDP(User Datagram Protocol, User datagram protocol ), I need you to agree UDP There is a basic understanding , For the convenience of later chapters UDP Practical operation . ...

  6. Python Basic course udp and tcp Protocol is introduced

    Python Basic course udp and tcp Protocol is introduced UDP Introduce UDP --- User datagram protocol , It is a simple datagram oriented transport layer protocol without connection .UDP No reliability , It just passes the application to IP The datagram of the layer is sent out , but ...

  7. be based on UDP High performance transport protocol UDT doc translate ( One )

    The original is translated from :http://hi.baidu.com/doodlezone/item/74a203155efe26dbbf9042dd                  UDT Document reading comprehension One .   summary ...

  8. Increase knowledge -VI be based on TCP/UDP Application layer protocol

    be based on TCP/UDP Application layer protocol : be based on TCP: Telnet(Teletype over the Network, Internet telex ), Through a terminal (terminal) Log on to the Internet FTP(File Trans ...

  9. Raknet It's based on UDP Network transport protocol C++ The network library ( There are other libraries , such as nanomsg,fastsocket wait )

    Raknet It's based on UDP Network transport protocol C++ The network library , Allow programmers to implement efficient network transmission services in their own programs . Usually used for games , But it can also be used for other projects . Raknet There are the following benefits : High performance On the same computer ...

Random recommendation

  1. swift Study ( 3、 ... and )( Object oriented fundamentals )

    The basic characteristics of object-oriented include : encapsulation , Inherit , polymorphic stay swift in , class , structure , Enumerations are object-oriented But instances of structures and enumerations are not called objects , Because structures and enumerations are not completely object-oriented types , For example, they can't inherit . Structure struct ...

  2. Imagine again Windows 8 Store Apps (52) - binding : And Element Model Indexer Style RelativeSource binding , And data transformation in binding

    [ Source download ] Imagine again Windows 8 Store Apps (52) - binding : And Element Model Indexer Style RelativeSource binding , And the number in the binding ...

  3. JavaSE review _6 Enumeration class

    △ Singleton class means that there is only one instance , An enumeration class is actually a class with a finite number of instances , The instance has been defined in the class . △ Enumerating three forms of class creation : 1) enum Week { MON,TUE,WED;// Enumeration classes are created by default constructors ...

  4. X230 install win7 sp1

    I wake up in the morning and find win10 I'm off , If I can't start it, I have to reload the system With the stable version win7 More reliable . Go to msdn Upload and download One win7 System win7 The flagship version 64 position ed2k://|file|cn_windows_7_u ...

  5. css3 Multi column layout

    css3 Multi column layout Multi column layout properties : columns:column-widht and column-count Abbreviation . column-width: Define the width of each column . column-count: Define the number of columns . c ...

  6. GSON brief introduction Example

    Gson brief introduction Current analysis json The three most commonly used tools :org.json(Java Common parsing ),fastjson( Alibaba made ),Gson(Google Out of ), The fastest parsing speed is Gson. Gson The full name of is Go ...

  7. structure WDK Drive appears fatal error U1087: cannot have : and :: dependents for same target

    reason :WDK When compiling the driver , The path where the source file is not allowed ( The full path ) Contains spaces in , If you include spaces , There will be these mistakes . resolvent : Put the source file in a path without spaces . reference: http://blo ...

  8. Cortex-A9 UART

    One .Exynos4412 UART Characteristics of Exynos4412 in UART, Yes 4 It's a separate channel , Each channel can work in interrupt mode or DMA Pattern , namely UART An interrupt or DMA Request in order to UART ...

  9. [HeadFirst-HTMLCSS Learning notes ][ Chapter 13 forms ]

    form -table block tr That's ok table row th Header table head td Table data table data; caption Table title <table> <captio ...

  10. Codeforces Round #554 (Div. 2) C. Neko does Maths( mathematics +GCD)

    Portal The question : Give two integers a,b: The solution makes LCM(a+k,b+k) The smallest k, If there are more than one k bring LCM() Minimum , The smallest output k: Ideas : Just started to push the formula for a long time , a meal xjb Random operation : later , Look at the solution , see ...