Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
osc_sys.h
00001 /* 00002 * osc.h 00003 * 00004 * Created on: Mar 8, 2010 00005 * Author: pehr 00006 * 00007 * The functions to receive, parse and delegate OSC commands 00008 * Based on osc_cpp.h in Make Controller repository 00009 * This code is trimmed down to be UDP-only, no USB (code never had TCP) 00010 * http://makingthings.com 00011 */ 00012 /********************************************************************************* 00013 00014 Copyright 2006-2009 MakingThings 00015 00016 Licensed under the Apache License, 00017 Version 2.0 (the "License"); you may not use this file except in compliance 00018 with the License. You may obtain a copy of the License at 00019 00020 http://www.apache.org/licenses/LICENSE-2.0 00021 00022 Unless required by applicable law or agreed to in writing, software distributed 00023 under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 00024 CONDITIONS OF ANY KIND, either express or implied. See the License for 00025 the specific language governing permissions and limitations under the License. 00026 00027 *********************************************************************************/ 00028 #ifndef OSC_H_ 00029 #define OSC_H_ 00030 00031 #include "ipv4/lwip/ip_addr.h" 00032 #include "lwip/udp.h" 00033 00034 #ifndef UDP_BROADCAST_PORT 00035 #define UDP_BROADCAST_PORT 5555 00036 #endif 00037 00038 #include "error.h" //Make Controller error codes 00039 00040 #define OSC_SUBSYSTEM_COUNT 18 00041 00042 #define OSC_SCRATCH_SIZE 100 00043 00044 #define OSC_CHANNEL_COUNT 3 00045 #define OSC_CHANNEL_UDP 0 00046 #define OSC_CHANNEL_USB 1 //not implemented yet 00047 #define OSC_CHANNEL_TCP 2 //not implemented yet 00048 00049 00050 #define OSC_MAX_MESSAGE_IN 200 00051 #define OSC_MAX_MESSAGE_OUT 600 00052 00053 00054 typedef unsigned char uchar; 00055 00056 typedef struct OscChannel_ 00057 { 00058 char buffer[ OSC_MAX_MESSAGE_OUT ]; 00059 char incoming[ OSC_MAX_MESSAGE_IN ]; 00060 char* bufferPointer; 00061 int bufferRemaining; 00062 int messages; 00063 struct ip_addr * replyAddress; //where to send 00064 int replyPort; 00065 //A function pointer to the func used to send using this channel, set up in an init function 00066 int (*sendMessage)( char* packet, int length, struct ip_addr * replyAddress, int replyPort ); 00067 int running; 00068 }OscChannel; 00069 00070 // Top level functions 00071 void Osc_SystemInit( struct udp_pcb * pcb ); 00072 void Osc_UdpInit( int channel, struct udp_pcb * pcb); //set up UDP channel 00073 00074 OscChannel * Osc_GetChannel(int channel); //get ptr to the channel struct 00075 00076 int Osc_CreateMessage( int channel, char* address, char* format, ... ); 00077 int Osc_CreateMessageToBuf( char* bp, int* length, char* address, char* format, ... ); 00078 int Osc_SendPacket( int channel ); 00079 int Osc_ReceivePacket( int channel, char* packet, int length ); 00080 int Osc_RegisterSubsystem( const char *name, 00081 int (*Subsystem_ReceiveMessage)( int channel, char* buffer, int length ), 00082 int (*Subsystem_Poll)( int channel ) ); 00083 00084 // Helpers for processing messages - they return error codes as spec'ed above 00085 int Osc_IntReceiverHelper( int channel, char* message, int length, 00086 char* subsystemName, 00087 int (*propertySet)( int property, int value ), 00088 int (*propertyGet)( int property ), 00089 char* propertyNames[] ); 00090 00091 int Osc_IndexIntReceiverHelper( int channel, char* message, int length, 00092 int indexCount, bool (*validIndex)( int index ),char* subsystemName, 00093 int (*propertySet)( int index, int property, int value ), 00094 int (*propertyGet)( int index, int property ), 00095 char* propertyNames[] ); 00096 00097 int Osc_BlobReceiverHelper( int channel, char* message, int length, 00098 char* subsystemName, 00099 int (*blobPropertySet)( int property, uchar* buffer, int length ), 00100 int (*blobPropertyGet)( int property, uchar* buffer, int size ), 00101 char* blobPropertyNames[] ); 00102 00103 00104 int Osc_IndexBlobReceiverHelper( int channel, char* message, int length, 00105 int indexCount, char* subsystemName, 00106 int (*blobPropertySet)( int index, int property, uchar* buffer, int length ), 00107 int (*blobPropertyGet)( int index, int property, uchar* buffer, int size ), 00108 char* blobPropertyNames[] ); 00109 00110 int Osc_GeneralReceiverHelper( int channel, char* message, int length, 00111 char* subsystemName, 00112 int (*propertySet)( int property, char* typedata, int channel ), 00113 int (*propertyGet)( int property, int channel ), 00114 char* propertyNames[] ); 00115 00116 int Osc_SendError( int channel, char* subsystemName, int error ); 00117 00118 00119 // Functions needed to process messages 00120 int Osc_SubsystemError( int channel, char* subsystem, char* string ); 00121 int Osc_PropertyLookup( char** properties, char* property ); 00122 char *Osc_FindDataTag( char* message, int length ); 00123 int Osc_ExtractData( char* buffer, char* format, ... ); 00124 int Osc_NumberMatch( int max, char* pattern, int* fancy ); 00125 int Osc_SetReplyAddress( int channel, struct ip_addr * replyAddress ); 00126 int Osc_SetReplyPort( int channel, int replyPort ); 00127 00128 // Pattern Match Stuff 00129 bool Osc_PatternMatch(const char * pattern, const char * test); 00130 00131 00132 #endif /* OSC_H_ */ 00133
Generated on Wed Jul 13 2022 01:51:44 by
1.7.2