changed the year in copyright notices to 2011-2012
[deb_libcec.git] / src / lib / platform / sockets / serialport.h
index bef3a806abd9ac8a6849c03891ddfff749e77429..7b0a3a0be8af8b9764c74e2ca4f68d5f94871f26 100644 (file)
@@ -2,7 +2,7 @@
 /*
  * This file is part of the libCEC(R) library.
  *
- * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited.  All rights reserved.
+ * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited.  All rights reserved.
  * libCEC(R) is an original work, containing original code.
  *
  * libCEC(R) is a trademark of Pulse-Eight Limited.
 
 #if !defined(__WINDOWS__)
 #include <termios.h>
-#include "socket.h"
 #endif
 
+#include "socket.h"
+
 namespace PLATFORM
 {
   #define PAR_NONE 0
@@ -52,27 +53,33 @@ namespace PLATFORM
   {
     public:
       CSerialPort(void);
-      virtual ~CSerialPort(void) {};
+      virtual ~CSerialPort(void) {}
 
       bool Open(std::string name, uint32_t baudrate, uint8_t databits = 8, uint8_t stopbits = 1, uint8_t parity = PAR_NONE);
 
       CStdString GetName(void) const
       {
         CStdString strName;
-        strName = m_name;
+        strName = m_strName;
         return strName;
       }
 
-  private:
-      bool SetBaudRate(uint32_t baudrate);
+    #ifdef __WINDOWS__
+      virtual bool IsOpen(void);
+      virtual void Close(void);
+      virtual int64_t Write(uint8_t* data, uint32_t len);
+      virtual int32_t Read(uint8_t* data, uint32_t len, uint64_t iTimeoutMs = 0);
+    #endif
 
-      std::string  m_name;
-      bool         m_tostdout;
+    private:
+      bool SetBaudRate(uint32_t baudrate);
 
-  #ifdef __WINDOWS__
+    private:
+    #ifdef __WINDOWS__
+      void FormatWindowsError(int iErrorCode, CStdString &strMessage);
       bool SetTimeouts(bool bBlocking);
 
-      HANDLE                m_handle;
+      HANDLE                m_handle; 
       bool                  m_bIsOpen;
       uint32_t              m_iBaudrate;
       uint8_t               m_iDatabits;
@@ -84,5 +91,7 @@ namespace PLATFORM
   #else
       struct termios     m_options;
   #endif
+      std::string  m_strName;
+      bool         m_bToStdOut;
   };
 };