repositories
/
deb_libcec.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cec: refactored threading/locking - added windows native instead of pthread-win32...
[deb_libcec.git]
/
src
/
lib
/
platform
/
posix
/
serialport.cpp
diff --git
a/src/lib/platform/posix/serialport.cpp
b/src/lib/platform/posix/serialport.cpp
index f0408574dad1670238a571ab0dcadfb8acedcff3..ec8a5c1d48e2f4ea14160ab5bd51719de318a81b 100644
(file)
--- a/
src/lib/platform/posix/serialport.cpp
+++ b/
src/lib/platform/posix/serialport.cpp
@@
-32,8
+32,8
@@
#include <stdio.h>
#include <fcntl.h>
#include <stdio.h>
#include <fcntl.h>
-#include "../serialport.h"
-#include "../baudrate.h"
+#include "../serialport
/serialport
.h"
+#include "../
serialport/
baudrate.h"
#include "../timeutils.h"
#if defined(__APPLE__)
#include "../timeutils.h"
#if defined(__APPLE__)
@@
-48,7
+48,7
@@
#endif
#endif
using namespace std;
#endif
#endif
using namespace std;
-using namespace
CEC
;
+using namespace
PLATFORM
;
CSerialPort::CSerialPort()
{
CSerialPort::CSerialPort()
{
@@
-61,32
+61,33
@@
CSerialPort::~CSerialPort()
Close();
}
Close();
}
-int
8_t CSerialPort::Write(CCECAdapterMessage *data
)
+int
64_t CSerialPort::Write(uint8_t* data, uint32_t len
)
{
fd_set port;
{
fd_set port;
- CLockObject lock(
&
m_mutex);
+ CLockObject lock(m_mutex);
if (m_fd == -1)
{
m_error = "port closed";
return -1;
}
if (m_fd == -1)
{
m_error = "port closed";
return -1;
}
- int32_t byteswritten = 0;
-
- struct timeval timeout, *tv;
- if (data->transmit_timeout <= 0)
- {
+ int64_t byteswritten = 0;
+ struct timeval *tv;
+//TODO
+// struct timeval timeout, *tv;
+// if (data->transmit_timeout <= 0)
+// {
tv = NULL;
tv = NULL;
- }
- else
- {
- timeout.tv_sec = (long int)data->transmit_timeout / (long int)1000.;
- timeout.tv_usec = (long int)data->transmit_timeout % (long int)1000.;
- tv = &timeout;
- }
-
- while (byteswritten <
(int32_t) data->size()
)
+
//
}
+
//
else
+
//
{
+
//
timeout.tv_sec = (long int)data->transmit_timeout / (long int)1000.;
+
//
timeout.tv_usec = (long int)data->transmit_timeout % (long int)1000.;
+
//
tv = &timeout;
+
//
}
+
+ while (byteswritten <
len
)
{
FD_ZERO(&port);
FD_SET(m_fd, &port);
{
FD_ZERO(&port);
FD_SET(m_fd, &port);
@@
-102,7
+103,7
@@
int8_t CSerialPort::Write(CCECAdapterMessage *data)
return -1;
}
return -1;
}
- returnv = write(m_fd, data
->packet.data + byteswritten, data->size()
- byteswritten);
+ returnv = write(m_fd, data
+ byteswritten, len
- byteswritten);
if (returnv == -1)
{
m_error = strerror(errno);
if (returnv == -1)
{
m_error = strerror(errno);
@@
-116,7
+117,7
@@
int8_t CSerialPort::Write(CCECAdapterMessage *data)
{
printf("%s write:", m_name.c_str());
for (int i = 0; i < byteswritten; i++)
{
printf("%s write:", m_name.c_str());
for (int i = 0; i < byteswritten; i++)
- printf(" %02x", data
->at(i)
);
+ printf(" %02x", data
[i]
);
printf("\n");
}
printf("\n");
}
@@
-131,7
+132,7
@@
int32_t CSerialPort::Read(uint8_t* data, uint32_t len, uint64_t iTimeoutMs /*= 0
int64_t now(0), target(0);
int32_t bytesread = 0;
int64_t now(0), target(0);
int32_t bytesread = 0;
- CLockObject lock(
&
m_mutex);
+ CLockObject lock(m_mutex);
if (m_fd == -1)
{
m_error = "port closed";
if (m_fd == -1)
{
m_error = "port closed";
@@
-202,7
+203,7
@@
bool CSerialPort::Open(string name, uint32_t baudrate, uint8_t databits /* = 8 *
{
m_name = name;
m_error = strerror(errno);
{
m_name = name;
m_error = strerror(errno);
- CLockObject lock(
&
m_mutex);
+ CLockObject lock(m_mutex);
if (databits < 5 || databits > 8)
{
if (databits < 5 || databits > 8)
{
@@
-290,7
+291,7
@@
bool CSerialPort::Open(string name, uint32_t baudrate, uint8_t databits /* = 8 *
void CSerialPort::Close()
{
void CSerialPort::Close()
{
- CLockObject lock(
&
m_mutex);
+ CLockObject lock(m_mutex);
if (m_fd != -1)
{
close(m_fd);
if (m_fd != -1)
{
close(m_fd);
@@
-335,6
+336,6
@@
bool CSerialPort::SetBaudRate(uint32_t baudrate)
bool CSerialPort::IsOpen()
{
bool CSerialPort::IsOpen()
{
- CLockObject lock(
&
m_mutex);
+ CLockObject lock(m_mutex);
return m_fd != -1;
}
return m_fd != -1;
}