New result:
Code list:
int main(int argc, char *argv[])
{
int nsIMU = open("/dev/ser1", O_RDWR);
termios term;
tcgetattr(nsIMU, &term);
cfsetispeed(&term, 57600); //input and output baudrate
cfsetospeed(&term, 57600);
term.c_cflag = CS8 | CLOCAL | CREAD;
tcsetattr(nsIMU, TCSANOW, &term);
char szBuffer[4096];
char bufAH440[] = {0x55,0x55,0x47,0x50,0x02,0x41,0x30,0x94,0x87}; // NAV440 poll A0
char buf0Hz[] = {0x55,0x55,0x53,0x46,0x05,0x01,0x00,0x01,0x00,0x00,0x40,0x81};
tcflush(nsIMU, TCIOFLUSH);
usleep(500000);
::write(nsIMU, buf0Hz, 12);
usleep(15000);
// Poll 'A0'
int nWrite = ::write(nsIMU, bufAH440, 9);
if(nWrite!=9)
cout<<"Write operation error"<<endl;
usleep(500000);
while(1)
{
static int errCnt = 0;
// double t1 = ::GetTime();
usleep(20000);
int nRead = read(nsIMU, szBuffer, 50);
// tcflush(nsIMU, TCIFLUSH);
if (nRead>0)
{
cout<<"Bytes rcved: “<<nRead<<endl;
for (int i=0;i<nRead;i++)
{
printf(”%02x ", (unsigned char)szBuffer[i]);
}
cout<<endl;
if(nRead!=37)
errCnt++;
cout<<"error packets: "<<errCnt<<endl;
}
else
cout<<“No packets”<<endl;
::write(nsIMU, bufAH440, 9);
}
return EXIT_SUCCESS;
}
I attached the outcome in the annex. The current problem is after 69 times of error packets, the following requested packets all arrive correctly. If i paused the program, and then continue, then after 69 or 68 times of period, the requested packets will again return to the correct streams. No ideas on the hardware side, or my software side. Look forward to suggestions.
Eric