Fixed some win32 stdout related problems. May not worl wit visualstudio debug log anymore.
authoretisserant
Sun, 24 Feb 2008 02:03:19 +0100
changeset 407 384c3cd7afa2
parent 406 92e28415d026
child 408 f85552acc2bf
Fixed some win32 stdout related problems. May not worl wit visualstudio debug log anymore.
drivers/can_tcp_win32/can_tcp_win32_server.cpp
examples/DS401_Slave_Gui/CallBack.cpp
examples/DS401_Slave_Gui/main.cpp
examples/SillySlave/.cvsignore
include/win32/applicfg.h
--- a/drivers/can_tcp_win32/can_tcp_win32_server.cpp	Tue Feb 19 15:21:42 2008 +0100
+++ b/drivers/can_tcp_win32/can_tcp_win32_server.cpp	Sun Feb 24 02:03:19 2008 +0100
@@ -1,86 +1,86 @@
-/*
-This file is part of CanFestival, a library implementing CanOpen Stack. 
-
-Copyright (C): Edouard TISSERANT
-
-See COPYING file for copyrights details.
-
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-#include "Socket.h"
-#include <iostream>
-#include <process.h>
-#include <string>
-#include <list>
-
-using namespace std;
-
-typedef std::list<Socket*> socket_list;
-
-socket_list g_connections;
-
-unsigned __stdcall Connection(void* a) {
-  Socket* s = (Socket*) a;
-
-  g_connections.push_back(s);
-
-  //s->SendLine("Welcome to the Message Distributor");
-  printf("Accepted new connection (0x%x).\n");
-  while (1) {
-    std::string r = s->ReceiveLine();
-    if (r.empty()) break;
-    //cout << r  << endl;    
-    for (socket_list::iterator os =g_connections.begin();
-                               os!=g_connections.end(); 
-                               os++) {
-      if (*os != s) (*os)->SendLine(r);
-    }
-  }
-
-  g_connections.remove(s);
-
-  delete s;
-
-  printf("Connection closed (0x%x).\n",s);
-
-  return 0;
-}
-
-int main() {
-  printf("************************************************\n"
-		 "* TCP broadcasting chat server for CanFestival *\n"
-		 "*  for use with can_tcp_win32 CAN driver DLL   *\n"
-		 "************************************************\n"
-		 "\n"
-		 "Accepts connections on port 11898\n"
-		 "and repeat '\\n' terminated lines \n"
-		 "to each connected client\n"
-		 "\n"
-		 "Use netcat to monitor trafic\n"
-		 " nc 127.0.0.1 11898\n"
-		 "\n");
-  
-  SocketServer in(11898,5);
-  
-  while (1) {
-    Socket* s=in.Accept();
-  
-    unsigned ret;
-    _beginthreadex(0,0,Connection,(void*) s,0,&ret);
-  }
-  
-  return 0;
-}
+/*
+This file is part of CanFestival, a library implementing CanOpen Stack. 
+
+Copyright (C): Edouard TISSERANT
+
+See COPYING file for copyrights details.
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#include "Socket.h"
+#include <iostream>
+#include <process.h>
+#include <string>
+#include <list>
+
+using namespace std;
+
+typedef std::list<Socket*> socket_list;
+
+socket_list g_connections;
+
+unsigned __stdcall Connection(void* a) {
+  Socket* s = (Socket*) a;
+
+  g_connections.push_back(s);
+
+  //s->SendLine("Welcome to the Message Distributor");
+  printf("Accepted new connection (0x%x).\n");
+  while (1) {
+    std::string r = s->ReceiveLine();
+    if (r.empty()) break;
+    //cout << r  << endl;    
+    for (socket_list::iterator os =g_connections.begin();
+                               os!=g_connections.end(); 
+                               os++) {
+      if (*os != s) (*os)->SendLine(r);
+    }
+  }
+
+  g_connections.remove(s);
+
+  delete s;
+
+  printf("Connection closed (0x%x).\n",s);
+
+  return 0;
+}
+
+int main() {
+  printf("************************************************\n"
+		 "* TCP broadcasting chat server for CanFestival *\n"
+		 "*  for use with can_tcp_win32 CAN driver DLL   *\n"
+		 "************************************************\n"
+		 "\n"
+		 "Accepts connections on port 11898\n"
+		 "and repeat '\\n' terminated lines \n"
+		 "to each connected client\n"
+		 "\n"
+		 "Use netcat to monitor trafic\n"
+		 " nc 127.0.0.1 11898\n"
+		 "\n");
+  fflush(stdout);
+  SocketServer in(11898,5);
+  
+  while (1) {
+    Socket* s=in.Accept();
+  
+    unsigned ret;
+    _beginthreadex(0,0,Connection,(void*) s,0,&ret);
+  }
+  
+  return 0;
+}
--- a/examples/DS401_Slave_Gui/CallBack.cpp	Tue Feb 19 15:21:42 2008 +0100
+++ b/examples/DS401_Slave_Gui/CallBack.cpp	Sun Feb 24 02:03:19 2008 +0100
@@ -69,7 +69,7 @@
 Call_post_sync (CO_Data * d)
 {
   //*textLog << wxT("Post_sync\n");
-  printf ("POST SYNC:\n");
+ /* printf ("POST SYNC:\n");
   printf
     ("     Write_Outputs: %x \n     Analogue_Output1: %d \n     Analogue_Output2: %d \n",
      Write_Outputs_8_Bit[0], Write_Analogue_Output_16_Bit[0],
@@ -77,7 +77,7 @@
   printf
     ("     Read_Input: %x \n     Analogue_Input1: %d \n     Analogue_Input2: %d \n",
      Read_Inputs_8_Bit[0], Read_Analogue_Input_16_Bit[0],
-     Read_Analogue_Input_16_Bit[1]);
+     Read_Analogue_Input_16_Bit[1]);*/
 }
 
 void
@@ -89,6 +89,6 @@
 void
 Call_storeODSubIndex (CO_Data * d, UNS16 wIndex, UNS8 bSubindex)
 {
-  printf ("StoreODSubIndex : %4.4x %2.2x\n", wIndex, bSubindex);
+  /*printf ("StoreODSubIndex : %4.4x %2.2x\n", wIndex, bSubindex);*/
   //*textLog << wxT("StoreODSubIndex :\n");
 }
--- a/examples/DS401_Slave_Gui/main.cpp	Tue Feb 19 15:21:42 2008 +0100
+++ b/examples/DS401_Slave_Gui/main.cpp	Sun Feb 24 02:03:19 2008 +0100
@@ -596,6 +596,7 @@
   if (main_can (SlaveBoard, LibraryPath))
     {
       printf ("[KO]\n");
+      fflush(stdout);
       *textLog <<
 	wxT
 	("----------------------------------------------------Initialization [KO]\n");
@@ -603,6 +604,7 @@
   else
     {
       printf ("[OK]\n");
+      fflush(stdout);
       *textLog <<
 	wxT
 	("----------------------------------------------------Initialization [OK]\n");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/SillySlave/.cvsignore	Sun Feb 24 02:03:19 2008 +0100
@@ -0,0 +1,1 @@
+Makefile
--- a/include/win32/applicfg.h	Tue Feb 19 15:21:42 2008 +0100
+++ b/include/win32/applicfg.h	Sun Feb 24 02:03:19 2008 +0100
@@ -101,9 +101,12 @@
    OutputDebugString(msg);}while(0)
 #else
 #define MSG(...) \
-  do{char msg[300];\
+  do{printf(__VA_ARGS__);fflush(stdout);}while(0)
+
+/*do{char msg[300];\
    sprintf(msg,##__VA_ARGS__);\
    OutputDebugString(msg);}while(0)
+*/
 #endif  
 #define CANFESTIVAL_DEBUG_MSG(num, str, val)\
   {unsigned long value = val;\