Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Cheking THRE to send a string via serial port

    I'm trying to send a string to a serial port using:
    #define UART    0x03f8
    #define UART_LSR_THRE 0x20
    void UART_send(unsigned char *data){
         int i = 0, k = strlen(data);
         printk("UART_send invoked, data is %s and k is %d\n", data, k);
         while(i < k){
           while( !(inb(UART + UART_LSR_THRE)) ){
           if(i < k){
                 outb(data[i++], (UART + UART_TX));
    When trying write ABCDEF, for example, sometimes it skips letters or prints them more than once.
    My guess is that I'm not verifying the status of the THRE correctly, seeing as it's not only the wrong result, the while() being there or not doesn't seem to be doing anything.
    Any ideas? Or isn't this even the place to ask questions like this?

  2. #2
    Hello and welcome!

    Quote Originally Posted by LastOrder View Post
    Or isn't this even the place to ask questions like this?
    Aye, this be the place. Hopefully someone will come along soon to be able to help you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts