termios programming in linux
Dear All,
I trying to write a UART(interfacing of serial devices) to linux machine but after I execute the following code to receive data I need to enter key (carriage return).... but I don't want to remove carriage return/enter key please any one can help me.... Code:
#include <unistd.h> |
Please ask the moderators to move your post to the "Programming" sub-forum, and read the information linked to by the BB code link below the reply box so you can post your code inside a code block. That preserves the code formatting and makes it easier to read.
|
Quote:
What I don't trust in your code is the printf in the read_write function; your Rx_databuf_M8051 is not zeroed so printf will display a string that might not be terminated (with '\0'). Further you read a max of 255 chars into an array that can hold 100 chars; calling for trouble :D PS I've reported your post to be moved to the programming section |
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
|
trermios
yes I tried to modify the what have suggested earlier mail
but still the same issue I need to hit enter key to read data ... |
Check your code where you set the options for termios.
Code:
newtio.c_cflag = BAUDRATE | CS8 | CLOCAL | CREAD; |
Not sure to understand what do you want to achieve but see if removing the "ICANON" flag solve your issue (google for termios canonic)
|
without carriage return receive data from UART
thanks for your reply...
I think you did not get my problem let me explain you once again.. I am trying to write and read data from uart (serial port), where I am able write data successfully but while reading data once I hit enter key or carriage return only I able to see data on hyper-terminal... other wise no data is displayed on hyper terminal... so my intention to receive data as we type character not only after hitting enter key.. |
I still don't understand your problem exactly. From what I understand, your program runs on linux and, for now, communicates with a windows machine where you run hyper-terminal. In hyperterm you don't see anything from your program when you start your program till you press <enter> in hyperterm. Is that indeed your problem?
If that is your problem, do you start hyperterm before you start your program? If not, your program has already send the data '#09,R$' so you have to press <enter> before it will send it again as your read is blocking the loop. If yes, sounds like a hyperterm configuration and at this stage I can't help you with that (as I don't have a hyperterm available at this moment). Your program does send the data immediately (and works from that perspective); I have confirmed this using minicom under Ubuntu using pseudo terminals. You can configure minicom to use /dev/ptyp0 (and correct baudrate/parity settings etc) and your program to use /dev/ttyp0. Note that the names of the pseudo terminal pairs might depend on your OS. PS I also don't know if you can configure hyperterm to send a character at the moment that you type it. I also don't know if this is possible in minicom (still trying). |
Dear Wim Sturkenboom,
Thanks for your mail. I actually has arm 9 board and it starts and bootups from serial and I have connected arm9 serial port to windows hyper-terminal. But I develope compile application in fedora (linux) machine and download this file to arm9 board through windows hyperterminal. by sftp... I think this is very clear now... (I am not using minicom any whrere)... as u said in your mail once I run the application I get #09,R$ (since hyper terminal is already connected) but while reading data I am facing the problem (I want to receive data any time, it sholud not block the application) not by waiting for number of charcter, any no of character should be received.... |
Your read is fine. The problem is that hyperterm more than likely uses buffered IO in its current configuration and will only send once you have pressed <enter>. So you must look in the hyperterm documentation if you can change that behaviour.
|
termios setting
I don't think it is hyper terminal setting problem..
since i have interfaced another controller once I put in code 0x0D the data isread by ARM9 board ... I feel it all settings of termios... do have any ready made code which receives data on interrupt so that it will not block the normal flow... |
You might be right
From man termios: Code:
In non-canonical mode input is available immediately (without the user |
You are right; I've just changed ICANON in your code to ~ICANON and it works. Learned something again that I had forgotten.
|
All times are GMT -5. The time now is 05:01 PM. |