open("/dev/ser1", O_RDWR) returns 1 ,why?

Hello?

I am trying to make a simple example code for using serial port.
You can find it below.
But this code doesn’t work as I intended to because ‘open’ returns 1 which is the value of ‘stdout’ (or stdin?).
I expected it to be a number bigger than 2 because 0,1,2 are already open filedescripters - stdin, stdout and stderr.

Why I only get 1 from open("/dev/ser1", O_RDWR)? Could you please explain this?

[code]int main(int argc, char argv[]) {
/
-------------- internal variables -------------/
int filedesc;
int bytesRead;
fd_set rfd;
char buff[256] = {0x0};
/
------------------------------------------*/

printf("main() begins\n");

if (filedesc = open("/dev/ser1", O_RDWR) > 0) {
	printf("filedesc= %d\n", filedesc);

	FD_ZERO( &rfd );
	FD_SET( filedesc, &rfd );

	while (1) {
		if ( select( 1 + filedesc, &rfd, 0, 0, 0 ) < 0 ) {
			printf("select() failed!!\n");
			return EXIT_FAILURE;
		}
		printf("received a message\n");
		memset(buff, 0x0, sizeof(buff));
		if (bytesRead = read(filedesc, buff, sizeof(buff)) < 0) {
			printf("read() failed!!\n");
		}
		printf("%s",buff);
	}
	close(filedesc);
}

return EXIT_SUCCESS;

}[/code]

For your information, this program was tested on an x86 target machine which has been set with qnx6.3.2. And the target was connected with another x86 machine which has been set with Windows xp by a serial cable. The connection has been tested by doing “cat /etc/hosts > /dev/ser1” on the qnx system and checking the text output on the hyperterminal app on windows xp system.

I solved this problem with the help from my supervisor.
if (filedesc = open("/dev/ser1", O_RDWR) > 0)
has to be if ((filedesc = open("/dev/ser1", O_RDWR)) > 0)
operator ‘>’ takes precedence to the operator ‘=’
^^