Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ jobs:

- name: Upload Windows Server Information Artifact
uses: actions/upload-artifact@v2
if: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/releases')) && (runner.os == 'Windows') }}
if: ${{ (runner.os == 'Windows') }}
with:
name: ni-grpc-device-server-windows-x64
path: |
Expand All @@ -165,7 +165,7 @@ jobs:

- name: Upload Windows Server Binaries Artifact
uses: actions/upload-artifact@v2
if: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/releases')) && (runner.os == 'Windows') }}
if: ${{ (runner.os == 'Windows') }}
with:
name: ni-grpc-device-server-windows-x64
path: |
Expand All @@ -175,7 +175,7 @@ jobs:

- name: Upload Windows Test Binaries Artifact
uses: actions/upload-artifact@v2
if: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/releases')) && (runner.os == 'Windows') }}
if: ${{ (runner.os == 'Windows') }}
with:
name: ni-grpc-device-tests-windows-x64
path: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create_client_artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:

- name: Upload Windows Client Files Artifact
uses: actions/upload-artifact@v2
if: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/releases')) && (runner.os == 'Windows') }}
if: ${{ (runner.os == 'Windows') }}
with:
name: ni-grpc-device-client
path: |
Expand Down
15 changes: 8 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ set(metadata_dir ${CMAKE_SOURCE_DIR}/source/codegen/metadata)
set(service_output_dir ${CMAKE_SOURCE_DIR}/generated)
set(codegen_dir ${CMAKE_SOURCE_DIR}/source/codegen)
set(custom_dir ${CMAKE_SOURCE_DIR}/source/custom)
set(nidrivers "nidaqmx" "nidcpower" "nidigitalpattern" "nidmm" "nifake" "nifake_extension" "nifake_non_ivi" "nifgen" "nirfmxbluetooth" "nirfmxinstr" "nirfmxlte" "nirfmxnr" "nirfmxspecan" "nirfmxwlan" "nirfsa" "nirfsg" "niscope" "niswitch" "nisync" "nitclk" "nixnet" "nixnetsocket")
set(nidrivers "iotrace" "nidaqmx" "nidcpower" "nidigitalpattern" "nidmm" "nifake" "nifake_extension" "nifake_non_ivi" "nifgen" "nirfmxbluetooth" "nirfmxinstr" "nirfmxlte" "nirfmxnr" "nirfmxspecan" "nirfmxwlan" "nirfsa" "nirfsg" "niscope" "niswitch" "nisync" "nitclk" "nixnet" "nixnetsocket")

#----------------------------------------------------------------------
# Create NI Driver APIs proto and server files
Expand Down Expand Up @@ -307,9 +307,9 @@ target_link_libraries(ni_grpc_device_server
set_target_properties(ni_grpc_device_server PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)

if(WIN32)
target_link_libraries(ni_grpc_device_server Delayimp nidaqmx nidcpower niDigital nidmm niFgen niScope niRFmxBT niRFmxInstr niRFmxLTE niRFmxNR niRFmxSpecAn niRFmxWLAN niRFSA niRFSG niswitch nisync niTClk nixnet nixntipstack)
set_target_properties(ni_grpc_device_server PROPERTIES LINK_FLAGS "/DELAYLOAD:nicaiu.dll /DELAYLOAD:nidcpower.dll /DELAYLOAD:niDigital_64.dll /DELAYLOAD:nidmm_64.dll /DELAYLOAD:niFgen_64.dll /DELAYLOAD:niRFmxBT.dll /DELAYLOAD:niRFmxInstr.dll /DELAYLOAD:niRFmxLTE.dll /DELAYLOAD:niRFmxNR.dll /DELAYLOAD:niRFmxSpecAn.dll /DELAYLOAD:niRFmxWLAN.dll /DELAYLOAD:niRFSA_64.dll /DELAYLOAD:niRFSG_64.dll /DELAYLOAD:niScope.dll /DELAYLOAD:niswitch.dll /DELAYLOAD:nisync.dll /DELAYLOAD:niTClk_64.dll /DELAYLOAD:nixnet.dll /DELAYLOAD:nixntipstack.dll")
set(ni_grpc_device_server CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:nicaiu.dll /DELAYLOAD:nidcpower.dll /DELAYLOAD:niDigital_64.dll /DELAYLOAD:nidmm_64.dll /DELAYLOAD:niFgen_64.dll /DELAYLOAD:niScope.dll /DELAYLOAD:niRFmxBT.dll /DELAYLOAD:niRFmxInstr.dll /DELAYLOAD:niRFmxLTE.dll /DELAYLOAD:niRFmxNR.dll /DELAYLOAD:niRFmxSpecAn.dll /DELAYLOAD:niRFmxWLAN.dll /DELAYLOAD:niRFSA_64.dll /DELAYLOAD:niRFSG_64.dll /DELAYLOAD:niswitch.dll /DELAYLOAD:nisync.dll /DELAYLOAD:niTClk_64.dll /DELAYLOAD:nixnet.dll /DELAYLOAD:nixntipstack.dll")
target_link_libraries(ni_grpc_device_server Delayimp nidaqmx nidcpower niDigital nidmm niFgen NiSpyLog niScope niRFmxBT niRFmxInstr niRFmxLTE niRFmxNR niRFmxSpecAn niRFmxWLAN niRFSA niRFSG niswitch nisync niTClk nixnet nixntipstack)
set_target_properties(ni_grpc_device_server PROPERTIES LINK_FLAGS "/DELAYLOAD:nicaiu.dll /DELAYLOAD:nidcpower.dll /DELAYLOAD:niDigital_64.dll /DELAYLOAD:nidmm_64.dll /DELAYLOAD:niFgen_64.dll /DELAYLOAD:NiSpyLog.dll /DELAYLOAD:niRFmxBT.dll /DELAYLOAD:niRFmxInstr.dll /DELAYLOAD:niRFmxLTE.dll /DELAYLOAD:niRFmxNR.dll /DELAYLOAD:niRFmxSpecAn.dll /DELAYLOAD:niRFmxWLAN.dll /DELAYLOAD:niRFSA_64.dll /DELAYLOAD:niRFSG_64.dll /DELAYLOAD:niScope.dll /DELAYLOAD:niswitch.dll /DELAYLOAD:nisync.dll /DELAYLOAD:niTClk_64.dll /DELAYLOAD:nixnet.dll /DELAYLOAD:nixntipstack.dll")
set(ni_grpc_device_server CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:nicaiu.dll /DELAYLOAD:nidcpower.dll /DELAYLOAD:niDigital_64.dll /DELAYLOAD:nidmm_64.dll /DELAYLOAD:niFgen_64.dll /DELAYLOAD:NiSpyLog.dll /DELAYLOAD:niScope.dll /DELAYLOAD:niRFmxBT.dll /DELAYLOAD:niRFmxInstr.dll /DELAYLOAD:niRFmxLTE.dll /DELAYLOAD:niRFmxNR.dll /DELAYLOAD:niRFmxSpecAn.dll /DELAYLOAD:niRFmxWLAN.dll /DELAYLOAD:niRFSA_64.dll /DELAYLOAD:niRFSG_64.dll /DELAYLOAD:niswitch.dll /DELAYLOAD:nisync.dll /DELAYLOAD:niTClk_64.dll /DELAYLOAD:nixnet.dll /DELAYLOAD:nixntipstack.dll")
endif()

#----------------------------------------------------------------------
Expand Down Expand Up @@ -460,6 +460,7 @@ set(system_test_runner_sources
"source/tests/system/nidmm_session_tests.cpp"
"source/tests/system/nifgen_driver_api_tests.cpp"
"source/tests/system/nifgen_session_tests.cpp"
"source/tests/system/io_trace_api_tests.cpp"
"source/tests/system/nirfsa_driver_api_tests.cpp"
"source/tests/system/nirfsg_driver_api_tests.cpp"
"source/tests/system/nirfsg_session_tests.cpp"
Expand Down Expand Up @@ -520,9 +521,9 @@ add_custom_command(
$<TARGET_FILE_DIR:SystemTestsRunner>/)

if(WIN32)
target_link_libraries(SystemTestsRunner Delayimp nidaqmx nidcpower niDigital nidmm niFgen niRFmxBT niRFmxInstr niRFmxLTE niRFmxNR niRFmxSpecAn niRFmxWLAN niRFSA niRFSG niScope niswitch nisync niTClk nixnet nixntipstack)
set_target_properties(SystemTestsRunner PROPERTIES LINK_FLAGS "/DELAYLOAD:nicaiu.dll /DELAYLOAD:nidcpower.dll /DELAYLOAD:niDigital_64.dll /DELAYLOAD:nidmm_64.dll /DELAYLOAD:niFgen_64.dll /DELAYLOAD:niRFmxBT.dll /DELAYLOAD:niRFmxInstr.dll /DELAYLOAD:niRFmxLTE.dll /DELAYLOAD:niRFmxNR.dll /DELAYLOAD:niRFmxSpecAn.dll /DELAYLOAD:niRFmxWLAN.dll /DELAYLOAD:niRFSA_64.dll /DELAYLOAD:niRFSG_64.dll /DELAYLOAD:niScope.dll /DELAYLOAD:niswitch.dll /DELAYLOAD:nisync.dll /DELAYLOAD:niTClk_64.dll /DELAYLOAD:nixnet.dll /DELAYLOAD:nixntipstack.dll")
set(SystemTestsRunner CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:nicaiu.dll /DELAYLOAD:nidcpower.dll /DELAYLOAD:niDigital_64.dll /DELAYLOAD:nidmm_64.dll /DELAYLOAD:niFgen_64.dll /DELAYLOAD:niRFmxBT.dll /DELAYLOAD:niRFmxInstr.dll /DELAYLOAD:niRFmxLTE.dll /DELAYLOAD:niRFmxNR.dll /DELAYLOAD:niRFmxSpecAn.dll /DELAYLOAD:niRFmxWLAN.dll /DELAYLOAD:niRFSA_64.dll /DELAYLOAD:niRFSG_64.dll /DELAYLOAD:niScope.dll /DELAYLOAD:niswitch.dll /DELAYLOAD:nisync.dll /DELAYLOAD:niTClk_64.dll /DELAYLOAD:nixnet.dll /DELAYLOAD:nixntipstack.dll")
target_link_libraries(SystemTestsRunner Delayimp nidaqmx nidcpower niDigital nidmm niFgen NiSpyLog niRFmxBT niRFmxInstr niRFmxLTE niRFmxNR niRFmxSpecAn niRFmxWLAN niRFSA niRFSG niScope niswitch nisync niTClk nixnet nixntipstack)
set_target_properties(SystemTestsRunner PROPERTIES LINK_FLAGS "/DELAYLOAD:nicaiu.dll /DELAYLOAD:nidcpower.dll /DELAYLOAD:niDigital_64.dll /DELAYLOAD:nidmm_64.dll /DELAYLOAD:niFgen_64.dll /DELAYLOAD:NiSpyLog.dll /DELAYLOAD:niRFmxBT.dll /DELAYLOAD:niRFmxInstr.dll /DELAYLOAD:niRFmxLTE.dll /DELAYLOAD:niRFmxNR.dll /DELAYLOAD:niRFmxSpecAn.dll /DELAYLOAD:niRFmxWLAN.dll /DELAYLOAD:niRFSA_64.dll /DELAYLOAD:niRFSG_64.dll /DELAYLOAD:niScope.dll /DELAYLOAD:niswitch.dll /DELAYLOAD:nisync.dll /DELAYLOAD:niTClk_64.dll /DELAYLOAD:nixnet.dll /DELAYLOAD:nixntipstack.dll")
set(SystemTestsRunner CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:nicaiu.dll /DELAYLOAD:nidcpower.dll /DELAYLOAD:niDigital_64.dll /DELAYLOAD:nidmm_64.dll /DELAYLOAD:niFgen_64.dll /DELAYLOAD:NiSpyLog.dll /DELAYLOAD:niRFmxBT.dll /DELAYLOAD:niRFmxInstr.dll /DELAYLOAD:niRFmxLTE.dll /DELAYLOAD:niRFmxNR.dll /DELAYLOAD:niRFmxSpecAn.dll /DELAYLOAD:niRFmxWLAN.dll /DELAYLOAD:niRFSA_64.dll /DELAYLOAD:niRFSG_64.dll /DELAYLOAD:niScope.dll /DELAYLOAD:niswitch.dll /DELAYLOAD:nisync.dll /DELAYLOAD:niTClk_64.dll /DELAYLOAD:nixnet.dll /DELAYLOAD:nixntipstack.dll")
endif()

# Hook up different google test runners to CTest
Expand Down
111 changes: 76 additions & 35 deletions examples/niscope/graph-measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import matplotlib.pyplot as plt
import niscope_pb2 as niscope_types
import niscope_pb2_grpc as grpc_scope
import iotrace_pb2 as iotrace_types
import iotrace_pb2_grpc as grpc_iotrace

SERVER_ADDRESS = "localhost"
SERVER_PORT = "31763"
Expand Down Expand Up @@ -67,13 +69,50 @@ def check_for_error(vi, status):
raise Exception(error_message_response.error_message)


def simple_check_for_error(status, message):
"""Raise an exception if the status indicates an error."""
if status < 0:
raise Exception(f"Status check failed {status}: {message}")


def start_tracing():
"""Launch IO Trace and start tracing"""
print("Start tracing...")
open_response = iotrace_client.OpenIOTrace(iotrace_types.OpenIOTraceRequest())
simple_check_for_error(open_response.status, "Launching IO Trace failed.")
time.sleep(4)
start_tracing_response = iotrace_client.StartTracing(
iotrace_types.StartTracingRequest(
log_file_setting=iotrace_types.LogFileSetting.LOG_FILE_SETTING_Spy,
file_path_string="C:\\dev\\traces\\graph-measurement.nitrace",
file_write_mode=iotrace_types.FileWriteMode.FILE_WRITE_MODE_CreateOrOverwrite,
)
)
simple_check_for_error(start_tracing_response.status, "Start tracing failed.")


def stop_tracing():
"""Stop tracing and close IO Trace"""
input("\nHit enter to stop tracing and close IO Trace...\n")
stop_tracing_response = iotrace_client.StopTracing(iotrace_types.StopTracingRequest())
simple_check_for_error(stop_tracing_response.status, "Stop tracing failed.")
time.sleep(0.5)
close_io_trace_response = iotrace_client.CloseIOTrace(iotrace_types.CloseIOTraceRequest())
simple_check_for_error(close_io_trace_response.status, "Close IO Trace failed.")


# Create the communication channel for the remote host (in this case we are connecting to a local
# server) and create a connection to the NI-SCOPE service
channel = grpc.insecure_channel(f"{SERVER_ADDRESS}:{SERVER_PORT}")
niscope_client = grpc_scope.NiScopeStub(channel)
iotrace_client = grpc_iotrace.IOTraceStub(channel)

try:
# Initialize the scope
start_tracing()

input("\nHit enter to start measurement.\n")

init_result = niscope_client.InitWithOptions(
niscope_types.InitWithOptionsRequest(
session_name="demo", resource_name=RESOURCE, id_query=False, option_string=OPTIONS
Expand Down Expand Up @@ -143,46 +182,47 @@ def check_for_error(vi, status):

# Setup a plot to draw the captured waveform
fig = plt.gcf()
plot_open = True
fig.show()

def on_close(event):
global plot_open
plot_open = False

fig.canvas.mpl_connect("close_event", on_close)
fig.canvas.draw()

print("\nReading values in loop. CTRL+C to stop.\n")
try:
while True:
# Clear the plot and setup the axis
plt.clf()
plt.axis([0, 100, -6, 6])
# Read a waveform from the scope
read_result = niscope_client.Read(
niscope_types.ReadRequest(
vi=vi, channel_list=CHANNELS, timeout=1, num_samples=10000
)
)
check_for_error(vi, read_result.status)
values = read_result.waveform[0:10]
print(values)

# Update the plot with the new waveform
plt.plot(read_result.waveform[0:100])
fig.canvas.draw()
plt.pause(0.001)

# Fetch the measured average frequency
fetch_result = niscope_client.FetchMeasurementStats(
niscope_types.FetchMeasurementStatsRequest(
vi=vi,
channel_list=CHANNELS,
timeout=1,
scalar_meas_function=niscope_types.ScalarMeasurement.SCALAR_MEASUREMENT_NISCOPE_VAL_AVERAGE_FREQUENCY,
)
while plot_open:
# Clear the plot and setup the axis
plt.clf()
plt.axis([0, 100, -6, 6])
# Read a waveform from the scope
read_result = niscope_client.Read(
niscope_types.ReadRequest(vi=vi, channel_list=CHANNELS, timeout=1, num_samples=10000)
)
check_for_error(vi, read_result.status)
values = read_result.waveform[0:10]
print(values)

# Update the plot with the new waveform
plt.plot(read_result.waveform[0:100], color="green")
fig.canvas.draw()
plt.pause(0.001)

# Fetch the measured average frequency
fetch_result = niscope_client.FetchMeasurementStats(
niscope_types.FetchMeasurementStatsRequest(
vi=vi,
channel_list=CHANNELS,
timeout=1,
scalar_meas_function=niscope_types.ScalarMeasurement.SCALAR_MEASUREMENT_NISCOPE_VAL_AVERAGE_FREQUENCY,
)
check_for_error(vi, fetch_result.status)
print("Average Frequency: " + str("%.2f" % round(fetch_result.result[0], 2)) + " Hz")
print("")
)
check_for_error(vi, fetch_result.status)
print("Average Frequency: " + str("%.2f" % round(fetch_result.result[0], 2)) + " Hz")
print("")

time.sleep(0.1)
except KeyboardInterrupt:
pass
time.sleep(0.1)

except grpc.RpcError as rpc_error:
error_message = rpc_error.details()
Expand All @@ -198,3 +238,4 @@ def check_for_error(vi, status):
if "vi" in vars() and vi.id != 0:
# close the session.
check_for_error(vi, (niscope_client.Close(niscope_types.CloseRequest(vi=vi))).status)
stop_tracing()
96 changes: 96 additions & 0 deletions generated/iotrace/iotrace.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@

//---------------------------------------------------------------------
// This file is automatically generated. All manual edits will be lost.
//---------------------------------------------------------------------
// Proto file for the IO-TRACE Metadata
//---------------------------------------------------------------------
syntax = "proto3";

option java_multiple_files = true;
option java_package = "com.ni.grpc.iotrace";
option java_outer_classname = "IOTrace";
option csharp_namespace = "NationalInstruments.Grpc.IOTrace";

package iotrace_grpc;

import "session.proto";

service IOTrace {
rpc CloseIOTrace(CloseIOTraceRequest) returns (CloseIOTraceResponse);
rpc LogMessage(LogMessageRequest) returns (LogMessageResponse);
rpc OpenIOTrace(OpenIOTraceRequest) returns (OpenIOTraceResponse);
rpc StartTracing(StartTracingRequest) returns (StartTracingResponse);
rpc StopTracing(StopTracingRequest) returns (StopTracingResponse);
}

enum IOTraceAttribute {
IOTRACE_ATTRIBUTE_UNSPECIFIED = 0;
}

enum FileWriteMode {
FILE_WRITE_MODE_CreateOnly = 0;
FILE_WRITE_MODE_CreateOrAppend = 1;
FILE_WRITE_MODE_CreateOrOverwrite = 2;
}

enum LogFileSetting {
LOG_FILE_SETTING_Spy = 0;
LOG_FILE_SETTING_NoFile = -1;
LOG_FILE_SETTING_PlainText = 1;
LOG_FILE_SETTING_CommaSeparated = 2;
LOG_FILE_SETTING_SettingXml = 3;
}

enum CommandStatus {
COMMAND_STATUS_Success = 0;
COMMAND_STATUS_NoExecute = -303200;
COMMAND_STATUS_IncompatibleState = -303201;
COMMAND_STATUS_UnableToOpenLogFile = -303202;
COMMAND_STATUS_IOTraceClosed = -303203;
COMMAND_STATUS_InvalidSettings = -303204;
COMMAND_STATUS_BadParameter = -303205;
COMMAND_STATUS_InternalFailure = -303206;
COMMAND_STATUS_InvalidFileExtension = -303207;
COMMAND_STATUS_BufferTooSmall = -303208;
COMMAND_STATUS_FileAlreadyExists = -303209;
}

message CloseIOTraceRequest {
}

message CloseIOTraceResponse {
int32 status = 1;
}

message LogMessageRequest {
string message = 1;
}

message LogMessageResponse {
int32 status = 1;
}

message OpenIOTraceRequest {
}

message OpenIOTraceResponse {
int32 status = 1;
}

message StartTracingRequest {
LogFileSetting log_file_setting = 1;
string file_path_string = 2;
FileWriteMode file_write_mode = 3;
}

message StartTracingResponse {
int32 status = 1;
}

message StopTracingRequest {
}

message StopTracingResponse {
int32 status = 1;
}

Loading