How to use gRPC with NI Software and Hardware

Updated Jul 27, 2023

Environment

Operating System

  • Windows
  • Linux
  • LabVIEW Real-Time (NI Linux Real-Time)

Programming Language

  • LabVIEW G
  • Python
  • C# .NET

Other

  • gRPC

This article aims to explain how gRPC is used by NI, what is gRPC, how it fits in the NI ecosystem, what are the current possibilities and options and where to find support.

What is gRPC?


"gRPC is a modern open source high performance Remote Procedure Call (RPC) framework that can run in any environment. It can efficiently connect services in and across data centers with pluggable support for load balancing, tracing, health checking and authentication. It is also applicable in last mile of distributed computing to connect devices, mobile applications and browsers to backend services."

grpc.png
1. Why gRPC
 
In gRPC, a client application can directly call a method on a server application on a different machine as if it were a local object, making it easier for you to create distributed applications and services. As in many RPC systems, gRPC is based around the idea of defining a service, specifying the methods that can be called remotely with their parameters and return types. On the server side, the server implements this interface and runs a gRPC server to handle client calls. On the client side, the client has a stub (referred to as just a client in some languages) that provides the same methods as the server.

service.png
2. gRPC Overview

For further information and a more complete deep dive please proceed to the official website of gRPC Link.
 

How gRPC fits in the NI ecosystem?


gRPC can be used to control remote systems which do not need constant physical presence. Using a gRPC based server gives the possibility to access and control test and measurement from many different programming environments, platforms and operating systems. 

niservice.png
3. gRPC with NI system
 
As NI grow into a "software-connected" company, we are leveraging the best tools and methodologies for data sharing and process control to keep up with our customers requests and needs. By using gRPC as the NI's Remote-Ability tool gives the benefit to:
  • Remotely control NI Hardware and Software.
  • Minimize time to first measurement.
  • Leverage existing workflows.
  • Avoid driver installation on client system.
 
 

The current possibilities and options


Currently there are multiple ways to use gRPC with NI instrumentation based on the type of hardware and software use:
  1. Custom - NI Hardware with custom 3rd party programming languages 
  2. NI gRPC Device Server and Client API
  3. gRPC with LabVIEW
 
 

Custom - NI Hardware with custom 3rd party programming languages


If you are planning to use a programming language which is officially compatible with gRPC like Python, C#(.NET), etc. Then you can build your Server with the help of the NI Python or NET drivers:

grpccustom.png
4. gRPC Custom Solution

You can create and implement gRPC Server and instrument control from one environment. The only limitation is that not every NI driver has a direct Python or .NET support.
 
ServerClient
Created and maintained by the customer, also the programming languages are picked by the customer.Created and maintained by the customer, also the programming languages are picked by the customer.
  * Important note: gRPC is not supported by NI technical support, related questions or support are only available through github forums.

NI gRPC Device Server and Client API


grpcdevice.png
5. NI gRPC Device

NI gRPC Device Server and Client APIs

"The server and the client APIs allow NI's instrumentation to be accessed and controlled through a remote interface via pre-defined APIs using a client/server architecture. The API is not a driver but instead a layer on top of the existing driver C APIs that provides remote capabilities. It provides software capability that allows NI’s instrumentation to be accessed and controlled through a remote interface via pre-defined APIs on multiple platforms using a client/server architecture. It contains both the NI Device gRPC Server and .proto files that can be used to generate the interfaces necessary for a client to interact with the server and supported devices connected to the server."

This solution is NI R&D created and supported through Github forums, gRPC is not supported by NI technical support.
 
ServerClient
Created and maintained by the customer, also the programming languages are picked by the customer.Created and maintained by the customer, also the programming languages are picked by the customer.
* Important note: gRPC is not supported by NI technical support, related questions or support are only available through github forums.
 

gRPC with LabVIEW


gRPC Support for LabVIEW

This repo contains necessary C++ code and support VIs to implement a gRPC server and client in LabVIEW. You can either use the service as defined to implement a generic server via gPRC or use the implementation as a pattern to implement a gRPC service of your design. It supports Windows, Linux, and Linux RT targets.

grpclabview.png
6. gRPC in LabVIEW
 
This tool gives you the possibility to create your gRPC API like the tools of Python and other supported languages. The limitation is that it is a tool which is "as-it-is" it is created by NI but no direct support is provided.
 
ServerClient
Created and maintained by the customer in LabVIEW.Created and maintained by the customer in LabVIEW.

* Important note: gRPC API related questions and support is only available through github forums.