I am doing the serial port testing under QNX 6.2.1B , I wrote and ran the following code but nothing can be seen from the serial output.
I would be very appreciated if any suggestion and help.
Regards,
Shilunz
int main(void)
{
int data = 0, fd, error;
int i,j,n,sec;
struct termios oldtio, newtio;
char buf[255]; //buffer for where data is put
speed_t speed;
//if((fd = open ("/dev/ser2", O_RDWR|O_NOCTTY)) == -1)
if((fd = open ("/dev/ser1", O_RDWR |O_NOCTTY )) == -1)
{
fprintf(stderr, "Error with open() on /dev/ser1. Make sure exists.\n");
perror (NULL);
exit(EXIT_FAILURE);
}
tcgetattr(fd,&oldtio); // save current port settings
oldtio.c_cflag &= ~CSIZE;
oldtio.c_cflag |= CS8;
oldtio.c_cflag &=~CSTOPB; //1 stop
oldtio.c_cflag &=~PARENB; //no parity
oldtio.c_cflag &=~IHFLOW; //no handshake
oldtio.c_cflag &=~OHFLOW; //no handshake
oldtio.c_cflag |= CLOCAL | CREAD;
oldtio.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); //raw;
//no sw handshake
oldtio.c_iflag &= ~(IXON | IXOFF );
//raw
oldtio.c_oflag &= ~OPOST;
tcflush(fd, TCIFLUSH);
//speed setting
speed=600;
//speed=38400;
cfsetispeed( &oldtio, speed);
cfsetospeed( &oldtio, speed);
tcsetattr(fd,TCSANOW,&oldtio);
sec=60;
while(sec--)
{
for(i=0;i<255;i++)
buf[i]=0xff;
n=write(fd, buf,i);
if(n<0)
printf(" Write Err!\n");
else
printf(" Written :%d \n",n);
sleep(1);
}
close(fd);
return (1);
I am doing the serial port testing under QNX 6.2.1B , I wrote and ran the following code but nothing can be seen from the serial output.
I would be very appreciated if any suggestion and help.
Regards,
Shilunz
int main(void)
{
int data = 0, fd, error;
int i,j,n,sec;
struct termios oldtio, newtio;
char buf[255]; //buffer for where data is put
speed_t speed;
//if((fd = open ("/dev/ser2", O_RDWR|O_NOCTTY)) == -1)
if((fd = open ("/dev/ser1", O_RDWR |O_NOCTTY )) == -1)
{
fprintf(stderr, "Error with open() on /dev/ser1. Make sure exists.\n");
perror (NULL);
exit(EXIT_FAILURE);
}
tcgetattr(fd,&oldtio); // save current port settings
oldtio.c_cflag &= ~CSIZE;
oldtio.c_cflag |= CS8;
oldtio.c_cflag &=~CSTOPB; //1 stop
oldtio.c_cflag &=~PARENB; //no parity
oldtio.c_cflag &=~IHFLOW; //no handshake
oldtio.c_cflag &=~OHFLOW; //no handshake
oldtio.c_cflag |= CLOCAL | CREAD;
oldtio.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); //raw;
//no sw handshake
oldtio.c_iflag &= ~(IXON | IXOFF );
//raw
oldtio.c_oflag &= ~OPOST;
tcflush(fd, TCIFLUSH);
//speed setting
speed=600;
//speed=38400;
cfsetispeed( &oldtio, speed);
cfsetospeed( &oldtio, speed);
tcsetattr(fd,TCSANOW,&oldtio);
sec=60;
while(sec--)
{
for(i=0;i<255;i++)
buf[i]=0xff;
n=write(fd, buf,i);
if(n<0)
printf(" Write Err!\n");
else
printf(" Written :%d \n",n);
sleep(1);
}
close(fd);
return (1);