Hey guys, I have the following function:
Code:
int BstCommand(int bat, int port, short line)
{
int card;
int status;
printf("OUT: %x\n",line);
//sets switch low
status = DIG_Out_Line(card, port, line, 0);
SleepEx(100, FALSE);
//sets switch high
status = DIG_Out_Line(card, port, line, 1);
return 0;
}
...
short DIG_Out_Line (short device,
short port,
short line,
short lineState)
{
int li=(int)line;
int d =(int)&device;
d=d %10;
GblDeviceLineState[d][li]=(long)lineState;
*GblDeviceData[d]=lineState;
return 0;
}
BstCommand is called everytime a switch is toggled. Dig_out_line sets the state of the switch as high or low. The problem is I don't exactly understand how sleepex here works. It prevents the switch to high line from running depending on I/O and APC calls. But right now the last line always runs, so I always get high for the switch.
I'm trying to emulate a virtual switch here using code that deals with real switches. I can only modify dig_out_line, but not Bstcommand. What can I do?