int chatting() { char msg[80],msg_in[80]; int status,out,in,count=0,count_in=0,i,extra; bioscom(0, SETTINGS, COM1); //init. port //alternative to outportb(),perticularly for rs 232 communication. window(3,23,80,23); //message entry window while (1) { status = bioscom(3, 0, COM1); if (status & DATA_READY) { if ((out = bioscom(2, 0, COM1) & 0x7F) != 0)// input message byte. msg_in[count_in++]=out; if(out==13) { dsply(msg_in,10); count_in=0; gotoxy(count+1,1); } } if (kbhit()) //character entered { gotoxy(count+1,1); if ((in = getche()) == 27) break; if(in==0) { in= getch(); //special function key pressed, ignore continue; } if(in==8 && count>0) { count-=2;cprintf(" \b");} //BackSpace else msg[count]=in; if(count==70) {in=13; msg[70]=13;} count++; if(in==13 ) //Enter: Send { i=0; dsply(msg,14); for(i=0;i<count;i++) { bioscom(1, msg[i], COM1); } clrscr(); count=0; } } } return 1; }
int serialPutAttributes (SerialDevice *serial, const SerialAttributes *attributes) { { if (attributes->speed.biosBPS <= 7) { if (bioscom(0, attributes->bios.byte, serial->package.deviceIndex) & 0X0700) { logMessage(LOG_ERR, "bioscom failed"); return 0; } } else { int interruptsWereEnabled = disable(); SerialBiosConfiguration lcr = attributes->bios; lcr.fields.bps = 0; serialWritePort(serial, UART_PORT_LCR, lcr.byte | UART_FLAG_LCR_DLAB); serialWritePort(serial, UART_PORT_DLL, attributes->speed.divisor & 0XFF); serialWritePort(serial, UART_PORT_DLH, attributes->speed.divisor >> 8); serialWritePort(serial, UART_PORT_LCR, lcr.byte); if (interruptsWereEnabled) enable(); } } return 1; }
unsigned _RTL_FUNC _bios_serialcom(unsigned __cmd, unsigned __port, unsigned __abyte) { return bioscom(__cmd, __abyte, __port) ; }