- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi:
How could I open/set flags to an Altera UART device for being used in a non-blocking manner, e.g. a call to fgetc() or fread() returns inmediately if no characters are available? Thanks a lotLink Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With fcntl, I believe. It wasn't implemented in versions prior to 5.0, but it should be there now. When using it, keep in mind that your file descriptors for stdin, stdout, stderr are STDIN_FILENO, etc.
Cheers, - slacker- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi:
At this very moment we are still using NIOS-II with Quartus II-4.2. When looking at the UART HAL driver source code we see that a check for the flag bit O_NONBLOCK is made, so the question is how could I set this flag on. For opening the device I use fopen(). It seems to be around a unix style open() function with parameters for mode and flags. But it didnt work for me. Thanks,- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi VLorenzo,
> For opening the device I use fopen(). I rarely, if ever, use streams ... so I've never have the need for fdopen() ... but you might give it a try:int fd;
FILE *fs;
fd = open("/dev/uart1", O_RDWR | O_NONBLOCK | O_NOCTTY);
if (fd != -1) fs = dopen(fd, "rw");
And please let us know how/if it works. Regards, --Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, fat-fingered it ... that would be:
if (fd != -1) fs = fdopen (fd, "rw"); --Scott- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi smcnutt,
It works fine now using the unix style open, read and write functions from "unistd.h". for opening the device: comm_uartfd = open( uart_name, O_RDWR | O_NONBLOCK | O_NOCTTY ); for writing: write( comm_uartfd, src, size ) for reading: res = read( comm_uartfd, &curr_rxd, 1 ); Thanks
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