|
@@ -5,6 +5,10 @@
|
|
#include "picofunctions.h"
|
|
#include "picofunctions.h"
|
|
#include "pugiconfig.hpp"
|
|
#include "pugiconfig.hpp"
|
|
#include "pugixml.hpp"
|
|
#include "pugixml.hpp"
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+#include "simplecout.hpp"
|
|
|
|
+=======
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
#include "parser.hpp"
|
|
#include "parser.hpp"
|
|
#include "src/ActiveSocket.h"
|
|
#include "src/ActiveSocket.h"
|
|
|
|
|
|
@@ -15,6 +19,15 @@ using namespace std;
|
|
std::vector<std::string> split(const std::string& s, const std::string& delimiter) {
|
|
std::vector<std::string> split(const std::string& s, const std::string& delimiter) {
|
|
std::vector<std::string> tokens;
|
|
std::vector<std::string> tokens;
|
|
size_t pos = 0;
|
|
size_t pos = 0;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ std::string token;
|
|
|
|
+ while ((pos = s.find(delimiter)) != std::string::npos) {
|
|
|
|
+ token = s.substr(0, pos);
|
|
|
|
+ tokens.push_back(token);
|
|
|
|
+ s.erase(0, pos + delimiter.length());
|
|
|
|
+ }
|
|
|
|
+ tokens.push_back(s);
|
|
|
|
+=======
|
|
std::string temp = s;
|
|
std::string temp = s;
|
|
std::string token;
|
|
std::string token;
|
|
while ((pos = temp.find(delimiter)) != std::string::npos) {
|
|
while ((pos = temp.find(delimiter)) != std::string::npos) {
|
|
@@ -23,6 +36,7 @@ std::vector<std::string> split(const std::string& s, const std::string& delimite
|
|
temp.erase(0, pos + delimiter.length());
|
|
temp.erase(0, pos + delimiter.length());
|
|
}
|
|
}
|
|
tokens.push_back(temp);
|
|
tokens.push_back(temp);
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
|
|
|
|
return tokens;
|
|
return tokens;
|
|
}
|
|
}
|
|
@@ -50,7 +64,11 @@ class PicoLocalClient
|
|
cerr << "Failed to send data to socket" << endl;
|
|
cerr << "Failed to send data to socket" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ if(socket->Receive(rcvbuf, sizeof(rcvbuf)) == -1)
|
|
|
|
+=======
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
{
|
|
{
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
return -1;
|
|
return -1;
|
|
@@ -59,7 +77,11 @@ class PicoLocalClient
|
|
uint32_t bytes_received = socket->GetBytesReceived();
|
|
uint32_t bytes_received = socket->GetBytesReceived();
|
|
|
|
|
|
if(bytes_received == 0)
|
|
if(bytes_received == 0)
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ {
|
|
|
|
+=======
|
|
{
|
|
{
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
cerr << "Server disconnected" << endl;
|
|
cerr << "Server disconnected" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
@@ -85,7 +107,11 @@ class PicoLocalClient
|
|
cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+=======
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
}
|
|
}
|
|
else if(rcvbuf[1] != 0xC1)
|
|
else if(rcvbuf[1] != 0xC1)
|
|
{
|
|
{
|
|
@@ -110,7 +136,11 @@ class PicoLocalClient
|
|
cerr << "Failed to send data to socket" << endl;
|
|
cerr << "Failed to send data to socket" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ if(socket->Receive(rcvbuf, sizeof(rcvbuf)) == -1)
|
|
|
|
+=======
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
{
|
|
{
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
return -1;
|
|
return -1;
|
|
@@ -119,7 +149,11 @@ class PicoLocalClient
|
|
uint32_t bytes_received = socket->GetBytesReceived();
|
|
uint32_t bytes_received = socket->GetBytesReceived();
|
|
|
|
|
|
if(bytes_received == 0)
|
|
if(bytes_received == 0)
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ {
|
|
|
|
+=======
|
|
{
|
|
{
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
cerr << "Server disconnected" << endl;
|
|
cerr << "Server disconnected" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
@@ -145,7 +179,11 @@ class PicoLocalClient
|
|
cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+=======
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
}
|
|
}
|
|
else if(rcvbuf[1] != 0xC2)
|
|
else if(rcvbuf[1] != 0xC2)
|
|
{
|
|
{
|
|
@@ -154,7 +192,11 @@ class PicoLocalClient
|
|
}
|
|
}
|
|
|
|
|
|
cout << "Pico device configured" << endl;
|
|
cout << "Pico device configured" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ return 0;
|
|
|
|
+=======
|
|
return 0;
|
|
return 0;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
}
|
|
}
|
|
|
|
|
|
int pico_set_params(uint32_t* apoints, uint32_t* times, uint32_t sample_rate, uint32_t number_channels, uint32_t size)
|
|
int pico_set_params(uint32_t* apoints, uint32_t* times, uint32_t sample_rate, uint32_t number_channels, uint32_t size)
|
|
@@ -172,15 +214,26 @@ class PicoLocalClient
|
|
cerr << "Failed to send data to socket" << endl;
|
|
cerr << "Failed to send data to socket" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ if(socket->Receive(rcvbuf, sizeof(rcvbuf)) == -1)
|
|
|
|
+=======
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
{
|
|
{
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+
|
|
|
|
+ uint32_t bytes_received = socket->GetBytesReceived();
|
|
|
|
+ if(bytes_received == 0)
|
|
|
|
+ {
|
|
|
|
+=======
|
|
|
|
|
|
uint32_t bytes_received = socket->GetBytesReceived();
|
|
uint32_t bytes_received = socket->GetBytesReceived();
|
|
if(bytes_received == 0)
|
|
if(bytes_received == 0)
|
|
{
|
|
{
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
cerr << "Server disconnected" << endl;
|
|
cerr << "Server disconnected" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
@@ -227,7 +280,215 @@ class PicoLocalClient
|
|
cerr << "Failed to send data to socket" << endl;
|
|
cerr << "Failed to send data to socket" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ if(socket->Receive(rcvbuf, sizeof(rcvbuf)) == -1)
|
|
|
|
+=======
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
|
|
+ {
|
|
|
|
+ cerr << "Failed to receive data from socket" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ uint32_t bytes_received = socket->GetBytesReceived();
|
|
|
|
+ if(bytes_received == 0)
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ {
|
|
|
|
+ cerr << "Server disconnected" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ if(bytes_received < 2)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid buffer size" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ if(rcvbuf[0] != 0xAA)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid magic number" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(rcvbuf[1] == 0xFF)
|
|
|
|
+ {
|
|
|
|
+ if(bytes_received < 7)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid buffer size" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
|
|
+ memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
|
|
+ memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
|
|
+ cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+ }
|
|
|
|
+ else if(rcvbuf[1] != 0xC3)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid command callback" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ cout << "Pico device closed" << endl;
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int pico_get_current_params()
|
|
|
|
+ {
|
|
|
|
+ sndbuf[0] = 0xAA;
|
|
|
|
+ sndbuf[1] = 0x04;
|
|
|
|
+ if(socket->Send(sndbuf, 2) == -1)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Failed to send data to socket" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ if(socket->Receive(rcvbuf, sizeof(rcvbuf)) == -1)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Failed to receive data from socket" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ uint32_t bytes_received = socket->GetBytesReceived();
|
|
|
|
+ if(bytes_received == 0)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Server disconnected" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ if(bytes_received < 2)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid buffer size" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ if(rcvbuf[0] != 0xAA)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid magic number" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(rcvbuf[1] == 0xFF)
|
|
|
|
+ {
|
|
|
|
+ if(bytes_received < 7)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid buffer size" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
|
|
+ memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
|
|
+ memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
|
|
+ cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+ }
|
|
|
|
+ else if(rcvbuf[1] != 0xC4)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid command callback" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(bytes_received < 18)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid buffer size" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ uint32_t size;
|
|
|
|
+ memcpy(&size, rcvbuf + 2, sizeof(uint32_t));
|
|
|
|
+ if(size < 1)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid data size" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ uint32_t* apoints = new uint32_t[size];
|
|
|
|
+ memcpy(apoints, rcvbuf + 6, size * sizeof(uint32_t));
|
|
|
|
+ for(uint32_t i = 0; i < size; ++i)
|
|
|
|
+ {
|
|
|
|
+ cout << "apoints[" << i << "] = " << std::dec << apoints[i] << endl;
|
|
|
|
+ }
|
|
|
|
+ uint32_t* atimes = new uint32_t[size];
|
|
|
|
+ memcpy(atimes, rcvbuf + 6 + size * sizeof(uint32_t), size * sizeof(uint32_t));
|
|
|
|
+ for(uint32_t i = 0; i < size; ++i)
|
|
|
|
+ {
|
|
|
|
+ cout << "atimes[" << i << "] = " << std::dec << atimes[i] << endl;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ uint32_t sample_rate = 0;
|
|
|
|
+ memcpy(&sample_rate, rcvbuf + 6 + 2 * size * sizeof(uint32_t), sizeof(uint32_t));
|
|
|
|
+ cout << "sample_rate = " << std::dec << sample_rate << endl;
|
|
|
|
+
|
|
|
|
+ uint32_t number_channels = 0;
|
|
|
|
+ memcpy(&number_channels, rcvbuf + 10 + 2 * size * sizeof(uint32_t), sizeof(uint32_t));
|
|
|
|
+ cout << "number_channels = " << std::dec << number_channels << endl;
|
|
|
|
+
|
|
|
|
+ cout << "Pico device parameters retrieved" << endl;
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int pico_probe()
|
|
|
|
+ {
|
|
|
|
+ sndbuf[0] = 0xAA;
|
|
|
|
+ sndbuf[1] = 0x05;
|
|
|
|
+ if(socket->Send(sndbuf, 2) == -1)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Failed to send data to socket" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ if(socket->Receive(rcvbuf, sizeof(rcvbuf)) == -1)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Failed to receive data from socket" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ uint32_t bytes_received = socket->GetBytesReceived();
|
|
|
|
+ if(bytes_received == 0)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Server disconnected" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ if(bytes_received < 2)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid buffer size" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ if(rcvbuf[0] != 0xAA)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid magic number" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(rcvbuf[1] == 0xFF)
|
|
|
|
+ {
|
|
|
|
+ if(bytes_received < 7)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid buffer size" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
|
|
+ memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
|
|
+ memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
|
|
+ cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+ }
|
|
|
|
+ else if(rcvbuf[1] != 0xC5)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid command callback" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ cout << "Pico device probe completed" << endl;
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int pico_set_points(uint32_t* points, uint32_t size)
|
|
|
|
+ {
|
|
|
|
+ sndbuf[0] = 0xAA;
|
|
|
|
+ sndbuf[1] = 0x06;
|
|
|
|
+ memcpy(sndbuf + 2, &size, sizeof(uint32_t));
|
|
|
|
+ memcpy(sndbuf + 6, points, size * sizeof(uint32_t));
|
|
|
|
+
|
|
|
|
+ if(socket->Send(sndbuf, size * sizeof(uint32_t) + 6) == -1)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Failed to send data to socket" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ if(socket->Receive(rcvbuf, sizeof(rcvbuf)) == -1)
|
|
{
|
|
{
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
return -1;
|
|
return -1;
|
|
@@ -235,7 +496,67 @@ class PicoLocalClient
|
|
|
|
|
|
uint32_t bytes_received = socket->GetBytesReceived();
|
|
uint32_t bytes_received = socket->GetBytesReceived();
|
|
if(bytes_received == 0)
|
|
if(bytes_received == 0)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Server disconnected" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ if(bytes_received < 2)
|
|
{
|
|
{
|
|
|
|
+ cerr << "Invalid buffer size" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ if(rcvbuf[0] != 0xAA)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid magic number" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(rcvbuf[1] == 0xFF)
|
|
|
|
+ {
|
|
|
|
+ if(bytes_received < 7)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid buffer size" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
|
|
+ memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
|
|
+ memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
|
|
+ cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+ }
|
|
|
|
+ else if(rcvbuf[1] != 0xC6)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid command callback" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ cout << "Pico device points set" << endl;
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int pico_set_sample_rate(uint32_t sample_rate)
|
|
|
|
+ {
|
|
|
|
+ sndbuf[0] = 0xAA;
|
|
|
|
+ sndbuf[1] = 0x07;
|
|
|
|
+ memcpy(sndbuf + 2, &sample_rate, sizeof(uint32_t));
|
|
|
|
+
|
|
|
|
+ if(socket->Send(sndbuf, sizeof(uint32_t) + 6) == -1)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Failed to send data to socket" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ if(socket->Receive(rcvbuf, sizeof(rcvbuf)) == -1)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Failed to receive data from socket" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ uint32_t bytes_received = socket->GetBytesReceived();
|
|
|
|
+ if(bytes_received == 0)
|
|
|
|
+ {
|
|
|
|
+=======
|
|
|
|
+ {
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
cerr << "Server disconnected" << endl;
|
|
cerr << "Server disconnected" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
@@ -262,13 +583,33 @@ class PicoLocalClient
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+return 0;
|
|
|
|
+ }
|
|
|
|
+ else if(rcvbuf[1] != 0xC7)
|
|
|
|
+=======
|
|
}
|
|
}
|
|
else if(rcvbuf[1] != 0xC3)
|
|
else if(rcvbuf[1] != 0xC3)
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
{
|
|
{
|
|
cerr << "Invalid command callback" << endl;
|
|
cerr << "Invalid command callback" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ cout << "Pico device sample rate set" << endl;
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int pico_set_times(uint32_t* times, uint32_t size)
|
|
|
|
+ {
|
|
|
|
+ sndbuf[0] = 0xAA;
|
|
|
|
+ sndbuf[1] = 0x08;
|
|
|
|
+ memcpy(sndbuf + 2, &size, sizeof(uint32_t));
|
|
|
|
+ memcpy(sndbuf + 6, times, size * sizeof(uint32_t));
|
|
|
|
+
|
|
|
|
+ if(socket->Send(sndbuf, size * sizeof(uint32_t) + 6) == -1)
|
|
|
|
+=======
|
|
cout << "Pico device closed" << endl;
|
|
cout << "Pico device closed" << endl;
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -278,11 +619,16 @@ class PicoLocalClient
|
|
sndbuf[0] = 0xAA;
|
|
sndbuf[0] = 0xAA;
|
|
sndbuf[1] = 0x04;
|
|
sndbuf[1] = 0x04;
|
|
if(socket->Send(sndbuf, 2) == -1)
|
|
if(socket->Send(sndbuf, 2) == -1)
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
{
|
|
{
|
|
cerr << "Failed to send data to socket" << endl;
|
|
cerr << "Failed to send data to socket" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ if(socket->Receive(rcvbuf, sizeof(rcvbuf)) == -1)
|
|
|
|
+=======
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
{
|
|
{
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
return -1;
|
|
return -1;
|
|
@@ -290,7 +636,11 @@ class PicoLocalClient
|
|
|
|
|
|
uint32_t bytes_received = socket->GetBytesReceived();
|
|
uint32_t bytes_received = socket->GetBytesReceived();
|
|
if(bytes_received == 0)
|
|
if(bytes_received == 0)
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ {
|
|
|
|
+=======
|
|
{
|
|
{
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
cerr << "Server disconnected" << endl;
|
|
cerr << "Server disconnected" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
@@ -316,6 +666,9 @@ class PicoLocalClient
|
|
cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+=======
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
}
|
|
}
|
|
else if(rcvbuf[1] != 0xC4)
|
|
else if(rcvbuf[1] != 0xC4)
|
|
@@ -581,6 +934,7 @@ class PicoLocalClient
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
}
|
|
}
|
|
else if(rcvbuf[1] != 0xC8)
|
|
else if(rcvbuf[1] != 0xC8)
|
|
{
|
|
{
|
|
@@ -589,7 +943,11 @@ class PicoLocalClient
|
|
}
|
|
}
|
|
|
|
|
|
cout << "Pico device times set" << endl;
|
|
cout << "Pico device times set" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ return 0;
|
|
|
|
+=======
|
|
return 0;
|
|
return 0;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
}
|
|
}
|
|
|
|
|
|
int pico_configure_channels(const uint32_t number_channels, uint8_t trigger_channel, int32_t direction, uint16_t threshold, int16_t autoTrigger_ms)
|
|
int pico_configure_channels(const uint32_t number_channels, uint8_t trigger_channel, int32_t direction, uint16_t threshold, int16_t autoTrigger_ms)
|
|
@@ -607,7 +965,11 @@ class PicoLocalClient
|
|
cerr << "Failed to send data to socket" << endl;
|
|
cerr << "Failed to send data to socket" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ if(socket->Receive(rcvbuf, sizeof(rcvbuf)) == -1)
|
|
|
|
+=======
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
{
|
|
{
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
return -1;
|
|
return -1;
|
|
@@ -615,7 +977,11 @@ class PicoLocalClient
|
|
|
|
|
|
uint32_t bytes_received = socket->GetBytesReceived();
|
|
uint32_t bytes_received = socket->GetBytesReceived();
|
|
if(bytes_received == 0)
|
|
if(bytes_received == 0)
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ {
|
|
|
|
+=======
|
|
{
|
|
{
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
cerr << "Server disconnected" << endl;
|
|
cerr << "Server disconnected" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
@@ -641,7 +1007,11 @@ class PicoLocalClient
|
|
cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+=======
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
}
|
|
}
|
|
else if(rcvbuf[1] != 0xC9)
|
|
else if(rcvbuf[1] != 0xC9)
|
|
{
|
|
{
|
|
@@ -650,7 +1020,11 @@ class PicoLocalClient
|
|
}
|
|
}
|
|
|
|
|
|
cout << "Pico device channels configured" << endl;
|
|
cout << "Pico device channels configured" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ return 0;
|
|
|
|
+=======
|
|
return 0;
|
|
return 0;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
}
|
|
}
|
|
|
|
|
|
int pico_begin_measurement()
|
|
int pico_begin_measurement()
|
|
@@ -663,15 +1037,26 @@ class PicoLocalClient
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ if(socket->Receive(rcvbuf, sizeof(rcvbuf)) == -1)
|
|
|
|
+=======
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
{
|
|
{
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+
|
|
|
|
+ uint32_t bytes_received = socket->GetBytesReceived();
|
|
|
|
+ if(bytes_received == 0)
|
|
|
|
+ {
|
|
|
|
+=======
|
|
|
|
|
|
uint32_t bytes_received = socket->GetBytesReceived();
|
|
uint32_t bytes_received = socket->GetBytesReceived();
|
|
if(bytes_received == 0)
|
|
if(bytes_received == 0)
|
|
{
|
|
{
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
cerr << "Server disconnected" << endl;
|
|
cerr << "Server disconnected" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
@@ -697,7 +1082,11 @@ class PicoLocalClient
|
|
cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+=======
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
}
|
|
}
|
|
else if(rcvbuf[1] != 0xCA)
|
|
else if(rcvbuf[1] != 0xCA)
|
|
{
|
|
{
|
|
@@ -707,17 +1096,27 @@ class PicoLocalClient
|
|
cout << "Pico device measurement started" << endl;
|
|
cout << "Pico device measurement started" << endl;
|
|
cout << "Measurement in progress..." << endl;
|
|
cout << "Measurement in progress..." << endl;
|
|
|
|
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ while(rcvbuf[1] != 0xCB)
|
|
|
|
+ {
|
|
|
|
+ if(socket->Receive(rcvbuf, sizeof(rcvbuf)) == -1)
|
|
|
|
+=======
|
|
bool end_of_data = false;
|
|
bool end_of_data = false;
|
|
while(!end_of_data)
|
|
while(!end_of_data)
|
|
{
|
|
{
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
{
|
|
{
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
bytes_received = socket->GetBytesReceived();
|
|
bytes_received = socket->GetBytesReceived();
|
|
if(bytes_received == 0)
|
|
if(bytes_received == 0)
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ {
|
|
|
|
+=======
|
|
{
|
|
{
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
cerr << "Server disconnected" << endl;
|
|
cerr << "Server disconnected" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
@@ -743,6 +1142,11 @@ class PicoLocalClient
|
|
cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+ }
|
|
|
|
+ else if(rcvbuf[1] != 0xCA)
|
|
|
|
+=======
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -756,6 +1160,7 @@ class PicoLocalClient
|
|
cout << "Measurement in progress..." << endl;
|
|
cout << "Measurement in progress..." << endl;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
{
|
|
{
|
|
cerr << "Invalid command callback" << endl;
|
|
cerr << "Invalid command callback" << endl;
|
|
return -1;
|
|
return -1;
|
|
@@ -777,7 +1182,11 @@ class PicoLocalClient
|
|
cerr << "Failed to send data to socket" << endl;
|
|
cerr << "Failed to send data to socket" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ if(socket->Receive(rcvbuf, sizeof(rcvbuf)) == -1)
|
|
|
|
+=======
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
{
|
|
{
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
return -1;
|
|
return -1;
|
|
@@ -785,7 +1194,11 @@ class PicoLocalClient
|
|
|
|
|
|
uint32_t bytes_received = socket->GetBytesReceived();
|
|
uint32_t bytes_received = socket->GetBytesReceived();
|
|
if(bytes_received == 0)
|
|
if(bytes_received == 0)
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ {
|
|
|
|
+=======
|
|
{
|
|
{
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
cerr << "Server disconnected" << endl;
|
|
cerr << "Server disconnected" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
@@ -799,7 +1212,11 @@ class PicoLocalClient
|
|
cerr << "Invalid magic number" << endl;
|
|
cerr << "Invalid magic number" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+
|
|
|
|
+=======
|
|
|
|
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
if(rcvbuf[1] == 0xFF)
|
|
if(rcvbuf[1] == 0xFF)
|
|
{
|
|
{
|
|
if(bytes_received < 7)
|
|
if(bytes_received < 7)
|
|
@@ -811,7 +1228,11 @@ class PicoLocalClient
|
|
cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+=======
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
}
|
|
}
|
|
else if(rcvbuf[1] != 0xCE)
|
|
else if(rcvbuf[1] != 0xCE)
|
|
{
|
|
{
|
|
@@ -832,7 +1253,11 @@ class PicoLocalClient
|
|
cerr << "Failed to send data to socket" << endl;
|
|
cerr << "Failed to send data to socket" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ if(socket->Receive(rcvbuf, sizeof(rcvbuf)) == -1)
|
|
|
|
+=======
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
if(socket->Receive(MAX_PACKET, rcvbuf) == -1)
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
{
|
|
{
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
cerr << "Failed to receive data from socket" << endl;
|
|
return -1;
|
|
return -1;
|
|
@@ -840,7 +1265,11 @@ class PicoLocalClient
|
|
|
|
|
|
uint32_t bytes_received = socket->GetBytesReceived();
|
|
uint32_t bytes_received = socket->GetBytesReceived();
|
|
if(bytes_received == 0)
|
|
if(bytes_received == 0)
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ {
|
|
|
|
+=======
|
|
{
|
|
{
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
cerr << "Server disconnected" << endl;
|
|
cerr << "Server disconnected" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
@@ -866,7 +1295,11 @@ class PicoLocalClient
|
|
cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
cerr << "Error at ADC: " << std::hex << rcvbuf[2] << endl;
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_state, rcvbuf + 2, sizeof(uint8_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
memcpy(&error_code, rcvbuf + 3, sizeof(uint32_t));
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+=======
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
cerr << "Error code: " << std::hex << error_code << " " << return_fun(error_code) << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
}
|
|
}
|
|
else if(rcvbuf[1] != 0xCD)
|
|
else if(rcvbuf[1] != 0xCD)
|
|
{
|
|
{
|
|
@@ -880,27 +1313,43 @@ class PicoLocalClient
|
|
|
|
|
|
int get_command()
|
|
int get_command()
|
|
{
|
|
{
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ if(socket->Receive(sndbuf, sizeof(sndbuf)) != 0)
|
|
|
|
+ {
|
|
|
|
+ std::getline(std::cin, line_edit);
|
|
|
|
+=======
|
|
if(true)
|
|
if(true)
|
|
{
|
|
{
|
|
cout << "cmd$ ";
|
|
cout << "cmd$ ";
|
|
std::getline(std::cin, line_edit);
|
|
std::getline(std::cin, line_edit);
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
tokens = split(line_edit, " ");
|
|
tokens = split(line_edit, " ");
|
|
|
|
|
|
if(tokens.size() < 1)
|
|
if(tokens.size() < 1)
|
|
{
|
|
{
|
|
cerr << "Invalid command" << endl;
|
|
cerr << "Invalid command" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(tokens[0] = "open")
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
if(tokens[0] == "open")
|
|
if(tokens[0] == "open")
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
{
|
|
{
|
|
if(pico_open() != 0)
|
|
if(pico_open() != 0)
|
|
{
|
|
{
|
|
cerr << "Failed to open pico device" << endl;
|
|
cerr << "Failed to open pico device" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -909,13 +1358,19 @@ class PicoLocalClient
|
|
if(tokens.size() < 2)
|
|
if(tokens.size() < 2)
|
|
{
|
|
{
|
|
cerr << "Invalid command" << endl;
|
|
cerr << "Invalid command" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
if(pico_xml_config(tokens[1]) != 0)
|
|
if(pico_xml_config(tokens[1]) != 0)
|
|
{
|
|
{
|
|
cerr << "Failed to configure pico device" << endl;
|
|
cerr << "Failed to configure pico device" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -924,12 +1379,25 @@ class PicoLocalClient
|
|
if(tokens.size() < 5)
|
|
if(tokens.size() < 5)
|
|
{
|
|
{
|
|
cerr << "Invalid command" << endl;
|
|
cerr << "Invalid command" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
std::vector<uint32_t> points;
|
|
std::vector<uint32_t> points;
|
|
std::vector<uint32_t> times;
|
|
std::vector<uint32_t> times;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ uint32_t sample_rate = std::stoi(tokens[2]);
|
|
|
|
+ uint32_t number_channels = std::stoi(tokens[3]);
|
|
|
|
+ uint32_t size = std::stoi(tokens[4]);
|
|
|
|
+ points = string_to_vector(points);
|
|
|
|
+ times = string_to_vector(times);
|
|
|
|
+ if(points.size() != size || times.size() != size)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid data size" << endl;
|
|
|
|
+=======
|
|
|
|
|
|
points = string_to_vector(tokens[1]);
|
|
points = string_to_vector(tokens[1]);
|
|
times = string_to_vector(tokens[2]);
|
|
times = string_to_vector(tokens[2]);
|
|
@@ -941,12 +1409,16 @@ class PicoLocalClient
|
|
{
|
|
{
|
|
cerr << "Invalid data size" << endl;
|
|
cerr << "Invalid data size" << endl;
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
if(pico_set_params(points.data(), times.data(), sample_rate, number_channels, size) != 0)
|
|
if(pico_set_params(points.data(), times.data(), sample_rate, number_channels, size) != 0)
|
|
{
|
|
{
|
|
cerr << "Failed to set pico device parameters" << endl;
|
|
cerr << "Failed to set pico device parameters" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
return 0;
|
|
return 0;
|
|
@@ -956,7 +1428,10 @@ class PicoLocalClient
|
|
if(pico_close() != 0)
|
|
if(pico_close() != 0)
|
|
{
|
|
{
|
|
cerr << "Failed to close pico device" << endl;
|
|
cerr << "Failed to close pico device" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -965,7 +1440,10 @@ class PicoLocalClient
|
|
if(pico_exit() != 0)
|
|
if(pico_exit() != 0)
|
|
{
|
|
{
|
|
cerr << "Failed to exit pico device" << endl;
|
|
cerr << "Failed to exit pico device" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -976,7 +1454,10 @@ class PicoLocalClient
|
|
if(pico_get_current_params() != 0)
|
|
if(pico_get_current_params() != 0)
|
|
{
|
|
{
|
|
cerr << "Failed to get pico device parameters" << endl;
|
|
cerr << "Failed to get pico device parameters" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -985,7 +1466,10 @@ class PicoLocalClient
|
|
if(pico_probe() != 0)
|
|
if(pico_probe() != 0)
|
|
{
|
|
{
|
|
cerr << "Failed to probe pico device" << endl;
|
|
cerr << "Failed to probe pico device" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -994,6 +1478,16 @@ class PicoLocalClient
|
|
if(tokens.size() < 3)
|
|
if(tokens.size() < 3)
|
|
{
|
|
{
|
|
cerr << "Invalid command" << endl;
|
|
cerr << "Invalid command" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ uint32_t size = std::stoi(tokens[2]);
|
|
|
|
+ std::vector<uint32_t> points = string_to_vector(points);
|
|
|
|
+ if(points.size() != size)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid data size" << endl;
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
@@ -1005,12 +1499,16 @@ class PicoLocalClient
|
|
{
|
|
{
|
|
cerr << "Invalid data size" << endl;
|
|
cerr << "Invalid data size" << endl;
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
if(pico_set_points(points.data(), size) != 0)
|
|
if(pico_set_points(points.data(), size) != 0)
|
|
{
|
|
{
|
|
cerr << "Failed to set pico device points" << endl;
|
|
cerr << "Failed to set pico device points" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1019,7 +1517,10 @@ class PicoLocalClient
|
|
if(tokens.size() < 2)
|
|
if(tokens.size() < 2)
|
|
{
|
|
{
|
|
cerr << "Invalid command" << endl;
|
|
cerr << "Invalid command" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1027,7 +1528,10 @@ class PicoLocalClient
|
|
if(pico_set_sample_rate(sample_rate) != 0)
|
|
if(pico_set_sample_rate(sample_rate) != 0)
|
|
{
|
|
{
|
|
cerr << "Failed to set pico device sample rate" << endl;
|
|
cerr << "Failed to set pico device sample rate" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1036,6 +1540,16 @@ class PicoLocalClient
|
|
if(tokens.size() < 3)
|
|
if(tokens.size() < 3)
|
|
{
|
|
{
|
|
cerr << "Invalid command" << endl;
|
|
cerr << "Invalid command" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ uint32_t size = std::stoi(tokens[2]);
|
|
|
|
+ std::vector<uint32_t> times = string_to_vector(times);
|
|
|
|
+ if(times.size() != size)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Invalid data size" << endl;
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
@@ -1046,12 +1560,16 @@ class PicoLocalClient
|
|
{
|
|
{
|
|
cerr << "Invalid data size" << endl;
|
|
cerr << "Invalid data size" << endl;
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
if(pico_set_times(times.data(), size) != 0)
|
|
if(pico_set_times(times.data(), size) != 0)
|
|
{
|
|
{
|
|
cerr << "Failed to set pico device times" << endl;
|
|
cerr << "Failed to set pico device times" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1060,7 +1578,10 @@ class PicoLocalClient
|
|
if(tokens.size() < 6)
|
|
if(tokens.size() < 6)
|
|
{
|
|
{
|
|
cerr << "Invalid command" << endl;
|
|
cerr << "Invalid command" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
uint32_t number_channels = std::stoi(tokens[1]); // number of channels (1-8)
|
|
uint32_t number_channels = std::stoi(tokens[1]); // number of channels (1-8)
|
|
@@ -1071,7 +1592,10 @@ class PicoLocalClient
|
|
if(pico_configure_channels(number_channels, trigger_channel, direction, threshold, autoTrigger_ms) != 0)
|
|
if(pico_configure_channels(number_channels, trigger_channel, direction, threshold, autoTrigger_ms) != 0)
|
|
{
|
|
{
|
|
cerr << "Failed to configure pico device channels" << endl;
|
|
cerr << "Failed to configure pico device channels" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1080,7 +1604,10 @@ class PicoLocalClient
|
|
if(pico_begin_measurement() != 0)
|
|
if(pico_begin_measurement() != 0)
|
|
{
|
|
{
|
|
cerr << "Failed to begin pico device measurement" << endl;
|
|
cerr << "Failed to begin pico device measurement" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1089,7 +1616,10 @@ class PicoLocalClient
|
|
if(pico_stop() != 0)
|
|
if(pico_stop() != 0)
|
|
{
|
|
{
|
|
cerr << "Failed to stop pico device measurement" << endl;
|
|
cerr << "Failed to stop pico device measurement" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1117,26 +1647,72 @@ class PicoLocalClient
|
|
else
|
|
else
|
|
{
|
|
{
|
|
cerr << "Unknown command" << endl;
|
|
cerr << "Unknown command" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+=======
|
|
cout << endl;
|
|
cout << endl;
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
|
|
|
|
int main()
|
|
int main()
|
|
{
|
|
{
|
|
cout << "Open socket" << endl;
|
|
cout << "Open socket" << endl;
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ CPassiveSocket SocketPassive(CSimpleSocket::CSocketType::SocketTypeTcp);
|
|
|
|
+ if (!SocketPassive.Initialize())
|
|
|
|
+=======
|
|
CActiveSocket SocketActive(CSimpleSocket::CSocketType::SocketTypeTcp);
|
|
CActiveSocket SocketActive(CSimpleSocket::CSocketType::SocketTypeTcp);
|
|
if (!SocketActive.Initialize())
|
|
if (!SocketActive.Initialize())
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
{
|
|
{
|
|
cerr << "Socket initialization failed" << endl;
|
|
cerr << "Socket initialization failed" << endl;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+ if(!SocketPassive.Listen("localhost", 5002))
|
|
|
|
+ {
|
|
|
|
+ cerr << "Socket listening failed" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ CActiveSocket* ClientSocket;
|
|
|
|
+
|
|
|
|
+ while(true)
|
|
|
|
+ {
|
|
|
|
+ if ((ClientSocket = SocketPassive.Accept()) != nullptr)
|
|
|
|
+ {
|
|
|
|
+ cerr << "Socket accept failed" << endl;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ cout << LogPref::Flag(INFO) << "Client connected" << endl;
|
|
|
|
+ pico_service = new PicoLocalService(ClientSocket);
|
|
|
|
+
|
|
|
|
+ while(pico_service->get_request() != 0)
|
|
|
|
+ {
|
|
|
|
+ cout << LogPref::Flag(INFO) << "Request received" << endl;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ cout << LogPref::Flag(INFO) << "Request processing finished" << endl;
|
|
|
|
+ delete pico_service;
|
|
|
|
+ pico_service = nullptr;
|
|
|
|
+
|
|
|
|
+ delete ClientSocket;
|
|
|
|
+ ClientSocket = nullptr;
|
|
|
|
+=======
|
|
if(!SocketActive.Open("127.0.0.1", 5003))
|
|
if(!SocketActive.Open("127.0.0.1", 5003))
|
|
{
|
|
{
|
|
cerr << "Socket opening failed" << endl;
|
|
cerr << "Socket opening failed" << endl;
|
|
@@ -1147,6 +1723,7 @@ int main()
|
|
|
|
|
|
while(pico_client.get_command() != 1) {
|
|
while(pico_client.get_command() != 1) {
|
|
// empty
|
|
// empty
|
|
|
|
+>>>>>>> 6a0c5e06dc737368566c8c5b45d8073a39148b99
|
|
}
|
|
}
|
|
|
|
|
|
return 0;
|
|
return 0;
|