Hi all,
I use the following code in order to read from a serial port based on the command I write there first.
Code:
write(*dev_fd,pwise_command,PWISE_COMMAND_SIZE);
int p_devbytes = 1;
while(p_devbytes)
{
FD_SET(*dev_fd,&fdsread);
fdsreaduse = fdsread;
q.tv_sec = 5;
q.tv_usec = 0;
sel_res = select((*dev_fd+1),&fdsreaduse,NULL,NULL,&q);
if (sel_res == -1 || sel_res == 0) {
break;
}
else if(FD_ISSET(*dev_fd,&fdsreaduse))
{
memset(&p_devdata[0], 0, sizeof(p_devdata));
p_devbytes = (int)read(*dev_fd,p_devdata,128);
strcat(p_devdatabuffer,p_devdata);
}else
FD_ZERO(&fdsread);
}
printf("DATA:%s\n",p_devdatabuffer);
Now, everything works fine the first time around for write/read cycle, however when my program does it for second request I only get the first line of the response after which the serial port does not respond anymore.
I run this code on an embedded controller with Midge linux. It seems to run fine when running it on my laptop, however when I cross compile it for the embedded controller I get the above problem.
Now the question. I am not that experienced C programmer, so would someone be able to tell me if the above problem might be:
1) issue with my code
2) issue with the serial port configuration on the embedded controller (this is a USB port by the way if that makes any difference)
3) issues with Midge OS
Really stuck with this so any advice/ideas greatly appreciated.
Regards,
Olli