I am working with the K8055 board (XP SP2 / Borland c++ 5.0.2).
I wrote a simple C routine to convert a number into a voltage as an output using OutputAnalogChannel().
Everything works fine but I needed to put in comments the declaration FUNCTION bool __stdcall ReadDigitalChannel(long Channel) in K8055D.h. If I don’t do that, I have a syntax error when I compile the program.
int main()
{
int h,i,a;
a = 1;
do
{
h = OpenDevice(0);
printf(“h = %d\n”,h);
printf("Input an integer: ");
fscanf(stdin, “%d”, &i);
OutputAnalogChannel(2,i);
} while (a == 1);
ClearAnalogChannel(1);
CloseDevice();
return 0;
}[/code]
Does anybody have an idea why I have this mistake ? Did I forget something ?
For the moment I don’t need the function ReadDigitalChannel() then everything is fine. But perhaps I will have tu use it.
Thank you in advance.
LePapat.
In french now
Bonjour,
je realise une routine simple en C (win xp sp2 / borland c++ 5.0.2) pour communiquer avec la K8055. Vous trouverez le code ci dessus. Pour que le programme fonctionne, je suis oblige de mettre en commentaires la ligne FUNCTION bool __stdcall ReadDigitalChannel(long Channel) dans le fichier K8055D.h. Sinon j’ai une ‘syntax error.’
je ne sais pas pourquoi. Si vous avez des ides je suis preneur. merci d’avance.
LePapat.
I modified the type bool by long in the original librairy but your solution is better
Even with yours, I have some warnings about some functions
‘Call to function ClearAllAnalog with no prototype’
‘Call to function CloseDevice with no prototype’
It works but it is weird that I have this kind of warnings.
Something is wrong, please double-check that the K8055D.h is added to your project and is being used
This message means that the compiler has noticed you trying to call a function which the compiler has no (or only minimal) information about (didn’t see your .h file). Under most compilers, this is a warning message, not an error, because the compiler is willing to assume certain things about unknown functions, and will let you try to call them. However, the assumptions it makes might not be right, and the compiler won’t be able to check that you’ve called the function with the correct number and type of arguments, which is why it issues the warning.
I included the librairy in my C file and linked the K8055d.lib to my project (using in Borland C++ the function AddNode. I did it for several projects in the past and everything was fine.
It is very surprising because I am using most of the functions provided by the Velleman librairy and have this warning only for a few functions.
In the examples provided by the cd, I noticed that the #pragma directive is used but I don’t use it in my program. I don’t know if it can play a rule ?
I don’t have an explanation, maybe we’re missing something obvious… Do you use those two functions anywhere else? Somewhere where the .h file is not included…
The pragma is probably used to import the .lib file. You can do this with your project settings too.