Компьютерные сети. Лабораторные работы
29ec6025

Пример программы "Slave"


#include <stdio.h>

#include <stdlib.h>

#include <conio.h>

#include <dos.h>

main() {

union REGS rr;

int dataport,statusport,ctrlport; /* Номера портов */

unsigned char stat; /* Байт статуса */

int i, count=0, c, c1, res;

/* Определение адресов портов принтера */

dataport=peek(0x40,8);

statusport=dataport+1;

ctrlport=statusport+1;

clrscr();

printf(" Порты LPT1\n");



printf(" Базовый адрес %03X\n",dataport);

printf(" Адрес порта состояния %03X\n",statusport);

printf(" Адрес порта управления %03X\n",ctrlport);

outportb(dataport,0);

stat=inportb(statusport);

printf(" Состояние принтера - ");

for (i=7; i>=0; i--)

if ((stat>>i)&1) printf("1"); else printf("0");

while (!kbhit()) {

printf("\nEtap 1\n");

count=0;

while(count==0) {

stat = inportb(statusport);

if((stat&128)==0) {

count=1;

c=(stat>>3)&15;

outportb(dataport,16); }

}

printf("Etap 2\n");

count=0;

while(count==0) {

stat = inportb(statusport);

if((stat&128)!=0) {

stat=inportb(statusport);

c1=(stat<<1)&240;

count=1;

outportb(dataport,0); }

}

res=c|c1;

printf("%d\n",res);

count=0;

while(count==0) {

stat = inportb(statusport);

if((stat&128)==0) {

count=1;

outport(dataport,0); }

}}

return 0;

}

ОглавлениеВперед

КаталогИндекс раздела



Содержание раздела