OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 3:06 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Keyboard Sends Extra Character
PostPosted: Wed Oct 03, 2018 5:01 pm 
Offline

Joined: Wed Aug 15, 2018 7:43 pm
Posts: 10
I have gotten interrupts working for a while now, but the keyboard sends an extra character when I press the keys e, q, t, u, w, and y. I can't seem to figure out what I should be doing/changing about how I receive the keys and or scan codes.
Ex: https://imgur.com/a/EUvl7St
Keyboard code (W.I.P.) https://pastebin.com/PDmcsMVj


Top
 Profile  
 
 Post subject: Re: Keyboard Sends Extra Character
PostPosted: Thu Oct 04, 2018 12:31 am 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
Might help to see all your code. Do you send an EOI, do you properly save and restore the required registers when your interrupts run. Do you have the exact same output every time you run it or does it differ each time? I also have a potential concern about this
Code:
cmdchar(kbdus[scancode]);
. It suggests you are doing command processing inside an interrupt handler. You shouldn't do that. You could create a keyboard buffer that you populate with keystrokes and your kernel could sit in a HLT loop waiting for interrupts and processing keystrokes from the buffer. This keeps the main command processing out of the interrupt handler itself.


Top
 Profile  
 
 Post subject: Re: Keyboard Sends Extra Character
PostPosted: Fri Oct 05, 2018 1:09 am 
Offline
Member
Member

Joined: Thu Jul 03, 2014 5:18 am
Posts: 84
Location: The Netherlands
The output on the screen looks fine to me. The error seems to be in the out.log file, which I assume you pipe your serial port into. Perhaps there is an issue in your serial output code, instead of your keyboard handling code.

_________________
My blog: http://www.rivencove.com/


Top
 Profile  
 
 Post subject: Re: Keyboard Sends Extra Character
PostPosted: Fri Oct 05, 2018 9:35 pm 
Offline

Joined: Wed Aug 15, 2018 7:43 pm
Posts: 10
After some "intense" rewriting and adding a keyboard buffer, I have found out that the character displayed are the keys being released. And I don't know how it is finding the character, because my keyboard array doesn't have the character. #-o ](*,)
New output:
https://imgur.com/a/HAiRu5H
New keyboard "driver":
https://pastebin.com/k4knjgAd
Is there anything else I am messing up?


Top
 Profile  
 
 Post subject: Re: Keyboard Sends Extra Character
PostPosted: Fri Oct 05, 2018 9:43 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
Maybe you mean to do:
Code:
void keyboard_handler(struct regs *r)
{
    unsigned char scancode;
    scancode = inb(0x60);
    key = kbdus[scancode];
    if (scancode & 0x80)
    {
    }
    else
    {
        kbuff[kbufn] = key;
        terminal_putchar(key);
        write_serial(key);
        write_serial(kbuff[kbufn]);
        kbufn++;       
    }
}


Top
 Profile  
 
 Post subject: Re: Keyboard Sends Extra Character
PostPosted: Fri Oct 05, 2018 9:45 pm 
Offline

Joined: Wed Aug 15, 2018 7:43 pm
Posts: 10
Thank You! I never really stopped to think about what the if statement was doing.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 64 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group