csprint(NULL, CS_CONNECTED);
+ Write("autodisplay on\n");
Write(".messages\n");
int stat;
+ int last_is_eod = 0; /* Last packet received is BNET_EOD */
+ int do_not_forward_eod = 0; /* Last packet received/sent is .messages, so don't forward EOD. (so wx-console don't show the prompt again) */
+
/* main loop */
while(!TestDestroy()) { /* Tests if thread has been ended */
+ stat = bnet_wait_data(UA_sock, 10);
+ if (stat == 0) {
+ if (last_is_eod) {
+ Write(".messages\n");
+ do_not_forward_eod = 1;
+ }
+ continue;
+ }
+
+ last_is_eod = 0;
if ((stat = bnet_recv(UA_sock)) >= 0) {
+ if (do_not_forward_eod) { /* .messages got data: remove the prompt */
+ csprint(NULL, CS_REMOVEPROMPT);
+ }
csprint(UA_sock->msg);
}
else if (stat == BNET_SIGNAL) {
csprint(NULL, CS_PROMPT);
}
else if (UA_sock->msglen == BNET_EOD) {
- csprint(NULL, CS_END);
+ last_is_eod = 1;
+ if (!do_not_forward_eod)
+ csprint(NULL, CS_END);
}
else if (UA_sock->msglen == BNET_HEARTBEAT) {
bnet_sig(UA_sock, BNET_HB_RESPONSE);
csprint(NULL, CS_END);
break; /* error or term */
}
+
+ do_not_forward_eod = 0;
}
csprint(NULL, CS_DISCONNECTED);
void console_thread::Write(const char* str)
{
if (UA_sock) {
- UA_sock->msglen = (int32_t)strlen(str);
- pm_strcpy(&UA_sock->msg, str);
- bnet_send(UA_sock);
+ UA_sock->msglen = (int32_t)strlen(str);
+ pm_strcpy(&UA_sock->msg, str);
+ bnet_send(UA_sock);
} else if (choosingdirector) {
// wxString number = str;
// number.RemoveLast(); /* Removes \n */
#define CS_PROMPT 3 /* prompt signal received */
#define CS_CONNECTED 4 /* the socket is now connected */
#define CS_DISCONNECTED 5 /* the socket is now disconnected */
+
+#define CS_REMOVEPROMPT 6 /* remove the prompt (#), when automatic messages are comming */
+
#define CS_DEBUG 10 /* used to print debug messages */
#define CS_TERMINATED 99 /* used to signal that the thread is terminated */
EnableConsole(false);
}
+ if (status == CS_REMOVEPROMPT) {
+ if (consoleCtrl->GetLastPosition() > 0) {
+ consoleCtrl->Remove(consoleCtrl->GetLastPosition()-1, consoleCtrl->GetLastPosition()+1);
+ }
+ return;
+ }
+
if (status == CS_TERMINATED) {
consoleCtrl->AppendText(consoleBuffer);
consoleBuffer = wxT("");
if (lockedbyconsole) {
EnableConsole(true);
}
- //consoleBuffer << "<P>";
+ //consoleBuffer << wxT("<P>");
}
if ((status == CS_END) || (status == CS_PROMPT) || (str.Find(wxT("\n")) > -1)) {
char status = '?';
wxStopWatch sw;
-
+
+ wxbUtils::WaitForEnd(wxT("autodisplay off\n"));
while (true) {
tableparser = wxbUtils::CreateAndWaitForParser(cmd);
ended = false;
}
delete tableparser;
- dt = wxbUtils::WaitForEnd(wxT(".messages\n"), true);
+ dt = wxbUtils::WaitForEnd(wxT("messages\n"), true);
for (unsigned int i = 0; i < dt->GetCount(); i++) {
wxStringTokenizer tkz((*dt)[i], wxT(" "), wxTOKEN_STRTOK);
break;
}
}
-
+ wxbUtils::WaitForEnd(wxT("autodisplay on\n"));
wxbUtils::WaitForEnd(wxT(".messages\n"));
gauge->SetValue(totfilemessages);