K8055 doesn't work correctly whereas the program has been already tested

Hello,

I recently bought a Velleman PVM110N. By having to my IUT exactly the same, so I took the dll, the header and the library that goes with it.

I want to program in C.
Good.
I set code compiler options for Blocks, and Linkers.
The program is already done and already checked, it works. The problem is that he says that access to the card is impossible …

Knowing that in my IDE everything is good, and that my program too, that the riders are well set to choose the address of the card, I do not understand … for me it’s a DLL pb but I have put with the same file, in Windows, in System 32 and in Code Blocks even to be on, and its access to the IDE designates one of them …

Please help me debug the situation …

Thank you very much in advance!

PS: Here is the program in C:

// TEST PROGRAM FOR USB CARD K8055 (flashing output 1)

#include <stdio.h>
#include <windows.h>
#include <conio.h>
#include <K8055D_C.h>

int main ()
{
long test;
test = OpenDevice (3);
if (test! = 3)
{
puts (“opening USB card impossible!”);
return 0;

}

printf (“USB card% d open \ n”, test);

do
{
SetDigitalChannel (2);

Sleep (500);
ClearDigitalChannel (2);

Sleep (500);
}
while (kbhit () == 0);

CloseDevice ();
printf (“USB card% ld closed \ n”, test);
return;
}

I just want to add that…I’ve got 2 computers, the first is on Win8 and the second on Win7. On the first, with my program, it is written that it’s not possible to open the USB; With the Win7 computer, it’s written that it’s open but the program doesn’t work whereas it worked at my school…

I already asked this problem on this website : https://www.abcelectronique.com/forum/showthread.php?t=96279

Thanks a lot for your help, it’s for sunday…

And sorry for the mistakes, I normaly speak french.

Great Regards,

Manu

Please see this thread: K8055 programming
There is about similar problem and solution.

Thanks for your answer.

Nevertheless, I’m programming with C language, not C++. And my IDE is CodeBlocks.
Thus, solutions doesn’t work…

HELP PLZ…

Thanks

Here is the modified code in C.
This works:

#include <stdio.h>
#include <windows.h>
#include <conio.h>

typedef void(CALLBACK* t_func)(int );
typedef void(CALLBACK* t_func0)();
typedef int(CALLBACK* t_func4)(int );

t_func4 OpenDevice;
t_func0 CloseDevice;
t_func SetDigitalChannel;
t_func ClearDigitalChannel;


HINSTANCE hDLL;
int foundDLL = 0;
int init();

int main()
{
    int h;

    h = init();
	if (!h)
	{
		puts ("DLL found");
		foundDLL = 1;
	}
	else
	{
		puts ("DLL not found");
	}
	if (foundDLL)
	{
		long test;
        test = OpenDevice (3);
        if (test != 3)
        {
        puts ("opening USB card impossible!");
        return 0;

        }

        printf ("USB card% d open \n", test);

        do
        {
        SetDigitalChannel (2);

        Sleep (500);
        ClearDigitalChannel (2);

        Sleep (500);
        }
        while (kbhit () == 0);

        CloseDevice ();
        printf ("USB card% ld closed \n", test);

        FreeLibrary(hDLL);
    }
    return 0;
}

int init()
{
	hDLL = LoadLibrary("k8055d");
	if (hDLL != NULL)
	{
		OpenDevice = (t_func4) GetProcAddress(hDLL, "OpenDevice");
		if (!OpenDevice)
		{						// handle the error
			FreeLibrary(hDLL);
			return -2;
		}
		CloseDevice = (t_func0) GetProcAddress(hDLL, "CloseDevice");
		if (!CloseDevice)
		{						// handle the error
			FreeLibrary(hDLL);
			return -2;
		}
		ClearDigitalChannel = (t_func) GetProcAddress(hDLL, "ClearDigitalChannel");
		if (!ClearDigitalChannel)
		{						// handle the error
			FreeLibrary(hDLL);
			return -2;
		}
		SetDigitalChannel = (t_func) GetProcAddress(hDLL, "SetDigitalChannel");
		if (!SetDigitalChannel)
		{						// handle the error
			FreeLibrary(hDLL);
			return -2;
		}
		return 0;				// OK
	}
	return -1;					// error to load DLL
}

Please use the latest K8055D.DLL version 5.0. It is compatible with VM110N / K8055N and older VM110 /
K8055 cards.
Please put the DLL in your CodeBlocks project folder (same folder where the main.c exists).
Or copy the DLL to the \Windows\System32 folder.
In 64-bit Windows copy the DLL to \Windows\SysWOW64 folder.

The DLL version 5.0 is in this package: https://www.velleman.eu/downloads/files/downloads/k8055n_vm110n_rev1206.zip