Using the µVision Socket Interface: Direct Interface (UVSOCK)

| Using the µVision Socket Interface Application Note 198 Control and monitor µVision via the built-in TCP/IP interface

- Main Page
- Usage and Description
- Reference

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Direct Interface (UVSOCK)

The UVSOCK interface can be used directly, although this is recommended only for cases where the Client Interface (UVSC) cannot be used, for example, when the client runs on an operating system other than Microsoft Windows.

The UVSOCK reference is avaialble in UVSOCK Interface (UVSOCK.h). Refer also to UVSOCK Messaging. Predefined data types are described in UVSOCK Data Types.

Follow these steps when working with UVSOCK:

- Enable UVSOCK in uVision
- Configure a project
- Build a project
- Debug a project
- Accessing Event Recorder Data

All possible operations are listed in UV_OPERATION.

# Enable UVSOCK in uVision

A.) Configure the TCP server port directly in uVision:

1. Select the menu Edit –> Configuration –> Other
2. Enable UVSOCK (TCP/IP) Settings
3. Set server Port, for example, to 4823.

UVSOCK Configuration

B.) Alternatively, configure the TCP server port manually:

1. Open the file TOOLS.INI from the installation folder of uVision (by default, C:\Keil_v5)
2. In the section [UV2] set the value for the entry SOCKETPORT. Setting SOCKETPORT to 0, disables the interface.

Example

[UV2]
...
SOCKETPORT=4823 // =0 - disabled
...

# Configure a project

Configuring a project is the process of opening a uVision project and adding files to project groups. Complex configuration of a project is possible via the uVision IDE. To configure a project:

- Load an existing project with UV_PRJ_LOAD
- Optionally, add new project groups with UV_PRJ_ADD_GROUP
- Optionally, add new files to a project groups with UV_PRJ_ADD_FILE

# Build a project

Building a project is the process of compiling and assembling source files, and linking the resultant object files to create an executable image. To build a project:

- Optionally, clean the project with UV_PRJ_CLEAN
- Build the project with UV_PRJ_BUILD or UV_PRJ_REBUILD
- Optionally, monitor the build output returned by the UV_PRJ_BUILD_OUTPUT message
- Wait for the UV_PRJ_BUILD_COMPLETE message, and check the build result when received.

# Debug a project

Debugging a project is the process of monitoring program execution. There are several methods of debugging:

- Static Debugging - halt execution before inspecting the state.
- Real-Time Debugging - inspect the state while target is executing. Real-Time Debugging is possible in uVision via the Real-Time Agent.

## Static Debugging

Inspect the application state when execution has been halted. Follow these steps for static debugging:

- Enter debug mode with UV_DBG_ENTER
- <<set breakpoints>>
- Start execution with UV_DBG_START_EXECUTION
- Wait for the UV_DBG_STOP_EXECUTION message to arrive, indicating the target program has hit a breakpoint.
- Stop execution with UV_DBG_STOP_EXECUTION
- Inspect memory with UV_DBG_MEM_READ or modify it with UV_DBG_MEM_WRITE. The UV_DBG_CALC_EXPRESSION message is useful for resolving symbol addresses or calculating the value of code expressions.
- Step execution with UV_DBG_STEP_HLL, UV_DBG_STEP_INTO, UV_DBG_STEP_INSTRUCTION, and UV_DBG_STEP_OUT, waiting for the UV_DBG_STOP_EXECUTION message after issuing each step command.
- Restart execution with UV_DBG_START_EXECUTION
- Exit debug mode with UV_DBG_EXIT

## Real-Time Debugging

Inspect the application state while the target is executing. Follow these steps for real-time debugging:

- Enter debug mode with UV_DBG_ENTER
- Start execution with UV_DBG_START_EXECUTION
- Inspect memory with UV_DBG_MEM_READ or modify it with UV_DBG_MEM_WRITE. The UV_DBG_CALC_EXPRESSION message is useful for resolving symbol addresses or calculating the value of code expressions.
- If the target program contains the Real-Time Agent (only available for non-Arm targets), debug information from the operating system and auto-generated code structures can be received at any time via the UV_RTA_MESSAGE message.

To communicate with the target via a serial interface, use any UART or the Real-Time Agent Terminal in simulation or target mode:

- Send serial data to the target with UV_DBG_SERIAL_PUT
- Receive serial data from the target with UV_DBG_SERIAL_GET

To exit debugging mode:

- Stop execution with UV_DBG_STOP_EXECUTION
- Exit debug mode with UV_DBG_EXIT

# Accessing Event Recorder Data

Event Recorder shows the dynamic behavior of software components that helps you to analyze the internal operation. Using the UVSOCK interface, it is possible to gain access to the Event Recorder data:

- Register to receive Event Records:
  UV_DBG_EVTR_REGISTER = 0x2035 // Register to receive the Event Recorder Data
  // Request format: no data
  // Response format: #UVSOCK_CMD_RESPONSE --> no data / #UVSOCK_ERROR_RESPONSE
- Unregister to receive Event Records:
  UV_DBG_EVTR_UNREGISTER = 0x2036 // Unregister to not receive the data sent from Event Recorder anymore
  // Request format: no data
  // Response format: #UVSOCK_CMD_RESPONSE --> no data / #UVSOCK_ERROR_RESPONSE
- Check the current Event Recorder status:
  UV_DBG_EVTR_GETSTATUS = 0x2037 // Status of Event Recorder
  // Request format: no data
  // Response format #UVSOCK_CMD_RESPONSE --> no data / #UVSOCK_ERROR_RESPONSE
- Get the list of active SCVD files:
  UV_DBG_EVTR_ENUMSCVDFILES = 0x2038 // Get SCVD files
  // Request format: no data
  // Response format: #UVSOCK_CMD_RESPONSE --> no data / #UVSOCK_ERROR_RESPONSE

The interface will answer with these responses to the requests:

- Response to registering events:
  UV_DBG_EVTR_OUTPUT = 0x5063 // Notification of Event Recorder Data
  // Async format : #EVTROUT
- Response to requesting SCVD files:
  UV_DBG_EVTR_ENUMSCVDFILES_START = 0x5064, // Start of available view enumeration
  // Async format : no data
  UV_DBG_EVTR_ENUMSCVDFILES_ENU = 0x5065, // View list enumeration; one or more Response(s) with view item information
  // Async format : #UVSOCK_CMD_RESPONSE --> #SSTR / #UVSOCK_ERROR_RESPONSE
  UV_DBG_EVTR_ENUMSCVDFILES_END = 0x5066, // End of task list enumeration
  // Async format : no data