All pastes #368583 Raw Edit

Stuff

public c v1 · immutable
#368583 ·published 2007-02-23 05:08 UTC
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 <unistd.h>#include <stdlib.h>#include <hal.h>struct data {        hal_bit_t *b;} *data;int comp_id;int main(void) {        int result;        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_IN, &data->b, comp_id);        if(result < 0) exit(1);        hal_ready(comp_id);        while(1) {                usleep(10000);                //*data->b = !*data->b;                printf("value: %d\n",*data->b);        }        hal_exit(comp_id);}