# OSC Debug
[Core]

The Debug subsystem offers a simple way to send debug messages back from the MAKE Controller via OSC. More...

## Functions
int | Debug_SetActive (int state)
| Sets whether the Debug subsystem is active.
int | Debug_GetActive ()
| Returns the active state of the Debug subsystem.
int | Debug_SetLevel (int level)
| Sets the debug level.
int | Debug_GetLevel ()
| Read the current debugger level.
int | Debug_SetUsb (int state)
| Sets whether the Debug subsystem outputs its OSC messages via USB.
int | Debug_GetUsb ()
| Returns whether the Debug system is set to send its messages over USB.
int | Debug_SetUdp (int state)
| Sets whether the Debug system is set to send its messages over UDP.
int | Debug_GetUdp ()
| Sets whether the Debug subsystem outputs its OSC messages via USB.
int | Debug (int level, char *format,...)
| Create a debug message.
#define | DEBUG_ALWAYS 0
| The lowest debug level, used for messages that should go out no matter what.
#define | DEBUG_ERROR 1
| Used for critical/fatal error messages.
#define | DEBUG_WARNING 2
| Used for warnings.
#define | DEBUG_MESSAGE 3
| Used for normal/test messages.

## Detailed Description

The Debug subsystem offers a simple way to send debug messages back from the MAKE Controller via OSC.

Even without single-stepping through the code running on the MAKE Controller, it is still easy to get helpful debug information about the program through the Debug subsystem.

Specify the level of each debug message and then, in a debug session, set the level you would like to see. More frequent and lower level messages can be filtered out in a debug session by setting the debug level a bit higher to let through only the messages you're interested in.

Possible levels are:

- 0 - Always send
- 1 - Error messages
- 2 - Warning messages
- 3 - Normal/test messages

## Define Documentation

#define DEBUG_ALWAYS 0

The lowest debug level, used for messages that should go out no matter what.

Definition at line 31 of file debug.h.

#define DEBUG_ERROR 1

Used for critical/fatal error messages.

Definition at line 32 of file debug.h.

#define DEBUG_MESSAGE 3

Used for normal/test messages.

Definition at line 34 of file debug.h.

#define DEBUG_WARNING 2

Used for warnings.

Definition at line 33 of file debug.h.

## Function Documentation

int Debug | ( | int | level,
|  | char * | format,
|  |  | ... |
| ) |  |  |

Create a debug message.

Parameters:

  | level | An integer specifying the debug level.
  | format | printf()-style formatting. d, s, x, etc.
  | ... | The contents of the debug message - this can look just like a call to printf().

Example

        // send a simple debug message...
        Debug( DEBUG_MESSAGE, "%s", "Hello." );

        // or a slightly more interesting message
        SomeTask( void* p )
        {
          int counter = 0;
          while( 1 )
          {
            Debug( DEBUG_MESSAGE, "%s %d", "Current count is: ", counter++ );
            Sleep( 1000 );
          }
        }

Returns:

Definition at line 267 of file debugosc.c.

int Debug_GetActive | ( | void |  | ) |

Returns the active state of the Debug subsystem.

Returns:
  State - 1 (active) or 0 (inactive).

Example

        // Check to see if we're active...
        int active = Debug_GetActive();
        if( active )
          // then do something...

Definition at line 107 of file debugosc.c.

int Debug_GetLevel | ( | void |  | ) |

Read the current debugger level.

Returns:
  Level An integer from 0-3 specifying the level.

Example

        // Check the current debug level
        int level = Debug_GetLevel( );
        switch( level )
        {
          case DEBUG_ALWAYS:
            // ...
            break;
          case DEBUG_ERROR:
            // ...
            break;
          case DEBUG_WARNING:
            // ...
            break;
          case DEBUG_MESSAGE:
            // ...
            break;
        }

Definition at line 157 of file debugosc.c.

int Debug_GetUdp | ( | void |  | ) |

Sets whether the Debug subsystem outputs its OSC messages via USB.

This is enabled by default.

Returns:
  state An integer specifying whether messages will be sent over USB - 1 (enabled) or 0 (disabled).

Example

        // Check whether we're sending Debug messages over UDP
        int udp_debug = Debug_GetUdp( );

Definition at line 233 of file debugosc.c.

int Debug_GetUsb | ( | void |  | ) |

Returns whether the Debug system is set to send its messages over USB.

This is enabled by default.

Returns:
  state An integer specifying whether messages will be sent over USB - 1 (enabled) or 0 (disabled).

Example

        // Check whether we're sending Debug messages over USB
        int usb_debug = Debug_GetUsb( );

Definition at line 195 of file debugosc.c.

int Debug_SetActive | ( | int | state | ) |

Sets whether the Debug subsystem is active.

The Debug system is automatically set to active by making a call to any Debug system function, so you don't typically have to worry about doing that. But, you can set it to inactive to recover a bit of space on the heap.

Parameters:

  | state | An integer specifying the active state - 1 (active) or 0 (inactive).

Returns:
  Zero on success.

Example

        // Checking the debug level sets the system to active.
        int level = Debug_GetLevel();
        // then we can turn it off
        Debug_SetActive( 0 );

Definition at line 78 of file debugosc.c.

int Debug_SetLevel | ( | int | level | ) |

Sets the debug level.

Set to a lower number to get more messages. Default level is 3.

Parameters:

  | level | An integer specifying the level (from 0-3).

Returns:
  0 on success

Example

        // Set the level to just report error messages.
        Debug_SetLevel( 1 );

Definition at line 124 of file debugosc.c.

int Debug_SetUdp | ( | int | state | ) |

Sets whether the Debug system is set to send its messages over UDP.

This is enabled by default.

Parameters:

  | state | An integer specifying the state - 1 (on) or 0 (off).

Returns:
  Zero on success.

Example

        // Turn debugging over UDP off.
        Debug_SetUdp( 0 );

Definition at line 214 of file debugosc.c.

int Debug_SetUsb | ( | int | state | ) |

Sets whether the Debug subsystem outputs its OSC messages via USB.

This is enabled by default.

Parameters:

  | state | An integer specifying whether or not to send over USB - 1 (on) or 0 (off).

Returns:
  Zero on success.

Example

        // Turn debugging over USB off.
        Debug_SetUsb( 0 );

Definition at line 176 of file debugosc.c.