-
Posts
353 -
Joined
-
Last visited
-
Days Won
35
Content Type
Profiles
Forums
Downloads
Gallery
Everything posted by dadreamer
-
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
These modifications were made as well? extern "C" __declspec(dllexport) BOOL __cdecl InstallStandardCallback(LONG lRealHandle, LVUserEventRef * refnum) { HMODULE hDLL = LoadLibraryW(L"HCNetSDK.dll"); if (hDLL) { Type_SetStandardDataCallBack installFunc = (Type_SetStandardDataCallBack)GetProcAddress(hDLL, "NET_DVR_SetStandardDataCallBack"); if (installFunc) { if (refnum && *refnum) return installFunc(lRealHandle, DataCallBack, (DWORD)(*refnum)); else return installFunc(lRealHandle, NULL, 0)); } FreeLibrary(hDLL); } return FALSE; } -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
You still did not apply UninstallCallback to your VI. This may help or may not. I can't say now, what's the reason behind your problem. When you will be ready to test with UninstallCallback, restart LabVIEW completely to begin with fresh resources. And as you already are getting stream's binary data, save a single NET_DVR_SYSHEAD (1) packet and a single NET_DVR_STREAMDATA (2) packet to two separate binary files, so we could get a chance to look at the format. Use a Case Structure to differentiate them. Save one packet only, if possible, not two going one after the other. Post them afterwards. -
Download link for OpenG library compatible with LabVIEW 7.1
dadreamer replied to KumarB's topic in OpenG General Discussions
I assume you may easily find all these packages on SourceForge, e.g. this is a page for oglib_error-2.0-1: https://sourceforge.net/projects/opengtoolkit/files/lib_error/2.0/ -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
-
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
@alvise I also recommend putting a CLFN with SetCbState call and wire a False constant to it after the While loop, so it would deny posting anyways. -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
Could it be that the callback doesn't get installed? Did you try to uninstall it after the loop ends? -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
If I got it right, he says that on one run of the VI the events are being sent OK, but on another run (after he stops the VI and runs it again) no events is sent regardless of the button being pressed. -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
Is your cluster elements order correct? Open Context Help window, then select Wiring Tool and hover it over the pink wire. In the Context Help you'll see order of the cluster elements. -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
@alvise Do you really need audio in your streams? Because if no, then it would be a way easier to work with pure NET_DVR_STD_VIDEODATA (4) packets. -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
Yes. Make handle as U8 array instead of a numeric. -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
Now correct the cluster contents as proposed and test again. -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
This explains why he was seeing unstable behaviour from run to run. This is what happens, when two advisers are trying to help simultaneously. 😃 I often prefer a slightly different way to transfer data from the callback. I post a pointer to data and in LabVIEW I read it out with MoveBlock (because I like to see a minimalistic external code and do most of the coding in LV instead). By the way, I kind of think posting an U32/U64 number might work, if DSDisposeHandle would be moved to the LV Event frame from the callback code and in that frame MoveBlock + DSDisposeHandle would be called. -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
Because you exported it. Leave it as is. Take a boolean button with Switch when released mechanical action and create a new event frame "Value Change" with that button inside. Put a CLFN with SetCbState call, add one parameter in its settings with Adapt to Type -> Handles by Values data type and format. Wire your button to the CLFN. Now you're controlling the callback event flow. -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
Rolf nailed it already 🙂 So do as written above. -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
Why did you leave eventData declaration and NumericArrayResize call outside the condition? Unnecessary work for the callback to do, if the flag is False. There's also a mistake in your code. Compare with this: -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
Yes, something like this: extern "C" __declspec(dllexport) void __cdecl SetCbState(LVBoolean *state); // ... LVBoolean cbState = LVBooleanFalse; // ... extern "C" __declspec(dllexport) void __cdecl SetCbState(LVBoolean *state) { cbState = *state; } // ... extern "C" __declspec(dllexport) void __stdcall DataCallBack(LONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD dwBufSize, DWORD dwUser) { if (cbState==LVBooleanTrue){ // callback code } } -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
I see two main issues here. Too many events coming - your program just can't handle them all at once (you were already warned about that). How can you deal with it? You decide. I often use a boolean variable switch for that. You may consider something else. You want to have UninstallStandardCallback function to stop posting into LV, when the loop finishes or no matter what. Now your DLL seems to be trying to post even when the main VI finishes plus the event queue is full with unprocessed events. Try to implement that function on your own, it's not that complex. -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
Maybe because on each event a new handle is allocated? Now you're gonna have some fun with MoveBlock thingy 😉 Does your loop manage to process events in time? -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
Don't pass Event Registration Refnum to the DLL! Pass Event Refnum. Also you need to pass this wire through all the frames of the structure, because when the loop will be stopped, Destroy User Event VI will be confused getting invalid refnum. Or wire it around the loop instead. Oh, first do unregister, second do destroy, in that order. Moreover your calling convention is wrong! Plus you didn't insert an User Event frame where you're going to catch your events. ! Reg Events, Unregister and Destroy should be either outside the loop completely or inside the "Start" (for Reg Events) and "Stop" (for Unregister and Destroy) frames ! Otherwise the UE will be created and freed on each iteration. -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
You better rework Rolf's example a bit to not reinvent the wheel. 1. Remove this as no longer needed. 2. Remove this Case Structure and that VI Ref terminal. Pass NULL (0) as hPlayWnd. 3. Before the While loop create User Event of cluster type, containing these three fields: typedef struct { LONG realHandle; DWORD dataType; LVByteArrayHdl handle; } LVEventData; You should set handle type as U32, if you're working in 32-bit LabVIEW only, or U64 in all other cases. 4. In "Start" frame of the Event Structure right after Start.vi put CLFN with InstallStandardCallback function call, set it properly and pass two parameters to it - lSession from Start.vi and your fresh UE reference. 5. Activate Dynamic Events terminals on your Event Structure and set it to accept your User Event. Also here register for events and pass the event refnum to the right terminal. 6. In "Stop" frame of the Event Structure unregister for events. 7. After the loop destroy the UE. Now after running your program and pressing "Connect" + "Start" buttons you should receive some events (if no mistakes made). Check Event Inspector window to make sure. -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
You may trash down Release folder and rebuild the project in Release config. Or leave it as is. But when you will distribute your app onto another machines without Visual Studio installed, your library will ask for the debug version of MSVC Runtime. -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
There is! Alter the function declarations and add these prototypes. extern "C" __declspec(dllexport) void __stdcall DataCallBack(LONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD dwBufSize, DWORD dwUser); extern "C" __declspec(dllexport) BOOL __cdecl InstallStandardCallback(LONG lRealHandle, LVUserEventRef *refnum); -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
I don't see the functions prototypes declared anywhere in the source. Maybe this is the reason. Try to add them right after the last #include directive. Callback(void) DataCallBack(LONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD dwBufSize, DWORD dwUser); And LibAPI(BOOL) InstallStandardCallback(LONG lRealHandle, LVUserEventRef *refnum); -
Using the DLL files of an application compiled with C# with labview
dadreamer replied to alvise's topic in LabVIEW General
Yes. Your code does already have all that necessary stuff for export: #define LibAPI(retval) __declspec(dllexport) EXTERNC retval __cdecl #define Callback(retval) __declspec(dllexport) EXTERNC retval __stdcall // ... Callback(void) DataCallBack(LONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD dwBufSize, DWORD dwUser) { // ... } LibAPI(BOOL) InstallStandardCallback(LONG lRealHandle, LVUserEventRef *refnum) { // ... } Hence it's rather odd that nothing is exported. As you're using __declspec(dllexport), no need to use .def file - you may disable it in the settings. Maybe your functions are exported, but have decorated names... In this case LabVIEW won't show them. Could you check full export table with some tool like Dependency Walker or similar?