Subversion Repositories svn.mios32

Rev

Rev 1320 | Rev 1387 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1260 tk 1
// $Id: terminal.c 1333 2011-09-22 22:13:49Z tk $
2
/*
3
 * The command/configuration Terminal
4
 *
5
 * ==========================================================================
6
 *
7
 *  Copyright (C) 2010 Thorsten Klose (tk@midibox.org)
8
 *  Licensed for personal non-commercial use only.
9
 *  All other rights reserved.
10
 *
11
 * ==========================================================================
12
 */
13
 
14
/////////////////////////////////////////////////////////////////////////////
15
// Include files
16
/////////////////////////////////////////////////////////////////////////////
17
 
18
#include <mios32.h>
19
#include <string.h>
20
 
21
#include "app.h"
22
#include "midio_patch.h"
23
#include "terminal.h"
24
#include "midimon.h"
25
#include "uip.h"
26
#include "uip_task.h"
27
#include "tasks.h"
28
#include "osc_server.h"
29
#include "midio_file.h"
30
#include "midio_file_p.h"
31
 
32
/////////////////////////////////////////////////////////////////////////////
33
// Local defines
34
/////////////////////////////////////////////////////////////////////////////
35
 
36
#define STRING_MAX 80
37
 
38
 
39
/////////////////////////////////////////////////////////////////////////////
40
// Local variables
41
/////////////////////////////////////////////////////////////////////////////
42
 
43
static char line_buffer[STRING_MAX];
44
static u16 line_ix;
45
 
46
 
47
/////////////////////////////////////////////////////////////////////////////
48
// Local prototypes
49
/////////////////////////////////////////////////////////////////////////////
50
 
51
static s32 TERMINAL_PrintSystem(void *_output_function);
52
static s32 TERMINAL_PrintIPs(void *_output_function);
53
 
54
 
55
/////////////////////////////////////////////////////////////////////////////
56
// Initialisation
57
/////////////////////////////////////////////////////////////////////////////
58
s32 TERMINAL_Init(u32 mode)
59
{
60
  // install the callback function which is called on incoming characters
61
  // from MIOS Terminal
62
  MIOS32_MIDI_DebugCommandCallback_Init(TERMINAL_Parse);
63
 
64
  // clear line buffer
65
  line_buffer[0] = 0;
66
  line_ix = 0;
67
 
68
  return 0; // no error
69
}
70
 
71
 
72
/////////////////////////////////////////////////////////////////////////////
73
// help function which parses a decimal or hex value
74
// returns >= 0 if value is valid
75
// returns -1 if value is invalid
76
/////////////////////////////////////////////////////////////////////////////
77
static s32 get_dec(char *word)
78
{
79
  if( word == NULL )
80
    return -1;
81
 
82
  char *next;
83
  long l = strtol(word, &next, 0);
84
 
85
  if( word == next )
86
    return -1;
87
 
88
  return l; // value is valid
89
}
90
 
91
 
92
/////////////////////////////////////////////////////////////////////////////
93
// help function which parses for on or off
94
// returns 0 if 'off', 1 if 'on', -1 if invalid
95
/////////////////////////////////////////////////////////////////////////////
96
static s32 get_on_off(char *word)
97
{
98
  if( strcmp(word, "on") == 0 )
99
    return 1;
100
 
101
  if( strcmp(word, "off") == 0 )
102
    return 0;
103
 
104
  return -1;
105
}
106
 
107
 
108
/////////////////////////////////////////////////////////////////////////////
109
// help function which parses an IP value
110
// returns > 0 if value is valid
111
// returns 0 if value is invalid
112
/////////////////////////////////////////////////////////////////////////////
113
static u32 get_ip(char *word)
114
{
115
  char *brkt;
116
  u8 ip[4];
117
 
118
  int i;
119
  for(i=0; i<4; ++i) {
120
    if( (word = strtok_r((i == 0) ? word : NULL, ".", &brkt)) ) {
121
      s32 value = get_dec(word);
122
      if( value >= 0 && value <= 255 )
123
    ip[i] = value;
124
      else
125
    return 0;
126
    }
127
  }
128
 
129
  if( i == 4 )
130
    return (ip[0]<<24)|(ip[1]<<16)|(ip[2]<<8)|(ip[3]<<0);
131
  else
132
    return 0; // invalid IP
133
}
134
 
135
 
136
/////////////////////////////////////////////////////////////////////////////
137
// Parser
138
/////////////////////////////////////////////////////////////////////////////
1333 tk 139
s32 TERMINAL_Parse(mios32_midi_port_t port, char byte)
1260 tk 140
{
141
  // temporary change debug port (will be restored at the end of this function)
142
  mios32_midi_port_t prev_debug_port = MIOS32_MIDI_DebugPortGet();
143
  MIOS32_MIDI_DebugPortSet(port);
144
 
145
  if( byte == '\r' ) {
146
    // ignore
147
  } else if( byte == '\n' ) {
148
    MUTEX_MIDIOUT_TAKE;
149
    TERMINAL_ParseLine(line_buffer, MIOS32_MIDI_SendDebugMessage);
150
    MUTEX_MIDIOUT_GIVE;
151
    line_ix = 0;
152
    line_buffer[line_ix] = 0;
153
  } else if( line_ix < (STRING_MAX-1) ) {
154
    line_buffer[line_ix++] = byte;
155
    line_buffer[line_ix] = 0;
156
  }
157
 
158
  // restore debug port
159
  MIOS32_MIDI_DebugPortSet(prev_debug_port);
160
 
161
  return 0; // no error
162
}
163
 
164
 
165
/////////////////////////////////////////////////////////////////////////////
166
// Parser for a complete line - also used by shell.c for telnet
167
/////////////////////////////////////////////////////////////////////////////
168
s32 TERMINAL_ParseLine(char *input, void *_output_function)
169
{
170
  void (*out)(char *format, ...) = _output_function;
171
  char *separators = " \t";
172
  char *brkt;
173
  char *parameter;
174
 
175
  if( (parameter = strtok_r(input, separators, &brkt)) ) {
176
    if( strcmp(parameter, "help") == 0 ) {
177
      out("Welcome to " MIOS32_LCD_BOOT_MSG_LINE1 "!");
178
      out("Following commands are available:");
179
      out("  system:                           print system info");
180
      out("  set dhcp <on|off>:                enables/disables DHCP");
181
      out("  set ip <address>:                 changes IP address");
182
      out("  set netmask <mask>:               changes netmask");
183
      out("  set gateway <address>:            changes gateway address");
184
      out("  set osc_remote <con> <address>:   changes OSC Remote Address");
185
      out("  set osc_remote_port <con> <port>: changes OSC Remote Port (1024..65535)");
186
      out("  set osc_local_port <con> <port>:  changes OSC Local Port (1024..65535)");
1284 tk 187
      out("  set udpmon <0..4>:                enables UDP monitor (verbose level: %d)\n", UIP_TASK_UDP_MonitorLevelGet());
1260 tk 188
      out("  set midimon <on|off>:             enables/disables the MIDI monitor");
189
      out("  set midimon_filter <on|off>:      enables/disables MIDI monitor filters");
190
      out("  set midimon_tempo <on|off>:       enables/disables the tempo display");
1292 tk 191
      out("  set dout <pin> <0|1>:             directly sets DOUT (all or 0..%d) to given level (1 or 0)", MIOS32_SRIO_NUM_SR*8 - 1);
1264 tk 192
      out("  save <name>:                      stores current config on SD Card");
193
      out("  load <name>:                      restores config from SD Card");
1260 tk 194
      out("  show:                             shows the current configuration file");
1320 tk 195
      out("  msd <on|off>:                     enables Mass Storage Device driver");
1260 tk 196
      out("  reset:                            resets the MIDIbox (!)\n");
197
      out("  help:                             this page");
198
      out("  exit:                             (telnet only) exits the terminal");
199
    } else if( strcmp(parameter, "system") == 0 ) {
200
      TERMINAL_PrintSystem(_output_function);
1320 tk 201
    } else if( strcmp(parameter, "msd") == 0 ) {
202
      char *arg = NULL;
203
      if( (arg = strtok_r(NULL, separators, &brkt)) ) {
204
    if( strcmp(arg, "on") == 0 ) {
205
      if( TASK_MSD_EnableGet() ) {
206
        out("Mass Storage Device Mode already activated!\n");
207
      } else {
208
        out("Mass Storage Device Mode activated - USB MIDI will be disabled!!!\n");
209
        // wait a second to ensure that this message is print in MIOS Terminal
210
        int d;
211
        for(d=0; d<1000; ++d)
212
          MIOS32_DELAY_Wait_uS(1000);
213
        // activate MSD mode
214
        TASK_MSD_EnableSet(1);
215
      }
216
    } else if( strcmp(arg, "off") == 0 ) {
217
      if( !TASK_MSD_EnableGet() ) {
218
        out("Mass Storage Device Mode already deactivated!\n");
219
      } else {
220
        out("Mass Storage Device Mode deactivated - USB MIDI will be available again.n");
221
        TASK_MSD_EnableSet(0);
222
      }
223
    } else
224
      arg = NULL;
225
      }
226
      if( arg == NULL ) {
227
    out("Please enter 'msd on' or 'msd off'\n");
228
      }      
1264 tk 229
    } else if( strcmp(parameter, "save") == 0 ) {
230
      if( !(parameter = strtok_r(NULL, separators, &brkt)) ) {
231
    out("ERROR: please specify filename for patch (up to 8 characters)!");
1260 tk 232
      } else {
1264 tk 233
    if( strlen(parameter) > 8 ) {
234
      out("ERROR: 8 characters maximum!");
235
    } else {
236
      s32 status = MIDIO_PATCH_Store(parameter);
237
      if( status >= 0 ) {
238
        out("Patch '%s' stored on SD Card!", parameter);
239
      } else {
240
        out("ERROR: failed to store patch '%s' on SD Card (status %d)!", parameter, status);
241
      }
242
    }
1260 tk 243
      }
1264 tk 244
    } else if( strcmp(parameter, "load") == 0 ) {
245
      if( !(parameter = strtok_r(NULL, separators, &brkt)) ) {
246
    out("ERROR: please specify filename for patch (up to 8 characters)!");
1260 tk 247
      } else {
1264 tk 248
    if( strlen(parameter) > 8 ) {
249
      out("ERROR: 8 characters maximum!");
250
    } else {
251
      s32 status = MIDIO_PATCH_Load(parameter);
252
      if( status >= 0 ) {
253
        out("Patch '%s' loaded from SD Card!", parameter);
254
      } else {
255
        out("ERROR: failed to load patch '%s' on SD Card (status %d)!", parameter, status);
256
      }
257
    }
1260 tk 258
      }
259
    } else if( strcmp(parameter, "show") == 0 ) {
260
      MIDIO_FILE_P_Debug();
261
    } else if( strcmp(parameter, "reset") == 0 ) {
262
      MIOS32_SYS_Reset();
263
    } else if( strcmp(parameter, "set") == 0 ) {
264
      if( (parameter = strtok_r(NULL, separators, &brkt)) ) {
265
    if( strcmp(parameter, "dhcp") == 0 ) {
266
      s32 on_off = -1;
267
      if( (parameter = strtok_r(NULL, separators, &brkt)) )
268
        on_off = get_on_off(parameter);
269
 
270
      if( on_off < 0 ) {
271
        out("Expecting 'on' or 'off'!");
272
      } else {
273
        UIP_TASK_DHCP_EnableSet(on_off);
274
        if( UIP_TASK_DHCP_EnableGet() ) {
275
          out("DHCP enabled - waiting for IP address from server!\n");
276
        } else {
277
          out("DHCP disabled - using predefined values:");
278
          TERMINAL_PrintIPs(_output_function);
279
        }
280
      }
281
    } else if( strcmp(parameter, "ip") == 0 ) {
282
      if( UIP_TASK_DHCP_EnableGet() ) {
283
        out("ERROR: DHCP enabled - please disable it first via 'set dhcp off'");
284
      } else {
285
        u32 ip = 0;
286
        if( (parameter = strtok_r(NULL, separators, &brkt)) )
287
          ip = get_ip(parameter);
288
        if( !ip ) {
289
          out("Expecting IP address in format a.b.c.d!");
290
        } else {
291
          uip_ipaddr_t ipaddr;
292
          UIP_TASK_IP_AddressSet(ip);
293
          uip_gethostaddr(&ipaddr);
294
          out("Set IP address to %d.%d.%d.%d",
295
          uip_ipaddr1(ipaddr), uip_ipaddr2(ipaddr),
296
          uip_ipaddr3(ipaddr), uip_ipaddr4(ipaddr));
297
        }
298
      }
299
    } else if( strcmp(parameter, "netmask") == 0 ) {
300
      if( UIP_TASK_DHCP_EnableGet() ) {
301
        out("ERROR: DHCP enabled - please disable it first via 'set dhcp off'");
302
      } else {
303
        u32 ip = 0;
304
        if( (parameter = strtok_r(NULL, separators, &brkt)) )
305
          ip = get_ip(parameter);
306
        if( !ip ) {
307
          out("Expecting netmask in format a.b.c.d!");
308
        } else {
309
          uip_ipaddr_t ipaddr;
310
          UIP_TASK_NetmaskSet(ip);
311
          uip_getnetmask(&ipaddr);
312
          out("Set netmask to %d.%d.%d.%d",
313
          uip_ipaddr1(ipaddr), uip_ipaddr2(ipaddr),
314
          uip_ipaddr3(ipaddr), uip_ipaddr4(ipaddr));
315
        }
316
      }
317
    } else if( strcmp(parameter, "gateway") == 0 ) {
318
      if( UIP_TASK_DHCP_EnableGet() ) {
319
        out("ERROR: DHCP enabled - please disable it first via 'set dhcp off'");
320
      } else {
321
        u32 ip = 0;
322
        if( (parameter = strtok_r(NULL, separators, &brkt)) )
323
          ip = get_ip(parameter);
324
        if( !ip ) {
325
          out("Expecting gateway address in format a.b.c.d!");
326
        } else {
327
          uip_ipaddr_t ipaddr;
328
          UIP_TASK_GatewaySet(ip);
329
          uip_getdraddr(&ipaddr);
330
          out("Set gateway to %d.%d.%d.%d",
331
          uip_ipaddr1(ipaddr), uip_ipaddr2(ipaddr),
332
          uip_ipaddr3(ipaddr), uip_ipaddr4(ipaddr));
333
        }
334
      }
335
    } else if( strcmp(parameter, "osc_remote") == 0 ) {
336
      if( !UIP_TASK_ServicesRunning() ) {
337
        out("ERROR: Ethernet services not running yet!");
338
      } else {
339
        s32 con = -1;
340
        if( (parameter = strtok_r(NULL, separators, &brkt)) )
341
          con = get_dec(parameter);
342
        if( con < 1 || con >= OSC_SERVER_NUM_CONNECTIONS) {
343
          out("Invalid OSC connection specified as first parameter (expecting 1..%d)!", OSC_SERVER_NUM_CONNECTIONS);
344
        } else {
1284 tk 345
          con-=1; // the user counts from 1
1260 tk 346
 
347
          u32 ip = 0;
348
          if( (parameter = strtok_r(NULL, separators, &brkt)) )
349
        ip = get_ip(parameter);
350
          if( !ip ) {
351
        out("Expecting OSC connection <1..%d> and remote address in format a.b.c.d!", OSC_SERVER_NUM_CONNECTIONS);
352
          } else {
1284 tk 353
        if( OSC_SERVER_RemoteIP_Set(con, ip) >= 0 ) {
354
          out("Set OSC%d Remote address to %d.%d.%d.%d",
355
              con+1,
1260 tk 356
              (ip>>24)&0xff, (ip>>16)&0xff, (ip>>8)&0xff, (ip>>0)&0xff);
1284 tk 357
          OSC_SERVER_Init(0);
358
        } else
359
          out("ERROR: failed to set OSC%d Remote address!", con+1);
1260 tk 360
          }
361
        }
362
      }
363
    } else if( strcmp(parameter, "osc_remote_port") == 0 ) {
364
      if( !UIP_TASK_ServicesRunning() ) {
365
        out("ERROR: Ethernet services not running yet!");
366
      } else {
367
        s32 con = -1;
368
        if( (parameter = strtok_r(NULL, separators, &brkt)) )
369
          con = get_dec(parameter);
370
        if( con < 1 || con >= OSC_SERVER_NUM_CONNECTIONS) {
371
          out("Invalid OSC connection specified as first parameter (expecting 1..%d)!", OSC_SERVER_NUM_CONNECTIONS);
372
        } else {
1284 tk 373
          con-=1; // the user counts from 1
1260 tk 374
 
375
          s32 value = -1;
376
          if( (parameter = strtok_r(NULL, separators, &brkt)) )
377
        value = get_dec(parameter);
378
          if( value < 1024 || value >= 65535) {
379
        out("Expecting OSC connection (1..%d) and remote port value in range 1024..65535", OSC_SERVER_NUM_CONNECTIONS);
380
          } else {
1284 tk 381
        if( OSC_SERVER_RemotePortSet(con, value) >= 0 ) {
382
          out("Set OSC%d Remote port to %d", con+1, value);
383
          OSC_SERVER_Init(0);
384
        } else
385
          out("ERROR: failed to set OSC%d remote port!", con+1);
1260 tk 386
          }
387
        }
388
      }
389
    } else if( strcmp(parameter, "osc_local_port") == 0 ) {
390
      if( !UIP_TASK_ServicesRunning() ) {
391
        out("ERROR: Ethernet services not running yet!");
392
      } else {
393
        s32 con = -1;
394
        if( (parameter = strtok_r(NULL, separators, &brkt)) )
395
          con = get_dec(parameter);
396
        if( con < 1 || con >= OSC_SERVER_NUM_CONNECTIONS) {
397
          out("Invalid OSC connection specified as first parameter (expecting 1..%d)!", OSC_SERVER_NUM_CONNECTIONS);
398
        } else {
1284 tk 399
          con-=1; // the user counts from 1
1260 tk 400
 
401
          s32 value = -1;
402
          if( (parameter = strtok_r(NULL, separators, &brkt)) )
403
        value = get_dec(parameter);
404
          if( value < 1024 || value >= 65535) {
405
        out("Expecting OSC connection (1..%d) and local port value in range 1024..65535", OSC_SERVER_NUM_CONNECTIONS);
406
          } else {
1284 tk 407
        if( OSC_SERVER_LocalPortSet(con, value) >= 0 ) {
408
          out("Set OSC%d Local port to %d", con+1, value);
409
          OSC_SERVER_Init(0);
410
        } else
411
          out("ERROR: failed to set OSC%d local port!", con+1);
1260 tk 412
          }
413
        }
414
      }
415
    } else if( strcmp(parameter, "udpmon") == 0 ) {
416
      char *arg;
417
      if( (arg = strtok_r(NULL, separators, &brkt)) ) {
418
        int level = get_dec(arg);
419
        switch( level ) {
420
        case UDP_MONITOR_LEVEL_0_OFF:
421
          out("Set UDP monitor level to %d (off)\n", level);
422
          break;
423
        case UDP_MONITOR_LEVEL_1_OSC_REC:
424
          out("Set UDP monitor level to %d (received packets assigned to a OSC1..4 port)\n", level);
425
          break;
426
        case UDP_MONITOR_LEVEL_2_OSC_REC_AND_SEND:
427
          out("Set UDP monitor level to %d (received and sent packets assigned to a OSC1..4 port)\n", level);
428
          break;
429
        case UDP_MONITOR_LEVEL_3_ALL_GEQ_1024:
430
          out("Set UDP monitor level to %d (all received and sent packets with port number >= 1024)\n", level);
431
          break;
432
        case UDP_MONITOR_LEVEL_4_ALL:
433
          out("Set UDP monitor level to %d (all received and sent packets)\n", level);
434
          break;
435
        default:
436
          out("Invalid level %d - please specify monitor level 0..4\n", level);
437
          level = -1; // invalidate level for next if() check
438
        }
439
 
440
        if( level >= 0 )
441
          UIP_TASK_UDP_MonitorLevelSet(level);
442
      } else {
443
        out("Please specify monitor level (0..4)\n");
444
      }
445
    } else if( strcmp(parameter, "midimon") == 0 ) {
446
      s32 on_off = -1;
447
      if( (parameter = strtok_r(NULL, separators, &brkt)) )
448
        on_off = get_on_off(parameter);
449
 
450
      if( on_off < 0 ) {
451
        out("Expecting 'on' or 'off'!");
452
      } else {
453
        MIDIMON_ActiveSet(on_off);
454
        out("MIDI Monitor %s!", MIDIMON_ActiveGet() ? "enabled" : "disabled");
455
      }
456
    } else if( strcmp(parameter, "midimon_filter") == 0 ) {
457
      s32 on_off = -1;
458
      if( (parameter = strtok_r(NULL, separators, &brkt)) )
459
        on_off = get_on_off(parameter);
460
 
461
      if( on_off < 0 ) {
462
        out("Expecting 'on' or 'off'!");
463
      } else {
464
        MIDIMON_FilterActiveSet(on_off);
465
        out("MIDI Monitor Filter %s!", MIDIMON_FilterActiveGet() ? "enabled" : "disabled");
466
      }
467
    } else if( strcmp(parameter, "midimon_tempo") == 0 ) {
468
      s32 on_off = -1;
469
      if( (parameter = strtok_r(NULL, separators, &brkt)) )
470
        on_off = get_on_off(parameter);
471
 
472
      if( on_off < 0 ) {
473
        out("Expecting 'on' or 'off'!");
474
      } else {
475
        MIDIMON_TempoActiveSet(on_off);
476
        out("MIDI Monitor Tempo Display %s!", MIDIMON_TempoActiveGet() ? "enabled" : "disabled");
477
      }
478
    } else if( strcmp(parameter, "dout") == 0 ) {
479
      s32 pin = -1;
480
      if( (parameter = strtok_r(NULL, separators, &brkt)) ) {
481
        if( strcmp(parameter, "all") == 0 ) {
482
          pin = -42;
483
        } else {
484
          pin = get_dec(parameter);
485
        }
486
      }
487
 
488
      if( (pin < 0 && pin != -42) || pin >= (MIOS32_SRIO_NUM_SR*8) ) {
489
        out("Pin number should be between 0..%d", MIOS32_SRIO_NUM_SR*8 - 1);
490
      } else {
491
        s32 value = -1;
492
        if( (parameter = strtok_r(NULL, separators, &brkt)) )
493
          value = get_dec(parameter);
494
 
495
        if( value < 0 || value > 1 ) {
496
          out("Expecting value 1 or 0 for DOUT pin %d", pin);
497
        } else {
498
          if( pin == -42 ) {
499
        for(pin=0; pin<(MIOS32_SRIO_NUM_SR*8); ++pin)
500
          MIOS32_DOUT_PinSet(pin, value);
501
        out("All DOUT pins set to %d", value);
502
          } else {
503
        MIOS32_DOUT_PinSet(pin, value);
504
        out("DOUT Pin %d (SR#%d.D%d) set to %d", pin, (pin/8)+1, 7-(pin%8), value);
505
          }
506
        }
507
      }
508
    } else {
509
      out("Unknown set parameter: '%s'!", parameter);
510
    }
511
      } else {
512
    out("Missing parameter after 'set'!");
513
      }
514
    } else {
515
      out("Unknown command - type 'help' to list available commands!");
516
    }
517
  }
518
 
519
  return 0; // no error
520
}
521
 
522
 
523
/////////////////////////////////////////////////////////////////////////////
524
// System Informations
525
/////////////////////////////////////////////////////////////////////////////
526
static s32 TERMINAL_PrintSystem(void *_output_function)
527
{
528
  void (*out)(char *format, ...) = _output_function;
529
 
530
  out("Application: " MIOS32_LCD_BOOT_MSG_LINE1);
531
 
532
  out("Ethernet module connected: %s", UIP_TASK_NetworkDeviceAvailable() ? "yes" : "no");
533
  out("Ethernet services running: %s", UIP_TASK_ServicesRunning() ? "yes" : "no");
534
  out("DHCP: %s", UIP_TASK_DHCP_EnableGet() ? "enabled" : "disabled");
535
 
536
  if( UIP_TASK_DHCP_EnableGet() && !UIP_TASK_ServicesRunning() ) {
537
    out("IP address: not available yet");
538
    out("Netmask: not available yet");
539
    out("Default Router (Gateway): not available yet");
540
  } else {
541
    TERMINAL_PrintIPs(_output_function);
542
  }
543
 
544
  int con;
545
  for(con=0; con<OSC_SERVER_NUM_CONNECTIONS; ++con) {
546
    u32 osc_remote_ip = OSC_SERVER_RemoteIP_Get(con);
547
    out("OSC%d Remote address: %d.%d.%d.%d",
548
    con+1,
549
    (osc_remote_ip>>24)&0xff, (osc_remote_ip>>16)&0xff,
550
    (osc_remote_ip>>8)&0xff, (osc_remote_ip>>0)&0xff);
551
    out("OSC%d Remote port: %d", con+1, OSC_SERVER_RemotePortGet(con));
552
    out("OSC%d Local port: %d", con+1, OSC_SERVER_LocalPortGet(con));
553
  }
554
 
555
  out("UDP Monitor: verbose level #%d\n", UIP_TASK_UDP_MonitorLevelGet());
556
 
557
  out("MIDI Monitor: %s", MIDIMON_ActiveGet() ? "enabled" : "disabled");
558
  out("MIDI Monitor Filters: %s", MIDIMON_FilterActiveGet() ? "enabled" : "disabled");
559
  out("MIDI Monitor Tempo Display: %s", MIDIMON_TempoActiveGet() ? "enabled" : "disabled");
560
 
561
  return 0; // no error
562
}
563
 
564
 
565
 
566
/////////////////////////////////////////////////////////////////////////////
567
// Print IP settings (used by multiple functions)
568
/////////////////////////////////////////////////////////////////////////////
569
static s32 TERMINAL_PrintIPs(void *_output_function)
570
{
571
  void (*out)(char *format, ...) = _output_function;
572
 
573
  uip_ipaddr_t ipaddr;
574
  uip_gethostaddr(&ipaddr);
575
  out("IP address: %d.%d.%d.%d",
576
      uip_ipaddr1(ipaddr), uip_ipaddr2(ipaddr),
577
      uip_ipaddr3(ipaddr), uip_ipaddr4(ipaddr));
578
 
579
  uip_ipaddr_t netmask;
580
  uip_getnetmask(&netmask);
581
  out("Netmask: %d.%d.%d.%d",
582
      uip_ipaddr1(netmask), uip_ipaddr2(netmask),
583
      uip_ipaddr3(netmask), uip_ipaddr4(netmask));
584
 
585
  uip_ipaddr_t draddr;
586
  uip_getdraddr(&draddr);
587
  out("Default Router (Gateway): %d.%d.%d.%d",
588
      uip_ipaddr1(draddr), uip_ipaddr2(draddr),
589
      uip_ipaddr3(draddr), uip_ipaddr4(draddr));
590
 
591
  return 0; // no error
592
}