serial port problem is occuring,,, pls guide on the same as i new to this,,,
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
int main()
{
int fd;
int wd=0;
unsigned char buff[] = { 0x02, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x23, 0x01, 0x21, 0x03};
fd = open("/dev/ttyS0", O_RDONLY | O_NOCTTY | O_NDELAY );
if (fd == -1)
{printf("error opening");}
else
{
printf("%d", fd); //i get fd value to be 3
fcntl(fd, F_SETFL, 0);
wd=write(fd, buff, 13 );
}
printf("%d", wd); //i get wd to be -1, so what is the problem??
close(fd);
}