#include <sys/io.h>
#include <stdio.h>
#include <assert.h>

#define WAIT	usleep(100)
#define MCR	0x3fc
#define MSR	0x3fe
#define ACTIVATE_RTS	0x2
#define ACTIVATE_DTR	0x1
#define DEACTIVATE_RTS	0x0

int main ( void ) {

    int b;
    iopl(3);
    
    while(1) {
	// aktywuje RTS w Modem Control Register
	outb(ACTIVATE_RTS, MCR);
	
	//odczyt DSR z Modem Status Register
	b = inb(MSR);
	printf("%d\n", b);
	fflush(stdout);
	WAIT;
    }
    
    // Jakby cos.. to deaktywacja RTS w Modem Control Register:
    // outb(DEACTIVATE_RTS, MCR);
    
    return 0;
}
