TsctlDIOGetAsyncCExamples
From embeddedTS Manuals
int main(int argc,char *argv[]) {
System *sys;
DIO *dio;
int n;
DIOState state;
if (argc < 2) {
printf("usage: %s <dio#>\n",argv[0]);
return 1;
}
sys = SystemInit(0);
dio = DIOInit(0);
if (!dio) {
printf("Error instantiating DIO 0\n");
return 1;
}
// if argument isn't a number, do a lookup
n = atoi(argv[1]);
if (n == 0 && argv[1][0] != '0') {
// Note that we have to pass our C string to ASCIIZ
// to get the libtsctl array expected by MapLookup
// for a longer running program we would ArrayFree() it when done...
n = sys->MapLookup(sys,ASCIIZ(argv[1]));
if (n < 0) {
printf("DIO %s not found\n",argv[1]);
}
}
dio->Lock(dio,n,0);
state = dio->GetAsync(dio,n);
dio->Unlock(dio,n,0);
printf("DIO %s state is %s\n",argv[1],DIOValueString(state));
return 0;
}