Wierd result from K8062D.DLL

I have the following code running in a QT application (QLC) but I’m getting some strange results - it seems like my integer is being overwritten by a pointer. Also, if I make the variables volatile, my pointers get overwritten instead so I’m no better off. Any ideas?

I’ve tried using the original DLL supplied and also the DLL (and exe) I found on this forum dated 07/06/2010 11:16.

	int channelCount = universe.size();
	SetChannelCount(channelCount);

	unsigned char value = 0;
	int channelLoop = 0;
	while (channelLoop < channelCount)
	{
		qDebug("1. Channel: %d, %p, value: %d, %p, count: %d, %p", channelLoop, &channelLoop, value, &value, channelCount, &channelCount);
		value = uchar(universe[channelLoop]);
		qDebug("2. Channel: %d, %p, value: %d, %p, count: %d, %p", channelLoop, &channelLoop, value, &value, channelCount, &channelCount);
		SetData(channelLoop, value);
		qDebug("3. Channel: %d, %p, value: %d, %p, count: %d, %p", channelLoop, &channelLoop, value, &value, channelCount, &channelCount);
		channelLoop++;
		qDebug("4. Channel: %d, %p, value: %d, %p, count: %d, %p", channelLoop, &channelLoop, value, &value, channelCount, &channelCount);
	}

Results in the following debug being written…

warning: 1. Channel: 0, 0xd93fe8c, value: 0, 0xd93fe93, count: 512, 0xd93fe94
warning: 2. Channel: 0, 0xd93fe8c, value: 0, 0xd93fe93, count: 512, 0xd93fe94
warning: 3. Channel: 0, 0xd93fe8c, value: 0, 0xd93fe93, count: 512, 0xd93fe94
warning: 4. Channel: 227802773, 0xd93fe8c, value: 0, 0xd93fe93, count: 512, 0xd93fe94

227802773 = 0xd93fe95

Make sure you are using the correct data type for all function parameters, especially differences in 16-bit vs 32-bit vs 64-bit integers.

I have tried changing that but with no success (well actually, some success in that my loop variable changes to 513 instead of the pointer! Still not useful at all. I have however managed to make it work for now using the SetAllData function but I’d like to know why the other one didn’t work, just in case there’s some situation where SetAllData will do the same.

My entire function now looks like this…

void VellemanOut::outputDMX(quint32 output, const QByteArray& universe)
{
	if (output != 0)
		return;
	if (!currentlyOpen)
	{
		StartDevice();
		currentlyOpen = true;
	}

	int32_t channelCount = 0 + universe.size();
	SetChannelCount(channelCount);

	int32_t channelLoop = 0;
	//int32_t values [512]; //Set up array to pass to SetAllData.
	while (channelLoop < channelCount)
	{
		qDebug("1. Channel: %lu, %p, count: %lu, %p", (long unsigned int)channelLoop, &channelLoop, (long unsigned int)channelCount, &channelCount);
		int32_t value32 = (int32_t) universe[channelLoop];
		qDebug("2. Channel: %lu, %p, value: %lu, %p, count: %lu, %p", (long unsigned int)channelLoop, &channelLoop, (long unsigned int)value32, &value32, (long unsigned int)channelCount, &channelCount);
		//values[channelLoop] = (quint32) value; //Write the value to our temporary array.
		SetData(channelLoop, value32);
		qDebug("3. Channel: %lu, %p, value: %lu, %p, count: %lu, %p", (long unsigned int)channelLoop, &channelLoop, (long unsigned int)value32, &value32, (long unsigned int)channelCount, &channelCount);
		channelLoop++;
		qDebug("4. Channel: %lu, %p, value: %lu, %p, count: %lu, %p", (long unsigned int)channelLoop, &channelLoop, (long unsigned int)value32, &value32, (long unsigned int)channelCount, &channelCount);
	}
	//qDebug("About to write the universe!");
	//SetAllData(values); //Write the entire universe of values to the interface DLL.
	//qDebug("Written the universe!");

}

Are you using the updated DLL?
There were some strange problems with the older DLL version in C#.
See: viewtopic.php?f=3&t=4064

Here is the link to download the updated DLL: box.net/shared/2l0b2tk8e1