Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12600 Discussions

Simultaneous open of two UART on a single NIOS II

Altera_Forum
Honored Contributor II
1,058 Views

Hi, 

 

I searched before post but I didn't find anything so I hope nobody asked this before. 

 

I try to use several (three on my final application) UART on the same NIOS and connected each others (uart0 <=> uart1). I want to send a character with uart0 to uart1. 

To do this, I want to use open, read, and write function in non blocking mode (reduced_device_driver option disable). 

But when I try to open the second uart, i have an error (errno 24 => EMFILE /* Too many open files */). 

I tried to disable uart1 when I send the character with uart0 and enable it after and it's working but for my application it's not really applicable... 

SO my question is: 

Is it possible to open more than one uart device at the same time? 

 

Thank you in advance! :)
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
395 Views

Go into the BSP editor, and under the "Advanced" section, increase the value of hal.max_file_descriptors. 

 

Also, it is not strictly necessary to use reduced drivers if you just want non-blocking access. If you're using the full HAL layer, you can also use fcntl() to set O_NONBLOCK on the device. (This does not appear to work on the standard streams - stdin, stdout, stderr - but it should work on a device you have opened with open().) Keep in mind that this will make the device non-blocking for both reads and writes; i.e. check the return value of write() -- don't just assume the character was sent.
0 Kudos
Reply