For the communication
between the master and the multiple slaves involved in the project, we
implemented the Open Sound Control(OSC) messaging protocol. OSC is a content
format for messaging among computers and multimedia devices which is comparable
to XML and JSON formats.
OSC provides
flexibility, interoperability and improved organization and documentation to
applications.
When an OSC server receives an OSC Message, it
must invoke the appropriate OSC Methods in its OSC Address Space based on the
OSC Message's OSC Address Pattern. This process is called dispatching the
OSC Message to the OSC Methods that match its OSC Address
Pattern. All the matching OSC Methods are invoked with the same argument data,
namely, the OSC Arguments in the OSC Message.
The OSC message format:
The OSC message consists of an address pattern, a type tag and
zero or more arguments.
Our application has a master communicating with multiple slaves
using the OSC protocol. It resembles invoking a remote procedure call to the
slave by the master.
The message format:
The message format s[ecifies that each OSC message is of 8 bytes with the fields as specified below.
Fields:
Address: This field specifies the address of the slave which is meant to receive the message. Each slave checks this address and if the message is meant for itself, it unpacks the rest of the message otherwise it drops the message.
SubAddress: This field specifies the function on the slave which we need to call. The slave will read the subaddress and call the appropriate function with the parameters attached with the message.
Start Type: This field indicates the end of the address and start of the type tags.(usually a ',')
Parameters: This field contains the parameters required for the function mentioned in the subaddress. It can also be a time tag indicating the time in seconds which may be required by the slave.(Eg if it plays a musical instrument, this helps in knowing for how long to play it)
OSC Message Types:
The message format:
The message format s[ecifies that each OSC message is of 8 bytes with the fields as specified below.
Fields:
Address: This field specifies the address of the slave which is meant to receive the message. Each slave checks this address and if the message is meant for itself, it unpacks the rest of the message otherwise it drops the message.
SubAddress: This field specifies the function on the slave which we need to call. The slave will read the subaddress and call the appropriate function with the parameters attached with the message.
Start Type: This field indicates the end of the address and start of the type tags.(usually a ',')
Parameters: This field contains the parameters required for the function mentioned in the subaddress. It can also be a time tag indicating the time in seconds which may be required by the slave.(Eg if it plays a musical instrument, this helps in knowing for how long to play it)
OSC Message Types:
OSC Type Tag
|
Type of corresponding argument
|
i
|
int32
|
f
|
float32
|
s
|
OSC-string
|
T
|
TimeTag
|
Message API:
General Format: /Address/SubAddress,Type Tag {Arguments}
Type tag for our application:
t - Time
c- RGB
i - Integer
s- String
Slave 1:
Address: VEST
SubAddress: Motor_Location
Type Tag : Time Tag
Arguments: Time in seconds
Eg:
/VEST/Left-Top,t{0,2}
/VEST/Left-Solenoid,t{0,2}
Slave 2:
Address: LED
SubAddress: Led_Effect
Type Tag: RGB(c)
Arguments : color values between 0 and 1
Eg:
/LED/STROBE,c{o.5,0,5,0,5}
/LED/FLASH,c{1.0,0.3,0.5}
To read more on OSC:


No comments:
Post a Comment