/* ! Copyright (C) Magna Carta Software, Inc. 1990. All Rights Reserved. CCT00.C -- First example telecommunications program. CAPABILITY: Dumb terminal program that polls COM1 or COM2 for data. All options must be set in the code and the source recompiled to change them. Good for 1200 bps on an AT class machine, 300 bps on a slower machine. COMPATIBILITY: TURBOC v1.5+, POWERC v1.2+, MSC 5.0+/QUICK C, WATCOM C; */ #include #include #include #include #include /* our communications routines */ #include /* MANIFEST CONSTANTS */ #define MENU ALT_M /* key for command summary */ /* FUNCTION PROTOTYPES */ void term(COMM_PORT *p); /* the main program loop */ short menu(void); /* the function that handles the menu */ /* GLOBAL VARIABLES */ COMM_PORT port0; /* the structure describing the port */ ACL acl0; /* the structure describing the ACL */ short vers = 0; /* the version number of "CCT-COMM" */ #include #include TERMINAL t; /* ------------------------ PROGRAM BEGINS HERE --------------------------- */ int main(void) { short ret; ret = acl_init(&acl0, 0X200, MK_FP(0XCC00, 0)); if (ret) { printf("ACL card initialization error %d", ret); exit(EOF); } else printf("ACL Board initialized OK\n"); ret = acl_init_channel(&port0, &acl0, 0, 38400L, 8, PARITY_NONE, 1); if (ret) { printf("ACL port initialization error %d", ret); exit(-2); } else printf("ACL Port initialized OK\n"); /* THE FOLLOWING 4 CALLS ARE NOT IN CCT00, BUT ILLUSTRATE FLOW CONTROL CONFIGURATION */ set_rx_xlat(&port0, LOCAL_ECHO, ON); set_tx_xlat(&port0, FLOWCTL, XONXOFF); set_rx_xlat(&port0, ACL_INPUT_BUFFER_HWM, 850); set_rx_xlat(&port0, ACL_INPUT_BUFFER_LWM, 100); /* init_term(&port0, &t, (void (*)()) ibmansi_init, bios_video); */ printf("CCT-ACL Version %d: Press Alt-M for a list of commands\n", vers); term(&port0); printf("\nEnd of CCT-COMM%d\n", vers); set_dtr(&port0, LOW); return (0); } /* TERM -- The terminal emulation routine. Simply polls the COM port and the keyboard alternately for characters. */ void term(COMM_PORT *p_port) { short c; /* must be int to detect a -1 return */ for (;;) { /* CHECK SERIAL PORT FOR BYTE */ c_getc(p_port); /* CHECK KEYBOARD FOR A KEY PRESS */ if ( (c = inkey()) != EOF) { if (c == MENU) { if (menu()) break; } else c_putc(p_port, c); } } } #define EXIT 'Q' /* key to exit from menu */ short menu(void) { int c, retval = 0; static char *menus[] = { "\tQ. EXIT from TERM.", NULL /* null string terminates list */ }; char **menup; c = !EXIT; while (c != EXIT && c != LF) { puts("\n\n"); for (menup = menus; *menup != NULL; menup++) printf("%s\n", *menup); printf("\n\t\t Enter selection (CR to quit menu) : "); c = getchar(); c = toupper(c); switch (c) { case EXIT: retval = 1; break; default: break; } } puts("\nExiting menu"); return (retval); /* will be zero except if EXIT */ }