Communicate with a real-time capable application

Azure Sphere supports inter-core communication between high-level applications and real-time capable applications (RTApp). High-level applications can use the applibs Application_Connect function to send and receive data when communicating with an RTApp. Application_Connect retrieves a file descriptor to a socket that is used to communicate with the RTApp. While the file descriptor is open, you can perform operations on it, such as send/recv.

The IntercoreComms sample demonstrate how to use a high-level application to communicate with an RTApp on an MT3620. Communicate with a high-level application describes programming considerations for the RTApp.

Requirements

High-level applications that use inter-app communication must include the appropriate header files and add application settings to the application manifest.

Header files

#include <sys/socket.h>
#include <applibs/application.h>

App manifest settings

To communicate with an RTApp, both applications need to include the AllowedApplicationConnections capability in the application manifest:

  • The high-level application must list the component ID of the real-time capable application in the AllowedApplicationConnections capability.
  • The real-time capable application must list the component ID of the high-level application in the AllowedApplicationConnections capability.
"AllowedApplicationConnections": [ "005180BC-402F-4CB3-A662-72937DBCDE47" ]

Partner applications

When you load an application onto the Azure Sphere device, the Azure Sphere deployment tools by default delete all existing applications. To prevent this from happening when you develop a pair of applications that communicate with each other, you need to mark the applications as partners. When you deploy one of the applications, its partner will not be deleted. See Mark applications as partners for details.

Open the socket

Before you communicate with an RTApp, you must open a socket by calling the Application_Connect function. The file descriptor returned by this function call is used to perform send/recv operations on the socket.

Send data

You can send a message to an RTApp by calling the POSIX send() function. The maximum message size is 1 KB.

Receive data

You can receive a message from an RTApp by calling the POSIX recv() function.

Close the socket

To close the socket, call the POSIX close() function.