/* Copyright (C) Magna Carta Software, Inc. 1990. All Rights Reserved RACAL01.C -- This is CCT03 with support for the Racal-Vadic Modem Command Set. CAPABILITY: Dumb terminal program. 1) Uses interrupt driven reception. 2) Data transfer rate can be adjusted at run time. 3) Data format can be adjusted at run time. NEW: New menu option allows configuration of Racal-Vadic modem. Note: To exit the RV menu, enter a command number > 55. */ #include #include #include #include #include /* MANIFEST CONSTANTS AND MACROS */ #define MENU ALT_M /* key for command summary */ /* FUNCTION PROTOTYPES */ void do_data_menu(COMM_PORT * p_port); short do_racal_menu(COMM_PORT *p); long do_speed_menu(COMM_PORT * p_port); short menu(COMM_PORT *p); void term(COMM_PORT *p); /* GLOBAL VARIABLES */ COMM_PORT port1; BYTE rxbuf[2048]; /* RECEIVE BUFFER */ int vers = 3; #include "menus.c" /* ------------------------ PROGRAM BEGINS HERE --------------------------- */ int main(void) { init_port(&port1, COM1, 2400L, DATABITS8, PARITY_NONE, STOPBITS1); install_ipr(&port1, RECEIVE, NULL, rxbuf, sizeof(rxbuf)); install_isr(&port1, 4, NULL); printf("CCT-COMM Version %d: Press Alt-M for a list of commands\n", vers); term(&port1); printf("\nEnd of CCT-COMM%d\n", vers); deinit_port(&port1); 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 */ if ( (c = c_inchar(p_port)) != EOF) putchar(c); /* CHECK KEYBOARD FOR A KEY PRESS */ if ( (c = inkey()) != EOF) { if (c == MENU) { if (menu(p_port)) break; } else c_putc(p_port, c); } } } #define DATA_FORMAT 'D' /* key to set speed */ #define DATA_SPEED 'S' /* key to set speed */ #define EXIT 'Q' /* key to exit from main */ #define RACAL_COMMANDS 'R' /* send commands to a RV modem */ short menu(COMM_PORT *p_port) { short c, retval = 0, DONE = FALSE; static char *menus[] = { "\tD. Data Format", "\tR. Racal-Vadic Commands.", "\tS. Data Transfer Rate.", "\tQ. EXIT from COMM.", NULL /* null string terminates list */ }; char **p_menu; c = !EXIT; while (!DONE) { puts("\n\n"); for (p_menu = menus; *p_menu != NULL; p_menu++) printf("%s\n", *p_menu); printf("\n\t\t Enter selection (CR to quit menu) : "); if ( (c = getch()) == CR) break; /* return to term */ c = toupper(c); switch (c) { case EXIT: retval = 1; DONE = TRUE; break; case DATA_FORMAT: do_data_menu(p_port); break; case DATA_SPEED: do_speed_menu(p_port); break; case RACAL_COMMANDS: do_racal_menu(p_port); break; default: puts("Invalid choice\n\007"); DONE = TRUE; break; } } puts("\nExiting menu"); return (retval); /* will be zero except if EXIT */ } short do_racal_menu(COMM_PORT *p) { WORD cmd, val; short ret, DONE = FALSE; do { puts("\nSEND COMMANDS TO THE RACAL-VADIC MODEM -- (> 55 to exit)"); printf("\nEnter Racal-Vadic command and new value: "); scanf("%d %d", &cmd, &val); if (cmd > 55) DONE = TRUE; else ret = racal_icmd(p, cmd, val); } while (!DONE); return (ret); }