integration from bus into ebusloop continued.
This commit is contained in:
@@ -54,9 +54,9 @@ const std::string BusCommand::getMessageStr()
|
||||
result += "00";
|
||||
result += m_result.getDataStr();
|
||||
result += "00";
|
||||
} else {
|
||||
result = "success";
|
||||
}
|
||||
else
|
||||
result = "success";
|
||||
}
|
||||
else
|
||||
result = "error: "+std::string(getResultCodeCStr());
|
||||
|
||||
+4
-1
@@ -31,6 +31,9 @@ namespace libebus
|
||||
/** available device types. */
|
||||
enum DeviceType { SERIAL, NETWORK };
|
||||
|
||||
/** max bytes write to bus. */
|
||||
#define MAX_WRITE_SIZE 1
|
||||
|
||||
/** max size of receive buffer. */
|
||||
#define MAX_READ_SIZE 100
|
||||
|
||||
@@ -218,7 +221,7 @@ public:
|
||||
* @param nbytes number of bytes to send.
|
||||
* @return number of written bytes or -1 if an error has occured.
|
||||
*/
|
||||
ssize_t send(const unsigned char* buffer, size_t nbytes)
|
||||
ssize_t send(const unsigned char* buffer, size_t nbytes = MAX_WRITE_SIZE)
|
||||
{ return m_device->sendBytes(buffer, nbytes); }
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,6 +64,20 @@ public:
|
||||
return item;
|
||||
}
|
||||
|
||||
T next()
|
||||
{
|
||||
pthread_mutex_lock(&m_mutex);
|
||||
|
||||
while (m_queue.size() == 0)
|
||||
pthread_cond_wait(&m_cond, &m_mutex);
|
||||
|
||||
T item = m_queue.front();
|
||||
|
||||
pthread_mutex_unlock(&m_mutex);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
int size()
|
||||
{
|
||||
pthread_mutex_lock(&m_mutex);
|
||||
|
||||
Reference in New Issue
Block a user