mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Added option to stop receiving the proto replies
Former-commit-id: b15c31b8aa500b8d7253d0c2b2368eab6a11ed50
This commit is contained in:
parent
df9b33f560
commit
c96be1cf38
@ -8,7 +8,8 @@
|
||||
#include "ProtoConnection.h"
|
||||
|
||||
ProtoConnection::ProtoConnection(const std::string & a) :
|
||||
_socket()
|
||||
_socket(),
|
||||
_skipReply(false)
|
||||
{
|
||||
QString address(a.c_str());
|
||||
QStringList parts = address.split(":");
|
||||
@ -38,6 +39,11 @@ ProtoConnection::~ProtoConnection()
|
||||
_socket.close();
|
||||
}
|
||||
|
||||
void ProtoConnection::setSkipReply(bool skip)
|
||||
{
|
||||
_skipReply = skip;
|
||||
}
|
||||
|
||||
void ProtoConnection::setColor(const ColorRgb & color, int priority, int duration)
|
||||
{
|
||||
proto::HyperionRequest request;
|
||||
@ -119,13 +125,11 @@ proto::HyperionReply ProtoConnection::sendMessage(const proto::HyperionRequest &
|
||||
throw std::runtime_error("Error while writing data to host");
|
||||
}
|
||||
|
||||
/*
|
||||
// read reply data
|
||||
QByteArray serializedReply;
|
||||
length = -1;
|
||||
while (serializedReply.size() != length)
|
||||
while (length < 0 && serializedReply.size() < length+4)
|
||||
{
|
||||
std::cout << length << std::endl;
|
||||
// receive reply
|
||||
if (!_socket.waitForReadyRead())
|
||||
{
|
||||
@ -136,20 +140,22 @@ proto::HyperionReply ProtoConnection::sendMessage(const proto::HyperionRequest &
|
||||
|
||||
if (length < 0 && serializedReply.size() >= 4)
|
||||
{
|
||||
std::cout << (int) serializedReply[3] << std::endl;
|
||||
std::cout << (int) serializedReply[2] << std::endl;
|
||||
std::cout << (int) serializedReply[1] << std::endl;
|
||||
std::cout << (int) serializedReply[0] << std::endl;
|
||||
|
||||
length = (uint8_t(serializedReply[0]) << 24) | (uint8_t(serializedReply[1]) << 16) | (uint8_t(serializedReply[2]) << 8) | uint8_t(serializedReply[3]) ;
|
||||
// read the message size
|
||||
length =
|
||||
((serializedReply[0]<<24) & 0xFF000000) |
|
||||
((serializedReply[1]<<16) & 0x00FF0000) |
|
||||
((serializedReply[2]<< 8) & 0x0000FF00) |
|
||||
((serializedReply[3] ) & 0x000000FF);
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << length << std::endl;
|
||||
*/
|
||||
// parse reply data
|
||||
proto::HyperionReply reply;
|
||||
// reply.ParseFromArray(serializedReply.constData()+4, length);
|
||||
reply.ParseFromArray(serializedReply.constData()+4, length);
|
||||
|
||||
// remove data from receive buffer
|
||||
serializedReply = serializedReply.mid(length+4);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,9 @@ public:
|
||||
///
|
||||
~ProtoConnection();
|
||||
|
||||
/// Do not read reply messages from Hyperion if set to true
|
||||
void setSkipReply(bool skip);
|
||||
|
||||
///
|
||||
/// Set all leds to the specified color
|
||||
///
|
||||
@ -86,4 +89,7 @@ private:
|
||||
private:
|
||||
/// The TCP-Socket with the connection to the server
|
||||
QTcpSocket _socket;
|
||||
|
||||
/// Skip receiving reply messages from Hyperion if set
|
||||
bool _skipReply;
|
||||
};
|
||||
|
@ -81,6 +81,7 @@ int main(int argc, char** argv)
|
||||
SwitchParameter<> & argScreenshot = parameters.add<SwitchParameter<>> (0x0, "screenshot", "Take a single screenshot, save it to file and quit");
|
||||
StringParameter & argAddress = parameters.add<StringParameter> ('a', "address", "Set the address of the hyperion server [default: 127.0.0.1:19445]");
|
||||
IntParameter & argPriority = parameters.add<IntParameter> ('p', "priority", "Use the provided priority channel (the lower the number, the higher the priority) [default: 800]");
|
||||
SwitchParameter<> & argSkipReply = parameters.add<SwitchParameter<>> (0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
|
||||
SwitchParameter<> & argHelp = parameters.add<SwitchParameter<>> ('h', "help", "Show this help message and exit");
|
||||
|
||||
// set defaults
|
||||
@ -126,6 +127,7 @@ int main(int argc, char** argv)
|
||||
else
|
||||
{
|
||||
ProtoConnection connection(argAddress.getValue());
|
||||
connection.setSkipReply(argSkipReply.isSet());
|
||||
|
||||
grabber.setCallback(&sendImage, &connection);
|
||||
grabber.capture();
|
||||
|
Loading…
Reference in New Issue
Block a user