Pomogite s LPT portom
Esli kto znaet kak iz LPT porta so vtoroj nogi citat dannie, napisite. Nuzna programma dlia draivera i prikladnaja programma. Citat zelatelno s pomosiu inb() funkcii. Dopustim dlia vihoda dannih na LPt 2 nogu v draivere nado pisat: ssize_t lab3_write(struct file *filp, const char *buf, size_t count, loff_t *f_pos) { ssize_t retval = 0; unsigned char out = 0x00; retval = copy_from_user(&out, buf, 1); if(retval < 0) return retval; outb(out, dev->base); wmb(); return count; } a v prikladnoj proge:
int main() { int fd; if((fd = open("/dev/lab3", O_WRONLY)) < 0) { printf("error \n"); return -1; } int j = 0, i = 0; unsigned char out = 0x00; for(i = 1; i < 500; i++) { if (j == 0) { j = 1; out = 0x01; } else { j = 0; out = 0x00; } if((write(fd, &out, sizeof(unsigned char))) < 0) { printf("Error1 \n"); return -1; } usleep (20000); } close(fd); return (0); }
Tak vots vihodom vsio poniatno, a kak s cteniem? Kuda funkcija inb() zapisivaet rezultat, kak iznego vibrat dannie imenno 2 nogi LPT porta, i kak polucit dannie v prikladnoj programme? Esli kto znaet, ocen prosu otvetit, ocen nado! Spasibo!