cloud test
This commit is contained in:
@@ -18,11 +18,9 @@
|
||||
*/
|
||||
|
||||
#include "picloudserver.h"
|
||||
#include "piethernet.h"
|
||||
|
||||
|
||||
PICloudServer::PICloudServer(const PIString & path, PIIODevice::DeviceMode mode) : PIIODevice(path, mode) {
|
||||
eth = new PIEthernet(PIEthernet::TCP_Client);
|
||||
PICloudServer::PICloudServer(const PIString & path, PIIODevice::DeviceMode mode) : PIIODevice(path, mode), eth(PIEthernet::TCP_Client) {
|
||||
}
|
||||
|
||||
|
||||
@@ -33,18 +31,28 @@ PICloudServer::~PICloudServer() {
|
||||
|
||||
bool PICloudServer::openDevice() {
|
||||
piCout << "PICloudServer open device" << path();
|
||||
bool op = eth->connect(path(), false);
|
||||
bool op = eth.connect(path(), false);
|
||||
if (op) {
|
||||
CONNECTL(eth, disconnected, [this](bool){eth->connect(path());});
|
||||
eth->startThreadedRead();
|
||||
return true;
|
||||
} else {
|
||||
eth.close();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool PICloudServer::closeDevice() {
|
||||
eth->stopThreadedRead();
|
||||
return eth->close();
|
||||
return eth.close();
|
||||
}
|
||||
|
||||
|
||||
int PICloudServer::readDevice(void * read_to, int max_size) {
|
||||
return eth.read(read_to, max_size);
|
||||
}
|
||||
|
||||
|
||||
int PICloudServer::writeDevice(const void * data, int max_size) {
|
||||
return eth.write(data, max_size);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user