repositories
/
deb_libcec.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cec: moved the timed ping to a separate thread. bugzid: 654
[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 31ae09b1cdd2d58261f25f92acbab9f587a84be0..cefc21201ef03ee41d17feea11e5cdc3aac9e529 100644
(file)
--- a/
src/lib/platform/posix/serialport.cpp
+++ b/
src/lib/platform/posix/serialport.cpp
@@
-53,29
+53,32
@@
using namespace PLATFORM;
void CSerialSocket::Close(void)
{
void CSerialSocket::Close(void)
{
- SocketClose(m_socket);
+ if (IsOpen())
+ SocketClose(m_socket);
}
void CSerialSocket::Shutdown(void)
{
}
void CSerialSocket::Shutdown(void)
{
- SocketClose(m_socket);
+ if (IsOpen())
+ SocketClose(m_socket);
}
ssize_t CSerialSocket::Write(void* data, size_t len)
{
}
ssize_t CSerialSocket::Write(void* data, size_t len)
{
- return
SocketWrite(m_socket, &m_iError, data, len)
;
+ return
IsOpen() ? SocketWrite(m_socket, &m_iError, data, len) : -1
;
}
ssize_t CSerialSocket::Read(void* data, size_t len, uint64_t iTimeoutMs /* = 0 */)
{
}
ssize_t CSerialSocket::Read(void* data, size_t len, uint64_t iTimeoutMs /* = 0 */)
{
- return
SocketRead(m_socket, &m_iError, data, len, iTimeoutMs)
;
+ return
IsOpen() ? SocketRead(m_socket, &m_iError, data, len, iTimeoutMs) : -1
;
}
//setting all this stuff up is a pain in the ass
bool CSerialSocket::Open(uint64_t iTimeoutMs /* = 0 */)
{
iTimeoutMs = 0;
}
//setting all this stuff up is a pain in the ass
bool CSerialSocket::Open(uint64_t iTimeoutMs /* = 0 */)
{
iTimeoutMs = 0;
- CLockObject lock(m_mutex);
+ if (IsOpen())
+ return false;
if (m_iDatabits != SERIAL_DATA_BITS_FIVE && m_iDatabits != SERIAL_DATA_BITS_SIX &&
m_iDatabits != SERIAL_DATA_BITS_SEVEN && m_iDatabits != SERIAL_DATA_BITS_EIGHT)
if (m_iDatabits != SERIAL_DATA_BITS_FIVE && m_iDatabits != SERIAL_DATA_BITS_SIX &&
m_iDatabits != SERIAL_DATA_BITS_SEVEN && m_iDatabits != SERIAL_DATA_BITS_EIGHT)