Quantcast
Channel: LabWindows/CVI topics
Viewing all 5339 articles
Browse latest View live

GetTimerTickData() vs Timer() performance

$
0
0

Hello everyone, i'm doing some optimisation in my code and i saw that Timer() use a lot of resource in my profiler.

 

i have thried, where possible, to use GetTimerTickData() instead, and it's seem faster than Timer().

 

now i want to improve the performance in a multithread application and i use Timer() and SyncWait() to slow down the thread.

 

Is there a function similar to GetTimerTickData() that get the thread execution time and time elapsed from one call to other?

 

thank you in advice for your support


SelfCalibrateAllDevices.prj in examples does not compile in LabWindows 2017

$
0
0

SelfCalibrateAllDevices.prj in examples does not compile in LabWindows 2017; gives link errors.

Works just fine in LabWindows 2015

Can anybody comment?

Connect dual screens to NI PXIe-1085

$
0
0

Hi all

Is it possible to connect dual screens to NI PXIe-1085.The PXIe-1085 has one display port(DP).

 

Thanks

OpenComConfig returns an error even though Device manager lists the COM port

$
0
0

Hi,

 

I have  a weird problem.

I have many applications that use COM port. I use either FTDI Usb to Serial, or STM32 Virtual COM port. I have used both successfully for a long time, suddenly COM port derived from STM32 Virtual COM port is no longer recognized by CVI (but it does by device manager and terminal application such as docklight). 

I use code I got from this forum to populate a list of available COM ports (always worked perfectly until now), I will present the code below. The code no longer returns with the STM32 Virtual COM port number (It always did), so I tried to force the code to see the COM port exists (I force "com_port = 4" since it is COM4), and sometimes it works and most of the time OpenComConfig returns with -6 even though the COM port exists.

Any ideas?

 

Here is the code that lists the COM ports (it populates a menu ring):

 

if (number_of_found_ports)
{
  for(i = 0 ; i < number_of_found_ports ; i++)
  {
    sprintf(str , "COM %d", portlist[i]) ;
    InsertListItem(main_panel_handle , kPANEL_COM_RING , -1 , str , i) ;
  }

  GetLabelFromIndex(main_panel_handle, kPANEL_COM_RING, 0, selected_com_port);
  strcpy(selected_com_port, &selected_com_port[4]);
  com_port = atoi(selected_com_port);
  com_port_selected = 1;
}

Here is the COM port initialization, OpenComConfig returns with -6

 

 

OpenComConfig(com_port, "", COM_BAUDRATE, NO_PARITY, DATA_BITS_8, ONE_STOP_BIT, INPUT_QUEUE, NO_OUTPUT_QUEUE);
SetCTSMode(com_port, LWRS_HWHANDSHAKE_OFF);

This is the code I downloaded from this forum a while back to get a list of available COM ports:

static HDEVINFO  BeginEnumeratePorts(VOID)
{
	BOOL guidTest = FALSE;
	DWORD RequiredSize = 0;
	HDEVINFO DeviceInfoSet;
	char *buf;

	guidTest = SetupDiClassGuidsFromNameA("Ports", 0, 0, &RequiredSize);

	if(RequiredSize < 1)return INVALID_HANDLE_VALUE;

	buf = malloc(RequiredSize * sizeof(GUID));

	guidTest = SetupDiClassGuidsFromNameA("Ports", (GUID *)buf, RequiredSize * sizeof(GUID), &RequiredSize);

	if(!guidTest)return (HANDLE) - 1;


	DeviceInfoSet = SetupDiGetClassDevs((GUID *)buf, NULL, NULL, DIGCF_PRESENT);

	if(DeviceInfoSet == INVALID_HANDLE_VALUE)
		return INVALID_HANDLE_VALUE;

	free(buf);

	return DeviceInfoSet;
}


int LocateCom(char *inval, int *list, int maxnum)
{
	DWORD i;
	SP_DEVINFO_DATA DeviceInfoData = {0};
	int portsfound = 0;


	HDEVINFO hDevInfo = BeginEnumeratePorts();

	if (INVALID_HANDLE_VALUE == hDevInfo)
		return 0;


	// Enumerate through all devices in Set.

	DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);

	for (i = 0; SetupDiEnumDeviceInfo(hDevInfo, i, &DeviceInfoData); i++)
	{
		DWORD DataT;
		LPTSTR buffer = NULL;
		DWORD buffersize = 0;

		//
		// Call function with null to begin with,
		// then use the returned buffer size
		// to Alloc the buffer. Keep calling until
		// success or an unknown failure.
		//
		while (!SetupDiGetDeviceRegistryProperty(hDevInfo,
																						 &DeviceInfoData,
																						 SPDRP_FRIENDLYNAME,&DataT,
																						 (PBYTE)buffer,
																						 buffersize,&buffersize))
		{
			if (GetLastError() ==	ERROR_INSUFFICIENT_BUFFER)
			{
				// Change the buffer size.
				if (buffer)
					free(buffer);

				buffer = malloc(buffersize);
			}
			else
			{
				if (buffer)
					free(buffer);

				SetupDiDestroyDeviceInfoList(hDevInfo);
				return 0;
			}
		}

		if (NULL == buffer)
		{
			if (buffersize > 0)
			{
				buffer = malloc(buffersize);
				SetupDiGetDeviceRegistryProperty(hDevInfo,&DeviceInfoData,
																				 SPDRP_FRIENDLYNAME,&DataT,
																				 (PBYTE)buffer,
																				 buffersize,&buffersize);
			}
		}

		// We may have found the device
		if ((NULL != buffer) && strstr(buffer, inval))
		{
			char *xval;

			xval = strstr(buffer, "COM");

			if (xval != NULL)
			{
				int d;

				if ((1 == sscanf(xval, "COM%d", &d)) && (d >= 1) && (d <= 255))
				{
					if ((NULL == list) || (maxnum <= 0))
					{
						free(buffer);
						SetupDiDestroyDeviceInfoList(hDevInfo);
						return d;
					}
					else
					{
						if (portsfound < maxnum)
							list[portsfound++] = d;
					}
				}
			}
		}

		if (buffer) free(buffer);
	}

	SetupDiDestroyDeviceInfoList(hDevInfo);

	return portsfound;
}

Any help will be greatly appreciated

 

 

 

How can i use code created in labwindows in labview

$
0
0

Hello,

 

My question is: Could I use code that I develop in LabWindows in labview, in vi form or similar something.

 

I 'm absolutely new in labwindows.

 

Thanks

Can I ConvertLabWindows/CVI Program Into LabVIEW VIs?

DAQmxReadDigitalLines never finishes despite reading all required samples

$
0
0

I am using

DAQmxReadDigitalLines (taskHandle, -1, 2.0, DAQmx_Val_GroupByChannel, laneSamples, SAMPLES_TO_READ, &samplesRead, &bytesPerChannel, 0)

following a small delay, samplesRead is equal to  SAMPLES_TO_READ i.e. all expected samples have been captured.

However, when I call DAQmxStopTask(taskHandle), I get warning code 200010 Which means "Finite acquisition or generation has been stopped before the requested number of samples were acquired or generated".

So, I tried repeatedly calling DAQmxIsTaskDone(taskHandle, &taskDone);

but taskDone is never anything other than 0

 

Converting a LabView driver to a DLL then calling that DLL from CVI

$
0
0

Anyone out there have LabVIEW and would be willing to click a button to convert a vendor instrument drive to a CVI DLL for me?

 

I see that NI makes an exporter for just this task, but the requirements are that LabVIEW already be installed.  The setup.exe doesn't even load on my machine.

 

The vendor of my instrument makes LabVIEW drivers.


link errors

$
0
0

When trying to build my project, I get the following link errors:

error: Undefined symbol '_read_232@8' referenced in "*.obj"

error: Undefined symbol '_write_232@8' referenced in "*.obj"

 

How can I fix these errors please?

Get DB_VARWCHAR value from DB

$
0
0

Hi,

I'm trying to get a "DB_VARWCHAR" value type from a column of a table into a DB.

I have used the function "DBBindColChar" but without success: it replaces always the existing chars (unicode) with a '?' (the original string is "Принимаю" and the function get "????????").
More, I have tried to use the function "DBBindColBinary", but always it returns only the first 4 bytes (2 unicode char) of the original string.

The DB is SQL Server and the column is set to NVARCHAR type.
Suggestions?

Thanks a lot for your precious support!

Terminate a thread

$
0
0

Is there no way to terminate a thread from the main thread?

If main thread schedules a thread from pool, can the main thread take action to terminate the second thread?  The function CmtExitThreadPoolThread must be executed in the second thread as I understand it.

Undefined Symbol Error after changing an exported function name

$
0
0

Hi All,

I'm developing a dll for external application.

After changing some function's name, I received a linker error, "undefined symbol "_funcNewName" referenced in "pathToObjFile\*.obj" ".

I've rebuild the dll with new function name, copied the new *.lib and *.dll files into external application folder. 

Invoked the function using a new name, but still having that issue. 

Interesting detail to mention, when I roll back to original name - no linking errors.

Any Ideas? 

 

Thanks for the help Smiley Happy 

CVI is still unable to read/search files with lines longer than 102x characters

Unrecoverable Internal Error on launch

$
0
0

Hello all,

just trying to open an oldish (cvi2013) project with cvi2015 and it crashes without even showing the cvi window with: "unrecoverable internal error at 0023:10AFC318. LabWindows/CVI will be aborted"

I remember there was some utility you could run and configure to diagnose CVI crashes in a log file, but I cannot find it.

Also I checked the cws and prj file and I don't see any garbage or potential problems with them.

Display application in the front

$
0
0

I have a cvi2015-application A1. From this application I start another one (A2) with LaunchExecutable. 

A2 is displayed over A1. If I minimize A1, I only see A2. Now I stop A2 (QuitUserInterface()). Then I maximixe A1 again.

If I now start A2 it is allways displayed behind A1 - so I don't see it, as A1 is maximized.

This problem only occurs, if I have minimized A1, while A2 is running.


array initialize

$
0
0

Hi,

 

I am helping in troubleshoot a software issue (developed in LabWindows/CVI 2015), and one thing I have noticing and find weird is that the software code initializes the array by assigning an empty bracket or empty string.  For example

 

double Array[10] = {0};

char Buffer[1024] = "";

myMap NameMap = {0, "", "", ""}   //myStructure contains - int, char[1024], char [1024], char [1024]

 

I wonder would that method is truly initialize the array?  or if that could cause memory leak in the software as my assumption is that "" and {} are consider as a constant in the memory, and assigning array to that constant would forces the pointer to change.  And, as the constant does not have sufficient memory allocated, an update to the array would cause memory leak?!

 

Thanks.

 

Peggy

 

New Update Service available

$
0
0

For anyone interested, a new version (17.0) of the NI update service is available. For some reason the previous one does not inform about it.

(unfortunately the new one still does not support serial drivers)

Precedence of Callback Functions

cvi TestStand

$
0
0

i use cvi for execute a seqFile but after i exite the application i get a warning message : "References to PropertyObjects were not released properly, but a list is not available. "

i close the sequence before exite and i discard all the TSUIObj but the same warrning allways

documentation feedback gone

$
0
0

Hello NI,

I remember that once there was a dedicated online form for feedback on the help but it seems to be gone.

I am missing this feature because once in a while I stumble across some typos, missing information (e.g. missing default values) or the like and it seems sort of overkill to open a support request just for reporting such details - and also most of the times I am just too lazy for such an effort.

What should we do if we still care about documentation?

Viewing all 5339 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>