unable to read from serial port
I have been trying to communicate with device trhough /dev/ttyS0.
The device sends out data as soon as it powers up but the read just gets stuck and I cant proceed any further. After the initial startup data from the device, commands can be sent to it to control it. I can send one command to it successfully but after that I cant control the device.
Could the serial port be blocked by the kernel for some reason or is my code itself wrong. I have posted the code below and I would be grateful for any help regarding this.
struct termios ol;
struct termios nw;
fd=open("/dev/ttyS0", O_RDWR|O_NOCTTY|O_NDELAY);//opening port
printf("%s","error opening port\n\n");
tcgetattr(fd,&ol); //getting serial port attributes
nw.c_cflag |=B115200; //baud rate
nw.c_cflag &=~CSTOPB;//8N1 settings
nw.c_lflag |=~(ICANON | ECHO | ECHOE | ISIG);
printf("%s","error in setting up device\n\n");
printf("%s","trying to read");
bytes=fcntl(fd,F_SETFL,FNDELAY); //to avoid serial port blocking
res=read(fd,buff,100); //trying to read initial setup data-not working
n=write(fd,"debug d 35 5 0\r",1000); //writing command to WSS