/* * Tony Givargis - All Rights Reserved 1998 */ /*--------------------------------------------------------------------------*/ #include #include #include #include "pcserial.h" /*--------------------------------------------------------------------------*/ int main() { char buf[5]; EL_SerialPort* port; clrscr(); port = EL_SerialPortCreate(COM1, NONE, 1200, 8, 1); if( port == NULL ) { gotoxy(1, 1), cprintf("Oops, looks like the serial port didn't initialize!\n"); return 0; } do { printf("type a number : "); buf[0] = getche(); printf("\n"); } while( buf[0] < '0' || buf[0] > '9' ); EL_SerialPortWrite(port, buf, 1); while( !kbhit() ) { if( EL_SerialPortQueueSize(port) > 0 ) { EL_SerialPortRead(port, buf, 1); printf("received char : %c\n", buf[0]); printf("received value : %d\n", (int)buf[0]); EL_SerialPortWrite(port, buf, 1); return 0; } } EL_SerialPortDestroy(port); return 0; }