You cannot rely on the default settings of your serial port (and you should not try to use stty to set them up outside of your program). You have to write code into your program that sets your serial port up properly. For this, you have to use functions like tcsetattr/tcgetattr, cfsetspeed, etc., see man termios.
Also, fstream might not provide access to the proper open() function parameters to use, as opening a serial port on UNIX should be done with O_NOCTTY flag.