- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How do I set nonblocking mode for stdin (a standard uart) using the HAL? After wading through hunderds of pages of useless Altera info and library sources, I still can't find that simple piece of information.
<rant> It could be me, but I find this whole HAL/Posix compliance thing one big pile of useless, horribly documented useless junk that frustates the hell out of me, that instead of saving me time, only cost me more time. </rant> Thanks, JeroenLink Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
int fdterm; // FILEDESCRIPTOR RETURNED BY OPEN
FILE * fpterm; // FILE pointer returned by fdopen fdterm = open("/dev/uart1", O_RDWR | O_NONBLOCK | O_NOCTTY); fpterm=fdopen(fdterm,"rw+"); ... uart1_rxcount=read(fdterm,uart1_rxbuffer,UART1_RXBUFFERSIZE-1); if(uart1_rxcount>0) { ...something received fprintf(fpterm,"received:%s\r\n",uart1_rxbuffer); ...- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
<div class='quotetop'>QUOTE </div>
--- Quote Start --- How do I set nonblocking mode for stdin (a standard uart) using the HAL? After wading through hunderds of pages of useless Altera info and library sources, I still can't find that simple piece of information. <rant> It could be me, but I find this whole HAL/Posix compliance thing one big pile of useless, horribly documented useless junk that frustates the hell out of me, that instead of saving me time, only cost me more time. </rant>[/b] --- Quote End --- The information you sought was in chapter 10 page 60 of the Nios II Software Devlopers Handbook n2sw_nii5v2.pdf. This is the description of the open() function call. It was the first thing that a search of this manual found when searching for NONBLOCK. "You may also bitwise-OR flags with O_NONBLOCK, which causes the file to be opened in non-blocking mode. Neither open() nor any subsequent operations on the returned file descriptor causes the calling process to wait." As for your rant, it would be much more beneficial to all if you could post problems you have encountered, that way we can try to fix them.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ideally, one could change the blocking status of STDIN instead of making another file descriptor and updating all of the calls to printf with the new file descriptor.
I have heard that support for the fcntl call will be added in a future release. That functionality would be very helpful. As far as the original post, there isn't a way that I can see of changing STDIN to non blocking. Only a way to create a new file descriptor which is non blocking. However, I am still impressed with the depth of the HAL and I am looking forward to the refinements that Altera is providing. regards,- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apparently you have a newer version of the handbook, as page 60 describes lseek and open is not described; searching for NONBLOCK gives no hits. I should have checked for updates http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/tongue.gif
I got it more or less working now; I have to combine the data from/to the UART with an EPP port http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/blink.gif About the rant, it just was one of those days nothing seems to work. For the rest, I'm a happy Altera customer. Thanks, Jeroen
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page