/* main function for the universal protocol demo program */ /* <%Z%%M% %Q% sccs %I%> */ /**************************************************************************** comdemo.c: Date Written: 11/3/95 Written by: John LaBatt Project: COMDEMO.MAK Purpose: This program will continually poll I/O from the simulator program using universal protocol messages. It also allows the user to change values of the outputs and will only write the change once. ****************************************************************************/ #include /* for call to _bios_keybrd() */ #include /* for call to close() */ #include "comdemo.h" #include "udrive.h" /* Include the universal driver functions */ #include "comm_int.h" char inchars[BSIZE],outchars[BSIZE]; /* IO buffers */ /* set up the com port */ comm_cb(com_port,1,0,0x00,0x00,0x00,inchars,outchars); /* This is the main function for the universal driver demo */ /* The demo assumes you are using Com Port 2 with the simulator */ /* program running on a PC connected directly to the comport. */ /* It also only uses BIN commands for the messages that are sent. */ void main() { UD_CONT ct; /* Control structure for the universal driver */ InitScreen(); /* Initialize the screen display */ /* Open the com port */ InitComm(2); /* 2 = com port #2 */ init_udr_ct(&ct); quit = FALSE; /* ALT-X will terminate the program */ editted = FALSE; /* Flag for whether data has been editted */ while(!quit) { /* Simply loop forever reading the values, and Updating the screen */ ReadVals(&ct); UpdateDiscreteWindow(DI_WINDOW,discrete_in); UpdateDiscreteWindow(DO_WINDOW,discrete_out); UpdateAnalogWindow(AI_WINDOW,analog_in); UpdateAnalogWindow(AO_WINDOW,analog_out); UpdateFloatWindow(FI_WINDOW,float_in); UpdateFloatWindow(FO_WINDOW,float_out); if(_bios_keybrd(_KEYBRD_READY)) ProcessKey(&ct); /* if a key was pressed, process it */ } close_comm(&com_port); /* close the com port */ RestoreScreen(); /* clear the screen and redisplay the cursor */ }