From: "Michel Gallant" Newsgroups: comp.os.msdos.djgpp Subject: Re: Detecting interrupt on printer port Lines: 109 Message-ID: <_yLB1.90$Na1.583337@sapphire.mtt.net> Date: Mon, 17 Aug 1998 01:19:54 GMT NNTP-Posting-Host: 142.177.19.54 NNTP-Posting-Date: Sun, 16 Aug 1998 22:19:54 ADT Organization: MTT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Hi! I'm back, and with more problems than ever. Below is the progam I'm using.... Incorporating all the suggestions (I think) made to me thus far regarding this program. It still doesn't work. I used a logic probe, and verified that Interrupt Request Line 07 (Pin B21 on any ISA slot) is indeed triggering with the input in the -ACK line (pin #10 on the printer port). I'm absolutely sure of this correlation. The program refuses to increment its counter, though, spitting up a steady stream of zeros. If I change the inteerrupt to intecept from 15 (which corresponds to IRQ 15) to 8 (system timer) the program picks up on the interrupt and counts the timer tics perfectly. In fact, I ran an FC (file compare) on the two compiled .EXE files, and the only difference was the fact that in three places the 0x0f was replaced with an 0x08!- the number of the interrupts I'm intercepting. Here's the output from the fc program: Comparing files 60HZ003.EXE and timer003.exe 00000E36: 0F 08 00000E62: 0F 08 00000EB2: 0F 08 That's it! And here's my source code: //Interrupt Handler test for 0x0F, printer ACK //line interrupt, adapted from interrupt code by //Matthew Mastracci #include #include #include #include //macros by Shawn Hargreaves from the Allegro library for locking //functions and variables. #define END_OF_FUNCTION(x) void x##_end() { } #define LOCK_VARIABLE(x) _go32_dpmi_lock_data((void*)&x, sizeof(x)) #define LOCK_FUNCTION(x) _go32_dpmi_lock_code(x, (long)x##_end - (long)x) //timer interrupt F is generated when ACK goes LOW (I think) #define LPINT 15 //global counter volatile int counter = 0; //the new ISR, will be called automatically on low ACK once installed void TickHandler(void) { counter++; } END_OF_FUNCTION(TickHandler) int main(void) { //structures to hold selector:offset info for the ISRs _go32_dpmi_seginfo OldISR, NewISR; //set printer control register bit 4 //controls whether ACK generates interrupt outportb(890, inportb(890)|16); printf("About to set the vector to the new ISR..\n"); getkey(); //lock the functions and variables LOCK_FUNCTION(TickHandler); LOCK_VARIABLE(counter); //load the address of the old printer ISR into the OldISR structure _go32_dpmi_get_protected_mode_interrupt_vector(LPINT, &OldISR); //point NewISR to the proper selector:offset for handler function NewISR.pm_offset = (int)TickHandler; NewISR.pm_selector = _go32_my_cs(); //allocate wrapper _go32_dpmi_allocate_iret_wrapper(&NewISR); //set up new ISR to be called on low ACK _go32_dpmi_set_protected_mode_interrupt_vector(LPINT,&NewISR); //notice no changes to counter in this loop- the interrupt //changes it while (!kbhit()){ printf("%d\n",counter); outportb (888,255); } printf("Replacing the new ISR with the old one...\n"); //load the old timer ISR back _go32_dpmi_set_protected_mode_interrupt_vector(LPINT, &OldISR); //free wrapper _go32_dpmi_free_iret_wrapper(&NewISR); return 0; } Thanks for any help! Michel Gallant