write application arm linux fd=open
I wrote the programme for accessing the serial port of EP9312. But when i run the programme the following error comes;
"open_port: unable to open /dev/ttyS1-: no such a device"
i cannot understand why? i also changed the device file to ttyS0 but Problem remain same.
The source code is given below;
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
//int open_port();
int main()
{ struct termios options;
int i;
int n;
int fd;
//int open_port(void)
// {
fd=open("/dev/ttyS1", O_RDWR | O_NOCTTY | O_NDELAY);
if (fd==-1)
{
perror("open_port: unable to open /dev/ttyS1 - ");
}
else
fcntl(fd, F_SETFL, 0);
//return (fd);
// }
tcgetattr(fd, &options);
cfsetispeed(&options,B19200);
cfsetospeed(&options,B19200);
options.c_cflag |= ( CLOCAL | CREAD);
tcsetattr(fd, TCSANOW, &options);
for (i=0; i<=10; i++)
{
n= write(fd, "ALLAH O AKBER\n", 14);
write(fd, "Hello World\n", 12);
if (n<0)
fputs("write() of 4 bytes failed!\n", stderr);
}
return 0;
}
I complaid this code with ARM cross compiler provided by cirrus logic cross compiler 2.95.3
This Program work well on redhat linux 9.
Waiting for your reply
Bakhat