#include #include #include #include //Note: the header files for input/output might be in a different directory //sys/io.h is where ubuntu puts them #include #define BASEPORT 0x03F8 //port address for COM 1 serial port double t0, t1; unsigned int ntot, tint[28000]; int i; unsigned char mem1, mem2, nmem1, nmem2; unsigned char tl,th,ntl,nth, test, test1, test2[1000]; FILE *out; char filename[20]; int main() { iopl(3); //gives permission for user to access the ports i=0; outb(0,BASEPORT+1); // Turn off interrupts outb(0x80,BASEPORT+3); // Set DLAB ON outb(0x02,BASEPORT); // Set Baud rate to be 57,600 outb(0x00,BASEPORT+1); // Set Baud rate - Divisor Latch High Byte outb(0x03,BASEPORT+3); // 8 bits, No Parity, 1 Stop Bit outb(0xC7,BASEPORT+2); // FIFO control Register outb(0x0B,BASEPORT+4); // Turn on DTR, RTS, and OUT2 i=0; while(i<24) { test=inb(BASEPORT+5); // test if there is data ready to read from the port if((test & 1)==1) // if BASEPORT+5 equals 1, data is ready to read { test2[i]=inb(BASEPORT); // get the byte of data printf("%u \n", test2[i]); i=i+1; } } exit(0); }