Phatline Posted March 1, 2015 Report Share Posted March 1, 2015 (edited) A lot information: http://www.ucapps.de/midibox_osc.html but no information how to make a custom program, except this tutorial: http://svnmios.midibox.org/listing.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Ftutorials%2F028_osc%2F there are differnt modules out there , because i have to begin anywhare, lets start with the osc_client: http://www.midibox.org/mios32/manual/osc__client_8c.html lets try to send a nrpn, what say the "documentation": s32 OSC_CLIENT_SendNRPNEvent (u8 osc_port, u8 chn, u16 nrpn_number, u16 nrpn_value) aha, so then stripped down:: #include <uip_task.h> #include <osc_client.h> void APP_Init(void){ UIP_TASK_Init(0); OSC_CLIENT_Init(0);} OSC_CLIENT_SendNRPNEvent (7001, 0, 1, 127); //port, chn, nr, value compiler returns: app.c:52:1: warning: large integer implicitly truncated to unsigned type [-Woverflow] - what is no surprise since the port is declared as u8 (0-256) - when i want to use port 7001 ---what brings me to the first question why ist the port declared as u8? --- or maybe there is no network port meant? - like in the tutorial: maybe meant OSC0 OSC1 OSC2 I cant find any Word like receive or observe - how to receive/listen to a port/ip? >>> Maybe i have to use the OSC_CLIENT as a Function inside the main.c? (simular use like the DIN or Midi-notifcation function?) it looks like the midi-notificaton-function do this job by putting OSC0 as port out instead of UART or USB... Network connection with deafault Network configuration: Before Connect a Core LPC17 with code from above: Knoten: fe80::214 ff02::fb Protokolle: MDNS Port 5353 1second after connection a Core LPC17 with code from above: Knoten: fe80::214 ff02::fb ip6-allnodes ff02::1 Protokolle: MDNS Port 5353 UDP-UNKNOWN 4second after connection a Core LPC17 with code from above: Knoten: fe80::214 ff02::fb ip6-allnodes ff02::1 0,0,0,0 255.255.255.255 Protokolle: MDNS Port 5353 UDP-UNKNOWN BOOTPS Port 67 Edited March 4, 2015 by Phatline Quote Link to comment Share on other sites More sharing options...
Phatline Posted March 3, 2015 Author Report Share Posted March 3, 2015 (edited) its that: i can learn in Tutorial 28 that some Functions do the job for you, OSC_CLIENT_SendMIDIEvent(3, midi_package); - is that what you learn. But bevore the connections should be initalized or setupd. in this case #include "presets.h" has the data in it, and with Mios-Studio it could be setuped and stored in the preset file (as far i understand that...). but whats about if i dont want to have this preset file, and i dont want to use mios studio, in fact i want to fix the Adresses, to keep my application compact. So i take a look into "terminal.c" where all that Mios-Studio stuff happens... but here its getting complicated, since the whole thing is done for terminal work - and this terminal.c is not made for newbees, it looks like i missed some basics... i only learn them when i need them (elswhere i cant connect the dots) but i cant identfiy what i have to learn take a look what i have done: #include <mios32.h> #include "app.h" #include "uip.h" #include <uip_task.h> #include <osc_client.h> #include "terminal.h" void APP_Init(void) { // init terminal TERMINAL_Init(0); UIP_TASK_Init(0); //Connection Setup UIP_TASK_DHCP_EnableSet(0); UIP_TASK_IP_AddressSet(0,0,0,0);//app.c:17:16: error: too many decimal points in number Host IP-Adress? uip_ipaddr1(0.0.0.1); //pointer? app.c:17:16: error: too many decimal points in number uip_ipaddr2(0.0.0.2); //pointer? app.c:17:16: error: too many decimal points in numberor should they all be the same - the UIP_TASK_IP_ADress maybe? uip_ipaddr2(0.0.0.3); //pointer? app.c:17:16: error: too many decimal points in number uip_ipaddr2(0.0.0.4); //pointer? app.c:17:16: error: too many decimal points in number UIP_TASK_NetmaskSet(255.255.0.0); // error: too many decimal points in number OSC_SERVER_RemoteIP_Set(4, 1.0.0.0); // error: too many decimal points in number connections, IP OSC_SERVER_RemotePortSet(0, 1000); //connection, port OSC_SERVER_RemotePortSet(1, 1001); OSC_SERVER_RemotePortSet(2, 1002); OSC_SERVER_RemotePortSet(3, 1002); OSC_SERVER_LocalPortSet(0, 1000); //connection 0-3? those Remote Port? i dont understand that - this is most confuzing, OSC_CLIENT_TransferModeSet(1, 0); //selected_osc_con, ocfg_value UIP_TASK_GatewaySet(1.1); //ip UIP_TASK_UDP_MonitorLevelSet(1); //outputs data to Mios-Studio ---0 turn off //dont needed anymore if the Network setup is correct...just mess the usb bus.. OSC_SERVER_Init(0); OSC_CLIENT_Init(0); } void APP_Background(void){} void APP_Tick(void){} void APP_MIDI_Tick(void){} void APP_MIDI_NotifyPackage(mios32_midi_port_t port, mios32_midi_package_t midi_package){ MIOS32_LCD_Clear(); MIOS32_LCD_CursorSet(0, 0); MIOS32_LCD_PrintFormattedString("%u %u %u", port, midi_package.chn, midi_package.type); } s32 APP_SYSEX_Parser(mios32_midi_port_t port, u8 midi_in){return 0;} void APP_SRIO_ServicePrepare(void){} void APP_SRIO_ServiceFinish(void){} void APP_DIN_NotifyToggle(u32 pin, u32 pin_value){ OSC_CLIENT_SendNRPNEvent (0, 8, pin, pin_value);} //port, chn, nr, value;} void APP_ENC_NotifyChange(u32 encoder, s32 incrementer){} void APP_AIN_NotifyChange(u32 pin, u32 pin_value){} Question 1: no matter if i want to write a IP like 10.0.0.0 or a SubNetMast like 255.255.0.0 i get: "error to many decimal points in number" -- that says i should write a number here? but 10.0.0.0 is not a number - i understand but how to write it correct? confuzing.. Question 2: what do the server? do i need this once in setup? or is every Midibox a server? ANSWER: Any application that sends OSC Packets is an OSC Client; any application that receives OSC Packets is an OSC Server So a midibox that sends and receives is an server & client > thats what the OSC-Specifications says: .found @ http://opensoundcontrol.org/spec-1_0 Question 3: Do I have to setup all Midiboxes the same? except the local port? Question4:In Follwoing article, are 2 connections between 2 midiboxes http://ucapps.de/midibox_osc.html > we assume that MIDIbox A has IP address 192.168.1.112, and MIDIbox B the IP address 192.168.1.103. Configure MIDIbox A to send to MIDIbox B: set osc_remote 1 192.168.1.103 set osc_remote_port 1 10000 set osc_local_port 1 10001 set osc_mode 1 0 set osc_remote 2 192.168.1.103 set osc_remote_port 2 10002 set osc_local_port 2 10003 set osc_mode 2 0 And configure MIDIbox B to send to MIDIbox A: set osc_remote 1 192.168.1.112 set osc_remote_port 1 10001 set osc_local_port 1 10000 set osc_mode 1 0 set osc_remote 2 192.168.1.112 set osc_remote_port 2 10003 set osc_local_port 2 10002 set osc_mode 2 0 just to understand the whole concept: Midibox A Setup: Remote 1: 0.0.0.1 1000 Local_port 1: 1001 Remote 2: 0.0.0.1 1002 Local_port 2: 1003 Midibox B Setup: Remote 1: 0.0.0.2 1001 Local_port 1: 1000 Remote 2: 0.0.0.2 1003 Local_port 2: 1002 so every Device has its own ip, the Port are swapping, but why i need two of them? why Remote 2? Is this just to say "hey you can take to ports @ the same time?" Remote means - that this is the client/send-Port? Local means - that this ist the Server/receive-Port? How to write that code in my code example above? What happens if i use more then 2 Devices, If i use 4 or more Devices that share data? The local port is the one which receives OSC datagrams from any IP. It's allowed to set the local port to the same number as the remote port if your application requires this. the one that receives from any ip - and forces "void APP_MIDI_NotifyPackage" ? or where i can acces that osc datagram, by Midi_Notify_Package - as far as i see i get UART... and OSC0-3 (these have a definied ip, its not any?) Edited March 4, 2015 by Phatline Quote Link to comment Share on other sites More sharing options...
Phatline Posted March 4, 2015 Author Report Share Posted March 4, 2015 (edited) i thought maybe the IP-Set and NetMask set needs a pointer, so i tried this: #include <mios32.h> #include "app.h" #include "uip.h" #include <uip_task.h> #include <osc_client.h> #include "terminal.h" //set Device IP u32 deviceIP[4] = {1, 2, 3 ,4}; u32 *deviceIPpointer; //set UIP_TASK_Netmask u32 Netmask[4] = {255,255,255,0}; u32 *NetmaskPointer; void APP_Init(void) { // init terminal TERMINAL_Init(0); UIP_TASK_Init(0); //Set Pointer //Connection Setup UIP_TASK_DHCP_EnableSet(0); UIP_TASK_IP_AddressSet(1.1); //Host IP-Adress //uip_ipaddr1(1.0.0.0); //pointer? //uip_ipaddr2(2); //pointer? //uip_ipaddr2(3); //pointer? //uip_ipaddr2(4); //pointer NetmaskPointer = Netmask; UIP_TASK_NetmaskSet(NetmaskPointer); deviceIPpointer = deviceIP; OSC_SERVER_RemoteIP_Set(1, deviceIPpointer); //connections, IP OSC_SERVER_RemotePortSet(1, 5001); //connection 0-3, port OSC_SERVER_LocalPortSet(1, 5000); //connection 0-3, port OSC_CLIENT_TransferModeSet(1, 0); //selected_osc_con, ocfg_value UIP_TASK_GatewaySet(1.1); //ip UIP_TASK_UDP_MonitorLevelSet(1); //outputs data to Mios-Studio ---0 turn off OSC_SERVER_Init(0); OSC_CLIENT_Init(0); } give me back: app.c:32:4: warning: passing argument 1 of 'UIP_TASK_NetmaskSet' makes integer from pointer without a cast [enabled by default] ok it dont needs a pointer, ...it takes a singel integer...maybe i have to write the 001. instead of 1.? lets have a try: I want IP adress for Connection 1 (0-3) 001.000.000.000), I write it witouts points: OSC_SERVER_RemoteIP_Set(1, 001000000000); //connections, IP The System Command in Mios-Studio give me back: [9996.317] OSC2 Remote address: 8.0.0.0 from 001000000000 to 8.0.0.0 ??? what goes on... OSC_SERVER_RemoteIP_Set(1, 008000000000); //connections, IP give me back: app.c:34:31: error: invalid digit "8" in octal constant octal constant? whats that...ask google: ohh deep in wonderland...if i write bevore a number a 0 it is a treated as a octal constant by the compiler... so lets try: with that converter: http://www.binaryhexconverter.com/decimal-to-octal-converter 150 Decimal gets 226 octal... lets try this OSC_SERVER_RemoteIP_Set(1, 0226000000000) give me back: app.c:34:4: warning: large integer implicitly truncated to unsigned type [-Woverflow] ok ok, but 010 octal is 8 decimal 001000000000 is 8.0.0.0 since 0 stand for octal, i dont write the zero: 010.... AHA ok lets try a different ip: OSC_SERVER_RemoteIP_Set(1, 001002003004); // since 0-7 octal = 0-7 decimal it should output 1.2.3.4 nope 8.8.6.4! pffffff ok wrong direction... i go to bed now.. ...ok cant sleep, back again: 001000000000 = 8.0.0.0 0010 = 8 so 8.8.8.8 should be 0010 0010 0010 0010? lets try > 0010001000100010 no: app.c:34:4: warning: large integer implicitly truncated to unsigned type [-Woverflow] 0100010001000100 > warning: large integer implicitly truncated to unsigned type [-Woverflow] > 0100 0100 0100 0100 > thougt that would bring me 64.64.64.64 ... but nope 10010010010 > warning: large integer implicitly truncated to unsigned type [-Woverflow] 0010010010010 > 64.32.16.8 010010010010 > 64.32.16.8 try to analyze this: 64 dec = 100 octal > looks right since 0 100 100 100 10 32 dec = 40 octal no sense 16 dec = 20 octal 8 dec = 10 octal > looks right since 0 100 100 100 10 hm lets try this: 0 100010 > 0.0.128.8 10oct = 8dec, but 128?---no clue 0 10010 > 0.0.16.8 0 1010 > 0.0.2.8 > 10oct = 8dec, but 2?--- no clue 0 110 > 0.0.0.72 > 110oct = 72dec 0 10 > 0.0.0.8 > 10oct = 8dec no that makes no sense, try out the binary 64: 01000000 > 0.4.0.0 >>> hmm 64.... 4? happy accident? lets try the binary 128 010000000 > 0.32.0.0 --- no clue.... maybe without zero (dont declare it as octal) 10000000 > 0.152.150.128 ....ähm --- the first ip adress....ok what happens if i simply write the decimal 128: 128 > 0.0.0.128 ok maybe i missunderstand the word connections... and i have to do this: OSC_SERVER_RemoteIP_Set(0, 128); OSC_SERVER_RemoteIP_Set(1, 128); OSC_SERVER_RemoteIP_Set(2, 128); OSC_SERVER_RemoteIP_Set(3, 128); nope give me [16184.888] OSC4 Remote address: 0.0.0.128 4times... connections are connections and not numbers in the ip.... hmmmm wahhh hm maybe the Server needs some spacing between the integers: OSC_SERVER_RemoteIP_Set(0, 128/128/128/128); nope give me 0.0.0.0 ok 128128128128 and ignoring the "large integer...." >>> [16505.159] OSC1 Remote address: 213.8.20.128 >>> no clue ok then have a look again in the OSC_SERVER - where i dont understand anything...go to that IP_Set..: s32 OSC_SERVER_RemoteIP_Set(u8 con, u32 ip){ if( con >= OSC_SERVER_NUM_CONNECTIONS ) return -1; // invalid connection osc_remote_ip[con] = ip; #if 0 return OSC_SERVER_Init(0); #else return 0; // OSC_SERVER_Init(0) has to be called after all settings have been done #endif} hm it can be only that: "osc_remote_ip[con] = ip" ip is the input that i wan to set from my application...thats what i try and try and try...here it stands it want a u32 integer... so the only variable that i say that could tell me what is going on is "osc_remote_ip" seek this: // TODO: variable initialisation contains hardcoded dependency to OSC_SERVER_NUM_CONNECTIONS! static u32 osc_remote_ip[OSC_SERVER_NUM_CONNECTIONS] = { OSC_REMOTE_IP, OSC_REMOTE_IP, OSC_REMOTE_IP, OSC_REMOTE_IP }; what? ok ok... this is a arry with variable size, and its initalized 4times with the same Variable/Value.... ähm ok a idea: OSC_SERVER_RemoteIP_Set(4, 128, 128, 128, 128); >>>> nope ...that isnt it again... ok seek more in osc_remote_ip: for(con=0; con<OSC_SERVER_NUM_CONNECTIONS; ++con) { uip_ipaddr_t ripaddr; uip_ipaddr(ripaddr, ((osc_remote_ip[con])>>24) & 0xff, ((osc_remote_ip[con])>>16) & 0xff, ((osc_remote_ip[con])>> 8) & 0xff, ((osc_remote_ip[con])>> 0) & 0xff); ok i have seen this bevore... bevore i testetd all this.. i testet all this because i dont understand that... i have googled what the & 0xff is (it some "to be shure that nobody make mess with variable declaration like u8 u16" or so thing - dont know i think it dont matter with this for thing it looks like a modem dial mechanismus.... this"ripaddr" looks a pointer the uip_ipaddr_t like an structure...hm idea i did not try a structure... but i must to bed, a quick look into structure -tutorials (again, looked in structure about 10 times dont understand it anytime) ...nope i dont learn that today nope ok take a look again in the terminal.c found this: if( OSC_SERVER_RemoteIP_Set(con, ip) >= 0 ) { out("Set OSC%d Remote address to %d.%d.%d.%d", con+1, (ip>>24)&0xff, (ip>>16)&0xff, (ip>>8)&0xff, (ip>>0)&0xff); OSC_SERVER_Init(0); what take my interest is that >>24 >>16 >>8 >>0 thing - that could be the wright direction >> google says: >> used for BIT-FLAGS... ok with the test results from above that could be really the way to go! but thats some good night lecture for tomorrow: http://www.codeproject.com/Articles/13740/The-Beginner-s-Guide-to-Using-Enum-Flags Edited March 4, 2015 by Phatline Quote Link to comment Share on other sites More sharing options...
Phatline Posted March 4, 2015 Author Report Share Posted March 4, 2015 (edited) OK we testet out that this command OSC_SERVER_RemoteIP_Set(0, 10000000) results to 0.152.150.128 we bitshift 24 16 8 0, with that online calculator http://www.miniwebtool.com/bitwise-calculator/bit-shift/?data_type=10&number=0010010010010++&place=24&operator=Shift+Right (hopefully i handle that thing right) or this one http://www.convertalot.com/bitwise_operators.html 10000000dec >> 24 = 0 right 10000000dec >> 16 = 152 right 10000000dec >> 8 = 39062 false (should be 150) 10000000dec >> 0 = 10000000 false!!!! (should be 128) but: 128 in binary is 10000000 so: decimal >> 24 decimal >> 16 decimal ?????? decimal = decimal but how to combine that?.... i must assume that I CANT CHANGE THE IP the way i like . POINT. dont waste my live time for that anymore... - no osc. point. Edited March 6, 2015 by Phatline Quote Link to comment Share on other sites More sharing options...
Phatline Posted March 17, 2015 Author Report Share Posted March 17, 2015 Case: Connect one Midibox to a nother Midibox via LAN-Router - want to have bidirectional Transfair of data. When i enable DHCP, the local ip adress and the netmask will be automaticly set by the router - right. but for OSC i need a remote IP-Adress (the local ip adress of second Midibox) but when it i enable dhcp - i dont know what the ip adress is- and visa versa ... the only thing is that i can swap ports ... so for my understanding the DHCP cant be used, since we dont have something like a DNS server that says: hey i am midibox NR1, and hey i am midibox NR2 and i have IP this and that-ok lets get together - yea right... Quote Link to comment Share on other sites More sharing options...
Phatline Posted March 18, 2015 Author Report Share Posted March 18, 2015 (edited) #include <mios32.h> #include "app.h" #include <uip_task.h> #include <osc_client.h> #include "terminal.h" #include "uip.h" void APP_Init(void){ UIP_TASK_Init(0); TERMINAL_Init(0); MIOS32_DELAY_Wait_uS (65000); //wait 0.06seconds... MIOS32_DELAY_Wait_uS (65000); //wait 0.06seconds... OSC_SERVER_Init(0); OSC_CLIENT_Init(0); UIP_TASK_IP_AddressSet( 128); OSC_SERVER_RemoteIP_Set(0, 127); OSC_SERVER_RemoteIP_Set(1, 127); OSC_SERVER_RemoteIP_Set(2, 127); OSC_SERVER_RemoteIP_Set(3, 127); OSC_SERVER_RemotePortSet(0, 5000); OSC_SERVER_RemotePortSet(1, 5002); OSC_SERVER_RemotePortSet(2, 5004); OSC_SERVER_RemotePortSet(3, 5006); OSC_SERVER_LocalPortSet( 0, 5001); OSC_SERVER_LocalPortSet( 1, 5001); OSC_SERVER_LocalPortSet( 2, 5001); OSC_SERVER_LocalPortSet( 3, 5001); UIP_TASK_NetmaskSet(255); UIP_TASK_DHCP_EnableSet(0); UIP_TASK_UDP_MonitorLevelSet(3); //outputs data to Mios-Studio ---0 turn off MIOS32_LCD_PrintFormattedString("init done"); } void APP_Background(void){} void APP_Tick(void){} void APP_MIDI_Tick(void){} void APP_MIDI_NotifyPackage(mios32_midi_port_t port, mios32_midi_package_t midi_package){ MIOS32_LCD_Clear(); MIOS32_LCD_CursorSet(0, 0); MIOS32_LCD_PrintFormattedString("%u %u %u", port, midi_package.chn, midi_package.type); } s32 APP_SYSEX_Parser(mios32_midi_port_t port, u8 midi_in){return 0;} void APP_SRIO_ServicePrepare(void){} void APP_SRIO_ServiceFinish(void){} void APP_DIN_NotifyToggle(u32 pin, u32 pin_value){ OSC_CLIENT_SendNRPNEvent (0, 8, pin, pin_value);} //port, chn, nr, value;} void APP_ENC_NotifyChange(u32 encoder, s32 incrementer){} void APP_AIN_NotifyChange(u32 pin, u32 pin_value){} but since i cant change the netmask (because on my computer it is not 255.0.0.0) this dont work in my network now my resultats > for Linux type into terminal "ifconfig" (yes iF) eth0 Link encap:Ethernet Hardware Adresse 00:NO:WA:YM:AN inet Adresse:ni.x.g.ibts Bcast:oi.da.sp.in Maske:255.255.255.0 inet6-Adresse: kriegstsichanet Gültigkeitsbereich:Verbindung UP BROADCAST RUNNING MULTICAST MTU:1500 Metrik:1 RX-Pakete:186799 Fehler:0 Verloren:0 Überläufe:0 Fenster:0 TX-Pakete:158764 Fehler:0 Verloren:0 Überläufe:0 Träger:0 Kollisionen:0 Sendewarteschlangenlänge:1000 RX-Bytes:269544579 (269.5 MB) TX-Bytes:12100039 (12.1 MB) Interrupt:18 lo Link encap:Lokale Schleife inet Adresse:127.0.0.1 Maske:255.0.0.0 inet6-Adresse: ::1/128 Gültigkeitsbereich:Maschine UP LOOPBACK RUNNING MTU:65xxx Metrik:1 RX-Pakete:2687 Fehler:0 Verloren:0 Überläufe:0 Fenster:0 TX-Pakete:2687 Fehler:0 Verloren:0 Überläufe:0 Träger:0 Kollisionen:0 Sendewarteschlangenlänge:0 RX-Bytes:253470 (253.4 KB) TX-Bytes:253470 (253.4 KB) now MioStudio-Terminal: [14208.778] system [14208.777] Application: Tutorial #028 [14208.777] Ethernet module connected: yes [14208.777] Ethernet services running: yes [14208.777] DHCP: disabled [14208.777] IP address: 0.0.0.128 [14208.777] Netmask: 0.0.0.255 [14208.777] Default Router (Gateway): 192.168.1.1 [14208.777] OSC1 Remote address: 0.0.0.127 [14208.777] OSC1 Remote port: 5000 [14208.778] OSC1 Local port: 5001 [14208.778] OSC2 Remote address: 0.0.0.127 [14208.778] OSC2 Remote port: 5002 [14208.778] OSC2 Local port: 5001 [14208.778] OSC3 Remote address: 0.0.0.127 [14208.778] OSC3 Remote port: 5004 [14208.778] OSC3 Local port: 5001 [14208.779] OSC4 Remote address: 0.0.0.127 [14208.796] OSC4 Remote port: 5006 [14208.796] OSC4 Local port: 5001 [14208.797] UDP Monitor: verbose level #3 now when i press a DIN-Button - the router-activity port leds lighting up and mios terminal print: [14470.460] [uDP:OSC_SEND] to 100.5.0.0:0 from port 0 (32 bytes) [14470.463] 00000000 2F 6D 69 64 69 31 00 00 2C 6D 6D 6D 6D 00 00 00 /midi1..,mmmm... [14470.463] 00000010 B8 63 00 00 B8 62 12 00 B8 06 00 00 B8 26 01 00 .c...b.......&.. but like i said cant use that. Edited March 18, 2015 by Phatline Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.