remove debug picout from cloud
This commit is contained in:
@@ -43,12 +43,12 @@ PICloudClient::PICloudClient(const PIString & path, PIIODevice::DeviceMode mode)
|
||||
|
||||
|
||||
PICloudClient::~PICloudClient() {
|
||||
piCoutObj << "~PICloudClient() ..." << this;
|
||||
//piCoutObj << "~PICloudClient() ..." << this;
|
||||
is_deleted = true;
|
||||
stopAndWait();
|
||||
close();
|
||||
internalDisconnect();
|
||||
piCoutObj << "~PICloudClient() done" << this;
|
||||
//piCoutObj << "~PICloudClient() done" << this;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,14 +70,14 @@ void PICloudClient::interrupt() {
|
||||
|
||||
|
||||
bool PICloudClient::openDevice() {
|
||||
piCoutObj << "open";// << path();
|
||||
//piCoutObj << "open";// << path();
|
||||
bool op = eth.connect(PIEthernet::Address::resolve(path()), false);
|
||||
if (op) {
|
||||
mutex_connect.lock();
|
||||
eth.startThreadedRead();
|
||||
piCoutObj << "connecting...";
|
||||
//piCoutObj << "connecting...";
|
||||
bool conn_ok = cond_connect.waitFor(mutex_connect, (int)eth.readTimeout());
|
||||
piCoutObj << "conn_ok" << conn_ok << is_connected;
|
||||
//piCoutObj << "conn_ok" << conn_ok << is_connected;
|
||||
mutex_connect.unlock();
|
||||
if (!conn_ok) {
|
||||
mutex_connect.lock();
|
||||
@@ -106,7 +106,7 @@ bool PICloudClient::closeDevice() {
|
||||
|
||||
ssize_t PICloudClient::readDevice(void * read_to, ssize_t max_size) {
|
||||
if (is_deleted || max_size <= 0) return -1;
|
||||
piCoutObj << "readDevice ...";
|
||||
//piCoutObj << "readDevice ...";
|
||||
if (!is_connected && eth.isClosed()) openDevice();
|
||||
ssize_t sz = -1;
|
||||
mutex_buff.lock();
|
||||
@@ -122,20 +122,20 @@ ssize_t PICloudClient::readDevice(void * read_to, ssize_t max_size) {
|
||||
}
|
||||
mutex_buff.unlock();
|
||||
if (!is_connected) opened_ = false;
|
||||
piCoutObj << "readDevice done" << sz;
|
||||
//piCoutObj << "readDevice done" << sz;
|
||||
return sz;
|
||||
}
|
||||
|
||||
|
||||
ssize_t PICloudClient::writeDevice(const void * data, ssize_t size) {
|
||||
if (is_deleted || !is_connected) return -1;
|
||||
piCoutObj << "writeDevice" << size;
|
||||
//piCoutObj << "writeDevice" << size;
|
||||
return tcp.sendData(PIByteArray(data, size));
|
||||
}
|
||||
|
||||
|
||||
void PICloudClient::internalDisconnect() {
|
||||
piCoutObj << "internalDisconnect";
|
||||
//piCoutObj << "internalDisconnect";
|
||||
is_connected = false;
|
||||
cond_buff.notifyOne();
|
||||
cond_connect.notifyOne();
|
||||
@@ -147,7 +147,7 @@ void PICloudClient::internalDisconnect() {
|
||||
void PICloudClient::_readed(PIByteArray & ba) {
|
||||
if (is_deleted) return;
|
||||
PIPair<PICloud::TCP::Type, PICloud::TCP::Role> hdr = tcp.parseHeader(ba);
|
||||
piCoutObj << "_readed" << ba.size() << hdr.first << hdr.second;
|
||||
//piCoutObj << "_readed" << ba.size() << hdr.first << hdr.second;
|
||||
if (hdr.second == tcp.role()) {
|
||||
switch (hdr.first) {
|
||||
case PICloud::TCP::Connect:
|
||||
@@ -167,6 +167,11 @@ void PICloudClient::_readed(PIByteArray & ba) {
|
||||
case PICloud::TCP::Data:
|
||||
if (is_connected) {
|
||||
mutex_buff.lock();
|
||||
if (buff.size_s() > threadedReadBufferSize()) {
|
||||
piCoutObj << "Error: buffer overflow, drop" << ba.size() << "bytes";
|
||||
mutex_buff.unlock();
|
||||
return;
|
||||
}
|
||||
buff.append(ba);
|
||||
mutex_buff.unlock();
|
||||
cond_buff.notifyOne();
|
||||
@@ -177,6 +182,6 @@ void PICloudClient::_readed(PIByteArray & ba) {
|
||||
}
|
||||
//piCoutObj << "readed" << ba.toHex();
|
||||
}
|
||||
while (buff.size_s() > threadedReadBufferSize()) piMSleep(100); // FIXME: sleep here is bad
|
||||
piCoutObj << "_readed done";
|
||||
if (buff.size_s() > threadedReadBufferSize()) piMSleep(100); // FIXME: sleep here is bad
|
||||
//piCoutObj << "_readed done";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user