[pso] Primul interrupt de read are bufferul gol

Mihai Borobocea mihaiborobocea at gmail.com
Wed Apr 16 01:19:06 EEST 2008


Salut,

Uite aici o discutie asemanatoare din arhiva:
http://cs.pub.ro/pipermail/pso/2007-April/001405.html

Pune si un printk() cu valoarea citita in intrerupere si in read().
Asigura-te ca preiei valoarea din portul serial si nu altceva la prima
citire (de ex. vreo variabila locala, indexul in buffer etc.).

Foarte util pentru testarea pe Linux: creeaza-ti doua 'char device'-uri:
mknod pso1 c 42 0
mknod pso2 c 42 1

Insereaza driverul tau cu 'insmod'.
Apoi porneste un 'cat' pe unul din ele in background (sau intr-o
consola separata):
cat pso1 &
Si trimite niste date in celalalt:
echo "Hello" >pso2

Singurul neajuns: trebuie sa faci un snapshot inainte de 'cat' si sa
revii la el dupa fiecare rulare (nu stiu cum poti opri comanda 'cat'
cata vreme read-ul din driver face sleep pe un waitqueue; o
alternativa ar fi ca read() din driver sa intoarca '0' dupa un numar
de caractere citite).

--
Mihai

2008/4/15 Dorin Barcan <dbarcan at gmail.com>:
>
> Salut,
>   De cateva zile tot incerc sa dau de cap la o problema. La primul interrupt
> de read din buffer se citeste 0 si astfel apare un decalaj intre bufferul
> citit si cel scris. Cand primesc un interrupt verific si IIR(base + 2) si
> LSR(base+5). A mai patit cineva chestia asta sau are idee de la ce poate fi?
>
> mai jos este o bucata de syslog:
>
> mesajele au formatul:  crt_interrupt IRQ num_irq RECEIVED IIR_register
> LSR_register
>
>
> Apr 12 13:07:13 blackwing kernel:
> ---------------------------------------------------------------------------------------------------------------------
>  Apr 12 13:07:13 blackwing kernel:
> Apr 12 13:07:13 blackwing kernel: 1 IRQ 4 RECEIVED 193 96<6>
> Apr 12 13:07:13 blackwing kernel: 2 IRQ 4 RECEIVED 194 96<6>
> Apr 12 13:07:13 blackwing kernel: 3 IRQ 4 RECEIVED 194 96<6>
>  Apr 12 13:07:13 blackwing kernel: 1 IRQ 3 RECEIVED 193 96<6>
> Apr 12 13:07:13 blackwing kernel: 2 IRQ 3 RECEIVED 194 96<6>
> Apr 12 13:07:14 blackwing kernel: 3 IRQ 3 RECEIVED 194 96<6>
> Apr 12 13:07:14 blackwing kernel: 4 IRQ 4 RECEIVED 194 96<6>
>  Apr 12 13:07:14 blackwing kernel: 5 IRQ 4 RECEIVED 204 97<6>
> Apr 12 13:07:14 blackwing kernel: READ LOOPIIIIIING 204 97 4<6>  <-- IRQ 4
> intru in read IIR = 1100 1100 (FIFO TIMEOUT RDAI) LSR=0110 0001 (... DATA
> READY )
>  Apr 12 13:07:14 blackwing kernel: -r-|30|<6>
> <-- citesc 0!!!
> Apr 12 13:07:14 blackwing kernel: LEFT READLOOP 193 96 4<6>    <-- ies din
> read
> Apr 12 13:07:14 blackwing kernel: 4 IRQ 3 RECEIVED 204 97<6>
>  Apr 12 13:07:14 blackwing kernel: READ LOOPIIIIIING 204 97 3<6>   <-- IRQ 3
> intru in read cu acelasi IIR si LSR ca mai sus
> Apr 12 13:07:14 blackwing kernel: -r-|30|<6>
> <-- citesc 0!!!
>  Apr 12 13:07:14 blackwing kernel: READ LOOPIIIIIING 204 97 3<6>   <--
> acelasi IIR si LSR
> Apr 12 13:07:14 blackwing kernel: -r-|55|<6>
> <-- citesc prima valoare
> Apr 12 13:07:14 blackwing kernel: READ LOOPIIIIIING 196 97 3<6>
>  Apr 12 13:07:14 blackwing kernel: -r-|ffffffc0|<6>
> ......................................
> ......................................
>
> Mentionez ca am incercat sa dau enable la interupturi in diferite combinatii
> (IIR setat la 0x03, 0x07, 0xf) dar tot timpul citesc un 0 la inceput si
> momentan sunt "clueless".
>
> Barcan Dorin


More information about the pso mailing list