Hi,
I have no idea what you are trying to write, but you are making things too difficult for yourself.
Save this simple example into a file called test.comp
component test "This is a test component";
pin in bit testinbit;
pin in s32 testins32;
pin out bit testoutbit;
pin out s32 testouts32;
param rw s32 testrwparam = 0;
// internal variables
variable bool testbool = false;
variable float testfloat = 0;
variable int progress_level = 0;
function _;
author "ArcEye ";
license "GPL";
;;
FUNCTION(_)
{
switch (progress_level)
{
case 0:
break;
default:
rtapi_print_msg(RTAPI_MSG_ERR, "Unknown state");
break;
}
}
Then run
comp test.comp and it will generate
test.c
Reading this will show you exactly what the comp program does to generate code to produce a module.
You can then build a module with
comp --install test.comp
From the commandline
$ # halrun
halcmd: loadrt test
halcmd: show pin
Component Pins:
Owner Type Dir Value Name
4 bit IN FALSE test.0.testinbit
4 s32 IN 0 test.0.testins32
4 bit OUT FALSE test.0.testoutbit
4 s32 OUT 0 test.0.testouts32
halcmd: unloadrt test
halcmd: exit
Which will demonstrate that the module loads and the pins were created.
Now just use this as a template and replace pins and variables with what you want and replace the code in FUNCTION() with something meaningful.
The code in FUNCTION() needs to do something and return quickly, no calls to sleep(), no while() loops etc.
Hence why a switch() statement, allowing you to do something, change the progress_level and next visit do the next stage and so on, is useful for a module which checks state of the pins and does stuff dependent upon that state.
Simple as that (in theory)
regards