From 314eb0e0ec85f7cbd17bb93882d9e648c997f15e Mon Sep 17 00:00:00 2001 From: Rohan Doshi Date: Tue, 26 Nov 2024 14:49:27 +0530 Subject: [PATCH] return error status from Write* moniker functions --- generated/nidaqmx/nidaqmx_service.cpp | 36 ++++++++ generated/nifpga/nifpga_service.cpp | 88 +++++++++++++++++++ source/codegen/templates/service_helpers.mako | 5 ++ 3 files changed, 129 insertions(+) diff --git a/generated/nidaqmx/nidaqmx_service.cpp b/generated/nidaqmx/nidaqmx_service.cpp index 5c9eda6c6..fc96c1d36 100644 --- a/generated/nidaqmx/nidaqmx_service.cpp +++ b/generated/nidaqmx/nidaqmx_service.cpp @@ -862,6 +862,10 @@ ::grpc::Status MonikerWriteAnalogF64(void* data, google::protobuf::Arena& arena, auto status = library->WriteAnalogF64(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -881,6 +885,10 @@ ::grpc::Status MonikerWriteAnalogScalarF64(void* data, google::protobuf::Arena& auto status = library->WriteAnalogScalarF64(task, auto_start, timeout, value, reserved); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -918,6 +926,10 @@ ::grpc::Status MonikerWriteBinaryI16(void* data, google::protobuf::Arena& arena, auto status = library->WriteBinaryI16(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array.data(), &samps_per_chan_written, reserved); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -943,6 +955,10 @@ ::grpc::Status MonikerWriteBinaryI32(void* data, google::protobuf::Arena& arena, auto status = library->WriteBinaryI32(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -980,6 +996,10 @@ ::grpc::Status MonikerWriteBinaryU16(void* data, google::protobuf::Arena& arena, auto status = library->WriteBinaryU16(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array.data(), &samps_per_chan_written, reserved); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1005,6 +1025,10 @@ ::grpc::Status MonikerWriteBinaryU32(void* data, google::protobuf::Arena& arena, auto status = library->WriteBinaryU32(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1024,6 +1048,10 @@ ::grpc::Status MonikerWriteDigitalScalarU32(void* data, google::protobuf::Arena& auto status = library->WriteDigitalScalarU32(task, auto_start, timeout, value, reserved); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1061,6 +1089,10 @@ ::grpc::Status MonikerWriteDigitalU16(void* data, google::protobuf::Arena& arena auto status = library->WriteDigitalU16(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array.data(), &samps_per_chan_written, reserved); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1086,6 +1118,10 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena auto status = library->WriteDigitalU32(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } diff --git a/generated/nifpga/nifpga_service.cpp b/generated/nifpga/nifpga_service.cpp index d2bac0d0b..78671d3cc 100644 --- a/generated/nifpga/nifpga_service.cpp +++ b/generated/nifpga/nifpga_service.cpp @@ -1063,6 +1063,10 @@ ::grpc::Status MonikerWriteArrayBool(void* data, google::protobuf::Arena& arena, auto status = library->WriteArrayBool(session, control, array.data(), size); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1083,6 +1087,10 @@ ::grpc::Status MonikerWriteArrayDbl(void* data, google::protobuf::Arena& arena, auto status = library->WriteArrayDbl(session, control, array, size); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1115,6 +1123,10 @@ ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, auto status = library->WriteArrayI16(session, control, array.data(), size); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1135,6 +1147,10 @@ ::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, auto status = library->WriteArrayI32(session, control, array, size); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1155,6 +1171,10 @@ ::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, auto status = library->WriteArrayI64(session, control, array, size); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1187,6 +1207,10 @@ ::grpc::Status MonikerWriteArrayI8(void* data, google::protobuf::Arena& arena, g auto status = library->WriteArrayI8(session, control, array.data(), size); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1207,6 +1231,10 @@ ::grpc::Status MonikerWriteArraySgl(void* data, google::protobuf::Arena& arena, auto status = library->WriteArraySgl(session, control, array, size); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1239,6 +1267,10 @@ ::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, auto status = library->WriteArrayU16(session, control, array.data(), size); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1259,6 +1291,10 @@ ::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, auto status = library->WriteArrayU32(session, control, array, size); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1279,6 +1315,10 @@ ::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, auto status = library->WriteArrayU64(session, control, array, size); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1311,6 +1351,10 @@ ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, g auto status = library->WriteArrayU8(session, control, array.data(), size); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1328,6 +1372,10 @@ ::grpc::Status MonikerWriteBool(void* data, google::protobuf::Arena& arena, goog auto status = library->WriteBool(session, control, value); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1345,6 +1393,10 @@ ::grpc::Status MonikerWriteDbl(void* data, google::protobuf::Arena& arena, googl auto status = library->WriteDbl(session, control, value); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1366,6 +1418,10 @@ ::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, googl auto status = library->WriteI16(session, control, value); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1383,6 +1439,10 @@ ::grpc::Status MonikerWriteI32(void* data, google::protobuf::Arena& arena, googl auto status = library->WriteI32(session, control, value); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1400,6 +1460,10 @@ ::grpc::Status MonikerWriteI64(void* data, google::protobuf::Arena& arena, googl auto status = library->WriteI64(session, control, value); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1421,6 +1485,10 @@ ::grpc::Status MonikerWriteI8(void* data, google::protobuf::Arena& arena, google auto status = library->WriteI8(session, control, value); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1438,6 +1506,10 @@ ::grpc::Status MonikerWriteSgl(void* data, google::protobuf::Arena& arena, googl auto status = library->WriteSgl(session, control, value); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1459,6 +1531,10 @@ ::grpc::Status MonikerWriteU16(void* data, google::protobuf::Arena& arena, googl auto status = library->WriteU16(session, control, value); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1476,6 +1552,10 @@ ::grpc::Status MonikerWriteU32(void* data, google::protobuf::Arena& arena, googl auto status = library->WriteU32(session, control, value); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1493,6 +1573,10 @@ ::grpc::Status MonikerWriteU64(void* data, google::protobuf::Arena& arena, googl auto status = library->WriteU64(session, control, value); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } @@ -1514,6 +1598,10 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google auto status = library->WriteU8(session, control, value); + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } return ::grpc::Status::OK; } diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index ce9c77fdf..666f52e88 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -431,6 +431,11 @@ ${set_response_values(output_parameters=output_parameters, init_method=false)}\ ## But that needs `context` parameter which is not available in Moniker functions. return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } +% else: + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } % endif