cec: added tcp client sockets to lib/platform
[deb_libcec.git] / src / lib / platform / sockets / serialport.h
index bef3a806abd9ac8a6849c03891ddfff749e77429..c6cb5953a1a9d7a45d2d5b28d17a57250e2b42ee 100644 (file)
 
 #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;
   };
 };