rendered paste body//
// On my system, this program can be compiled into a userspace HAL component
// with the command:
// gcc test.c -DULAPI -I/usr/src/emc2/include -L/usr/src/emc2/lib -lemchal
//
//#include <types.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <hal.h>
#include <signal.h>
struct data {
hal_bit_t *b;
} *data;
int comp_id;
static void siginthand(int sig);
int main(void) {
int result;
signal(SIGINT,siginthand);
comp_id = hal_init("test");
if(comp_id < 0) exit(1);
data = hal_malloc(sizeof(struct data));
result = hal_pin_bit_new("test.bit",HAL_OUT,&data->b,comp_id);
if(result < 0) exit(1);
hal_ready(comp_id);
printf("Hello\nstarting...\n");
while(1) {
printf("Getting pin data\n");
*data->b = !*data->b;
system("echo -ne \"\\007\"");
printf("Sleeping for 5 sec...\n");
sleep(5);
//printf("Pin says: %d",*data->b);
//getch();
}
hal_exit(comp_id);
}
static void siginthand(int sig)
{
hal_exit(comp_id);
exit(0);
}