Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to set LVRT module path #331

Merged
merged 7 commits into from
Jan 10, 2024
Merged
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
Binary file not shown.
1 change: 1 addition & 0 deletions labview source/gRPC lv Support/grpc-lvsupport.lvlib
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
<Item Name="Shared" Type="Folder">
<Item Name="grpcId.ctl" Type="VI" URL="../Shared/grpcId.ctl"/>
<Item Name="Any.ctl" Type="VI" URL="../Shared/Any.ctl"/>
<Item Name="Set LVRT Module Path.vi" Type="VI" URL="../Shared/Set LVRT Module Path.vi"/>
<Item Name="Wait On Occurence.vi" Type="VI" URL="../Shared/Wait On Occurence.vi"/>
<Item Name="TranslateGrpcError.vi" Type="VI" URL="../Shared/TranslateGrpcError.vi"/>
</Item>
Expand Down
16 changes: 16 additions & 0 deletions src/grpc_interop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,19 @@ LIBRARY_EXPORT int32_t IsCancelled(grpc_labview::gRPCid** id)
}
return data->_call->IsCancelled();
}

//---------------------------------------------------------------------
// Allows for definition of the LVRT DLL path to be used for callback functions
// This function should be called prior to any other gRPC functions in this library
//---------------------------------------------------------------------
LIBRARY_EXPORT int32_t SetLVRTModulePath(const char* modulePath)
{
if (modulePath == nullptr)
{
return -1;
}

grpc_labview::SetLVRTModulePath(modulePath);

return 0;
}
39 changes: 30 additions & 9 deletions src/lv_interop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,21 @@ static PostLVUserEvent_T PostLVUserEvent = nullptr;
static Occur_T Occur = nullptr;
static RTSetCleanupProc_T RTSetCleanupProc = nullptr;

static std::string ModulePath = "";

namespace grpc_labview
{
grpc_labview::PointerManager<grpc_labview::gRPCid> gPointerManager;

//---------------------------------------------------------------------
// Allows for definition of the LVRT DLL path to be used for callback functions
// This function should be called prior to calling InitCallbacks()
//---------------------------------------------------------------------
void SetLVRTModulePath(std::string modulePath)
{
ModulePath = modulePath;
}

#ifdef _WIN32

//---------------------------------------------------------------------
Expand All @@ -45,15 +56,25 @@ namespace grpc_labview
return;
}

auto lvModule = GetModuleHandle("LabVIEW.exe");
if (lvModule == nullptr)
{
lvModule = GetModuleHandle("lvffrt.dll");
}
if (lvModule == nullptr)
{
lvModule = GetModuleHandle("lvrt.dll");
}
HMODULE lvModule;

if(ModulePath != "")
{
lvModule = GetModuleHandle(ModulePath.c_str());
}
else
{
lvModule = GetModuleHandle("LabVIEW.exe");
if (lvModule == nullptr)
{
lvModule = GetModuleHandle("lvffrt.dll");
}
if (lvModule == nullptr)
{
lvModule = GetModuleHandle("lvrt.dll");
}
}

NumericArrayResizeImp = (NumericArrayResize_T)GetProcAddress(lvModule, "NumericArrayResize");
PostLVUserEvent = (PostLVUserEvent_T)GetProcAddress(lvModule, "PostLVUserEvent");
Occur = (Occur_T)GetProcAddress(lvModule, "Occur");
Expand Down
3 changes: 2 additions & 1 deletion src/lv_interop.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ namespace grpc_labview

//---------------------------------------------------------------------
//---------------------------------------------------------------------
void InitCallbacks();
void SetLVRTModulePath(std::string modulePath);
void InitCallbacks();
void SetLVString(LStrHandle* lvString, std::string str);
std::string GetLVString(LStrHandle lvString);
int NumericArrayResize(int32_t typeCode, int32_t numDims, void* handle, size_t size);
Expand Down
Loading