I'm trying to communicate to a serial port RF receiver (specifically the W800RF32A) which is supposed to receive events from wireless X10 devices.

Within the function that is supposed to read the port I have:
Qt Code:
  1. ErrorText->setText("Clicked");
  2.  
  3. string line;
  4. ifstream myfile ("/dev/ttyS0");
  5.  
  6. ErrorText->append("Created file object...");
  7.  
  8. if (myfile.is_open())
  9. {
  10. ErrorText->append("file is open...");
  11.  
  12. while ( !myfile.eof() )
  13. {
  14. ErrorText->append("not at end...");
  15. // getline (myfile,line);
  16. ErrorText->append("got line...");
  17. ErrorText->append(line);
  18. cout << line << endl;
  19.  
  20. }
  21.  
  22. ErrorText->append("End of file, closing");
  23. myfile.close();
  24. ErrorText->append("closed");
  25.  
  26. }
  27.  
  28. else cout << "Unable to open file";
To copy to clipboard, switch view to plain text mode 

You'll notice the commented getline function. The code can compile and run fine as long as I don't have the getline or similar function in there (and I've tried almost every alternative I could find for "getlin" because I know getline isnt going to work [no terminating character etc]).

Now when I look around for QT and stuff about serial ports everything is all QextSerial or some other class, but I've been told on linux you don't need that and you can simply read the serial port like a text file....... hence the above approach.

(btw I have a version of the above that uses QFile, it too behaves the same way)

So my questions:
1)Do I need another class to handle the serial port in linux?
2)If not, then what function should I use to get the incoming characters?? (to replace the commented line)