OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 5:46 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Problem with keyboard input routine
PostPosted: Sun Jul 17, 2005 4:40 pm 
Heres the code for it:

Code:
unsigned char kin(){
    unsigned char buf;
    rkey = 0;
    buf = "";
    while(rkey == 0){
        if(curkey > 0){
     buf = kbdus[curkey];
     puts("");
   }
    }
    return buf;
}


As you can see it should return the last charecter the user inputs.

buf is the buffer the charecter is stored in, kbdus is a list of charecter values, curkey is the current scancode value and rkey is 1 if the return key is pressed. But it just seems to return nothing, and I don't know why? Any ideas? its probably a really stupid mistake....

cheers

Jonny


Top
  
 
 Post subject: Re:Problem with keyboard input routine
PostPosted: Sun Jul 17, 2005 5:41 pm 
Why are you doing puts() and writing a NULL string? You can set "buf" to 0 rather than "" (although they should be the same thing).

What is "rkey"? If "rkey" is changed before "curkey" then it will return while "buf" is still NULL. If you are changing both values in the ISR then you have probably created a race condition where EIP is just after the If, "rkey" is changed then the ISR returns, the while checks "rkey" and leaves without the If executing.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 156 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