23#include <blackboard/remote.h>
24#include <core/threading/thread.h>
25#include <interfaces/SkillerInterface.h>
26#include <netcomm/fawkes/client.h>
27#include <netcomm/fawkes/client_handler.h>
28#include <readline/history.h>
29#include <readline/readline.h>
30#include <utils/system/argparser.h>
31#include <utils/system/signal.h>
43print_usage(
const char *program_name)
45 printf(
"Usage: %s [-h] [-r host[:port]]\n"
46 " -h This help message\n"
47 " -r host[:port] Remote host (and optionally port) to connect to\n",
74 just_connected =
true;
75 connection_died_recently =
false;
80 rl_event_hook = event_hook;
82 char * host = (
char *)
"localhost";
83 unsigned short int port = 1910;
98 printf(
"Finalizing\n");
118 if (just_connected) {
119 just_connected =
false;
135 const std::vector<const char *> &items = argp->
items();
137 std::vector<const char *>::const_iterator i = items.begin();
140 for (; i != items.end(); ++i) {
152 char *line = readline(prompt);
154 if (strcmp(line,
"") != 0) {
155 if (strcmp(line,
"stop") == 0) {
156 printf(
"Stopping skill execution\n");
160 printf(
"Executing: %s\n", line);
169 if (!connection_died_recently) {
175 if (connection_died_recently) {
176 connection_died_recently =
false;
177 printf(
"Connection died\n");
210 connection_died_recently =
true;
220 printf(
"Connection established\n");
221 just_connected =
true;
232 bool connection_died_recently;
240main(
int argc,
char **argv)
244 if (argp.has_arg(
"h")) {
245 print_usage(argv[0]);
virtual void deregistered(unsigned int id) noexcept
This handler has been deregistered.
SkillShellThread(ArgumentParser *argp)
Constructor.
virtual void loop()
Code to execute in the thread.
~SkillShellThread()
Destructor.
virtual void inbound_received(FawkesNetworkMessage *m, unsigned int id) noexcept
Called for incoming messages.
virtual void connection_died(unsigned int id) noexcept
Client connection died.
virtual void connection_established(unsigned int id) noexcept
Client has established a connection.
Parse command line arguments.
const std::vector< const char * > & items() const
Get non-option items.
bool parse_hostport(const char *argn, char **host, unsigned short int *port)
Parse host:port string.
std::vector< constchar * >::size_type num_items() const
Get number of non-option items.
The BlackBoard abstract class.
virtual Interface * open_for_reading(const char *interface_type, const char *identifier, const char *owner=NULL)=0
Open interface for reading.
virtual void close(Interface *interface)=0
Close interface.
Base class for exceptions in Fawkes.
void print_trace() noexcept
Prints trace to stderr.
Message handler for FawkesNetworkClient.
Simple Fawkes network client.
void register_handler(FawkesNetworkClientHandler *handler, unsigned int component_id)
Register handler.
void connect()
Connect to remote.
void disconnect()
Disconnect socket.
void deregister_handler(unsigned int component_id)
Deregister handler.
bool connected() const noexcept
Check if connection is alive.
Representation of a message that is sent over the network.
unsigned int msgq_enqueue(Message *message, bool proxy=false)
Enqueue message at end of queue.
AcquireControlMessage Fawkes BlackBoard Interface Message.
ExecSkillMessage Fawkes BlackBoard Interface Message.
ReleaseControlMessage Fawkes BlackBoard Interface Message.
StopExecMessage Fawkes BlackBoard Interface Message.
SkillerInterface Fawkes BlackBoard Interface.
Thread class encapsulation of pthreads.
void exit()
Exit the thread.
@ OPMODE_CONTINUOUS
operate in continuous mode (default)
Fawkes library namespace.