LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Windows Keyboard Entry


@Sable  a écrit :

I successfully opened the CVI project file in CVI 2013 and recompiled the DLL.


Great, that was a very important milestone!

 


@Sable  a écrit :

 

Could you please clarify the section highlighted in blue?

 

For debugging and tracing purposes, I am using OutputDebugStringA(), and the output can be captured using DebugView from Sysinternals.


Yes, sure. This is a very simple way to debug your library. DebugView is very small but useful utility that lets you monitor debug output. This tool will capture output of the OutputDebugStringA Function. (A at the end means Ascii ver).

 

For example, if I have the code like this:

 

 

int Your_Functions_Here (int x)
{
	char buf[256];
	sprintf(buf, "Debug Info: x = %d", x);
	OutputDebugStringA(buf);
	x = x * x;
	return x;
}

//==============================================================================
// DLL main entry-point functions
int __stdcall DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
	switch (fdwReason) {
		case DLL_PROCESS_ATTACH:
			OutputDebugStringA("Attached to Process"); break;
		case DLL_PROCESS_DETACH:
			OutputDebugStringA("Detached from Process"); break;
		case DLL_THREAD_ATTACH:
			OutputDebugStringA("Attached to Thread"); break;
		case DLL_THREAD_DETACH:
			OutputDebugStringA("Detached from Thread"); break;
	}

	return 1;
}

 

 

Then output shown in DebugView will be:

Screenshot 2024-10-18 07.25.11.png

And you will be not blind at least. DebugView will capture all outputs from all windows processes, but you can apply filter if this annoying.

 

By the way, you can call this function directly from LabVIEW, sometimes its also useful (don't forget to switch to WinAPI calling convention):

 

Screenshot 2024-10-18 07.27.12.png

 

and output will be here:

Screenshot 2024-10-18 07.28.12.png

 

But the "classical" debug technique also will work with CVI and LabVIEW, then in CVI you will set breakpoint:

 

Screenshot 2024-10-18 07.30.23.png

 

Then build Debug verision instead of release, then you can start LabVIEW and attach to that process from CVI:

 

Screenshot 2024-10-18 07.32.55.png

 

and when you will call it from LabVIEW, the CVI will be stopped on the breakpoint:

Screenshot 2024-10-18 07.35.21.png

 

So, you can debug you DLL (don't forget to build release after that).

 

And just one more thing — in LabVIEW you have "embedded" debug console, you can call DbgPrintf() from LabVIEW.exe, like OutputDebugString from kernel, then output will appear in small window:

Screenshot 2024-10-18 07.40.15.png

and this can be called from your DLL same way, of course:

 

 

int Your_Functions_Here (int x)
{
	DbgPrintf("Debug Info: x = %d", x);
	x = x * x;
	return x;
}

 

I hope this info above will be helpful for you.

0 Kudos
Message 21 of 21
(118 Views)