/[H7]/branches/linux-serial/Serial.cpp
ViewVC logotype

Diff of /branches/linux-serial/Serial.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 56 by torben, Mon Feb 5 10:24:24 2007 UTC revision 57 by torben, Mon Feb 5 10:38:58 2007 UTC
# Line 1  Line 1 
1  #ifndef _MSC_VER //linux  #ifndef _MSC_VER //linux
2  #include <sys/types.h>  #include <sys/types.h>
3  #include <sys/stat.h>  #include <sys/stat.h>
   
4  #include <unistd.h>  #include <unistd.h>
5  #include <errno.h>  #include <errno.h>
6  #include <termios.h>  #include <termios.h>
7  #include <fcntl.h>  #include <fcntl.h>
8  #endif  #endif
9    
 #include "stdafx.h"  
 #include "Serial.h"  
10    
11  #include <stdexcept>  #include <stdexcept>
12  #include <string>  #include <string>
# Line 20  Line 17 
17  #include <iomanip>  #include <iomanip>
18  #endif  #endif
19    
20  #define _POSIX_SOURCE 1 /* POSIX compliant source */  #include "stdafx.h"
21  #define BAUDRATE B9600  #include "Serial.h"
22    
 #ifndef _MSC_VER // ugly hack, else will gcc not accept this constant in openLinux()  
 const int flags = O_RDWR | O_NOCTTY | O_NONBLOCK;  
 #endif  
23    
24  std::string writeLastError()  std::string writeLastError()
25  {  {
# Line 40  std::string writeLastError() Line 34  std::string writeLastError()
34                          NULL);                          NULL);
35    
36          std::ostringstream out;          std::ostringstream out;
37          out << "Error" << lpMsgBuf;          out << "Error " << lpMsgBuf;
38          return out.str();          return out.str();
39  #else //linux  #else //linux
40          return std::string( strerror(errno) );          return std::string( strerror(errno) );
# Line 134  void CSerial::openLinux() Line 128  void CSerial::openLinux()
128  {  {
129          termios newtio;          termios newtio;
130    
131          mFiledescriptor = ::open(mPortstr, flags);          mFiledescriptor = ::open(mPortstr, O_RDWR | O_NOCTTY | O_NONBLOCK);
132          if (mFiledescriptor < 0)          if (mFiledescriptor < 0)
133                  throw std::runtime_error( writeLastError() );                  throw std::runtime_error( writeLastError() );
134    

Legend:
Removed from v.56  
changed lines
  Added in v.57

  ViewVC Help
Powered by ViewVC 1.1.20