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++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
12748 Discussions

Error while trying to use RS232 port on DE2 2c35 running uClinux

Altera_Forum
Honored Contributor II
1,197 Views

Hi all, 

I try to use RS232 port on my DE2 board to communicate with my device (magnetic card reader). 

But when I try to use the command "cat test.txt > /dev/ttyS0", the console appears with "/dev/ttyS0: cannot create." I am wondering if I have to check "Altera UART support" in "Device Drivers ---> Character devices ---> Serial drivers --->" or just use ttyS0 as a normal file? And how I can know that there are data coming from my device or PC? Is there buffer for data from RS232 port? :confused:  

 

Thanks for reading! :)
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
475 Views

Hi Tien, 

You have to be carefull with this command "cat test.txt > /dev/ttyS0", use microcom instead. You will find it in the application selection of the make menuconfig. command will be :  

microcom -s 9600 /dev/ttyS0 

with 9600 the baud rate of your serial connexion.
0 Kudos
Altera_Forum
Honored Contributor II
475 Views

thanks for replying Mr actris, I have solved that problem by updating to nios2-linux 2009 version. I can open and write data to "dev/ttyS0" well. 

But I encounter another problem now. I can't read from "dev/ttyS0" by using read or fread functions. :( 

here's my code: 

 

# include <string.h> # include <unistd.h> # include <fcntl.h> # include <errno.h> # include <termios.h> int main(void) { char buf; int fd1, fd2, count; fd1 = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY); fd2 = open("/mnt/SD/t.txt",O_WRONLY); if (fd1 == -1) { perror("open_port: Unable to open /dev/ttyS0 - "); } while(count = read(fd1, buf, 10) > 0) write(fd2, buf, 10); close(fd1); close(fd2); //return (fd); }
0 Kudos
Reply