- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
Browsing through Altera documentation suggests I should be using the HAL with a UART. So using the HAL how do I determine if there is data available from the UART before calling getchar()? I need my system to be doing other stuff and can't have it block while waiting for the UART to receive data. I can see I have to use the fast version of the driver so that the UART operates under interrupts but I can't see an equivalent to the old kbhit() function. Ta, MikeLink Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just an idea, can you fiddle with the driver to be able to look at the pointers for the receive buffer? Maybe you can work out a function like kbhit then.
Stefaan- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
open device uart in non blocking mode:
static int fdterm; // FILEDESCRIPTOR RETURNED BY OPEN .. fdterm = open("/dev/uart1", O_RDWR | O_NONBLOCK | O_NOCTTY); .. reading is done by .. res=read(fdterm,uart1_tempbuff,sizeof(uart1_tempbuff)-1); if(res>0) { ... we have received some bytes }- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Fischer
Thanks for your reply. I managed to work it out for myself but it is nice to have confirmation from a expert that I am doing the right thing. Mike
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