Changeset 51
- Timestamp:
- 05/28/09 15:44:05 (15 years ago)
- Location:
- drsdaq
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
drsdaq/DAQReadout.cc
r49 r51 1019 1019 vsnprintf(Textbuffer, sizeof(Textbuffer), Format, ArgumentPointer); 1020 1020 1021 // Print to console and generate new prompt1021 // Print to console 1022 1022 if(Target & MsgToConsole) { 1023 if(strlen(Textbuffer)>0 && Textbuffer[strlen(Textbuffer)-1]=='\n') printf("\r%s", Textbuffer); 1023 if(strlen(Textbuffer)>0 && Textbuffer[strlen(Textbuffer)-1]=='\n') { 1024 printf("\r%s%s", Textbuffer, Prompt); // New prompt 1025 fflush(stdout); 1026 } 1024 1027 else printf("%s", Textbuffer); 1025 1026 // New prompt only after newline 1027 if(Textbuffer[strlen(Textbuffer)-1]=='\n' || strlen(Textbuffer)==0) { 1028 if (NumBoards == 0) printf("\rDAQ> "); 1029 else if (FirstBoard == LastBoard) printf("\rDAQ|B%d> ",FirstBoard); 1030 else printf("\rDAQ|B%d-%d> ",FirstBoard,LastBoard); 1031 fflush(stdout); 1032 } 1033 } 1034 1035 // Print to log file and socket only if length not zero (then only prompt) 1036 if (strlen(Textbuffer)>0) { 1037 if((Target & MsgToLog) && Logfile!=NULL) { 1038 fprintf(Logfile, "%s", Textbuffer); 1039 fflush(Logfile); 1040 } 1041 if((Target & MsgToSocket) && Socket!=-1) write(Socket, Textbuffer, strlen(Textbuffer)); 1042 } 1028 } 1029 // Print to log file 1030 if((Target & MsgToLog) && Logfile!=NULL) { 1031 fprintf(Logfile, "%s", Textbuffer); 1032 fflush(Logfile); 1033 } 1034 // Print to socket 1035 if((Target & MsgToSocket) && Socket!=-1) write(Socket, Textbuffer, strlen(Textbuffer)); 1043 1036 } 1044 1037 -
drsdaq/DAQReadout.h
r49 r51 81 81 unsigned int RunNumber, FileNumber; 82 82 char FileName[MAX_PATH]; 83 83 char Prompt[MAX_COM_SIZE]; 84 84 85 85 // Public functions -
drsdaq/History.txt
r49 r51 28 28 19/5/2009 Subversion revision number included in run header. Added human readable 29 29 date and time to slow data. 30 28/5/2009 Replaced NCMCBoards by NBoards for clarity. 30 28/5/2009 Replaced NCMCBoards by NBoards for clarity. Added line editing 31 capability with the readline library. -
drsdaq/Makefile
r44 r51 26 26 27 27 CPPFLAGS = -DREVISION='"$(REVISION)"' -O3 -Wall $(VMECTRL) 28 LIBS = -lstdc++ -lz -lpthread -lutil -lfl $(VMELIB)28 LIBS = -lstdc++ -lz -lpthread -lutil -lfl -lreadline -ltermcap $(VMELIB) 29 29 30 30 drsdaq: $(OBJECTS) -
drsdaq/drsdaq.cpp
r44 r51 19 19 #include <netdb.h> 20 20 #include <arpa/inet.h> 21 #include <readline/readline.h> 22 #include <readline/history.h> 21 23 22 24 #include "DAQReadout.h" … … 116 118 ConsoleCommand thread 117 119 118 Handle console input 120 Handle console input using readline library functions to allow 121 line editing and history capability 119 122 120 123 \********************************************************************/ … … 122 125 void ConsoleCommand(DAQReadout *m) { 123 126 124 char Command[MAX_COM_SIZE], Buf[MAX_COM_SIZE];125 127 time_t Time; 126 128 char *Command, Buf[MAX_COM_SIZE];; 129 127 130 while (!m->Exit) { 128 m->PrintMessage(""); // New prompt 129 if (fgets(Command, MAX_COM_SIZE, stdin)==NULL) 131 if (m->NumBoards == 0) snprintf(m->Prompt,sizeof(m->Prompt),"\rDAQ> "); 132 else if (m->FirstBoard == m->LastBoard) snprintf(m->Prompt,sizeof(m->Prompt),"\rDAQ|B%d> ",m->FirstBoard); 133 else snprintf(m->Prompt,sizeof(m->Prompt),"\rDAQ|B%d-%d> ",m->FirstBoard,m->LastBoard); 134 135 Command = readline(m->Prompt); 136 if (Command==NULL) { 130 137 m->PrintMessage("Error reading command line input\n"); 131 132 strftime(Buf,MAX_COM_SIZE,"%d/%m/%y %X", localtime(&(Time=time(NULL)))); 133 m->PrintMessage(MsgToLog, "CONSOLE(%s)> %s",Buf, Command); 138 continue; 139 } 140 141 if(strlen(Command)>0) add_history(Command); 142 143 strftime(Buf,MAX_COM_SIZE, "%d/%m/%y %X", localtime(&(Time=time(NULL)))); 144 m->PrintMessage(MsgToLog, "CONSOLE(%s)> %s", Buf, Command); 134 145 135 146 pthread_mutex_lock(&m->control_mutex); 136 147 m->CommandControl(Command, false); 137 148 pthread_mutex_unlock(&m->control_mutex); 149 150 free(Command); 138 151 } 139 152 } … … 206 219 memset(Command,0,sizeof(Command)); 207 220 ReadResult = read(ConnectionSocket, Command, MAX_COM_SIZE); 208 if (ReadResult==0) break; // Client no exisiting anymore221 if (ReadResult==0) break; // Client not exisiting anymore 209 222 if (ReadResult==-1) { 210 223 if (errno!=EINTR) m->PrintMessage("Error read from socket (%s)\n", strerror(errno)); … … 219 232 m->CommandControl(Command, true); // Process CC command 220 233 pthread_mutex_unlock(&m->control_mutex); 221 m->PrintMessage(""); // New prompt222 234 } 223 235 m->Socket = -1;
Note:
See TracChangeset
for help on using the changeset viewer.