Serial port

I’ve never used serial port before, could you plese give me a simple example to start ?
Thanks
Stiefin

char *outmsg=“Out the serial port”;
char inmsg[80];

fd=open("/dev/ser1", O_RDWR);

/* write out the serial port */
write(fd, outmsg, strlen(outmsg);

/* read from the serial port */
read(fd, inmsg, sizeof(inmsg));

close(fd);

Look at tcgetattr()/tcsetattr() and other functions of tc* family, if you want some control over serial port (set baud rate, flow control, etc).