MIDAS
Loading...
Searching...
No Matches
msgdump.c File Reference
#include "midas.h"
#include "msystem.h"
Include dependency graph for msgdump.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Variables

chartype_name []
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 27 of file msgdump.c.

28{
29 int msg_buf, i, status, size, id;
30 char event[10000];
31 EVENT_HEADER *pheader;
32 BUFFER_HEADER buffer_header;
33 char *pstring;
34 char type_string[100];
35 FILE *f;
36
37 if (argc < 2) {
38 printf("Usage: msgdump [-dwc] \n");
39 printf(" \n");
40 printf(" -d display messages on screen \n");
41 printf(" -c display clients producing messages \n");
42 printf(" -w write messages to MSGDUMP.ASC \n\n");
43 return 1;
44 }
45
46 status = cm_connect_experiment("", "", "MsgDump", NULL);
47 if (status != CM_SUCCESS)
48 return 1;
49
51
52 bm_get_buffer_info(msg_buf, &buffer_header);
53
55
56 pstring = event + sizeof(EVENT_HEADER);
57 pheader = (EVENT_HEADER *) event;
58
59 if (argv[1][1] == 'd') {
60 printf("Displaying messages. Hit Ctrl-C to abort.\n");
61 printf("=========================================\n\n");
62
63 do {
64 size = 10000;
65 status = bm_receive_event(msg_buf, event, &size, BM_WAIT);
66
67 if (status != BM_SUCCESS) {
68 printf("Error receiving event.\n");
69 return 0;
70 }
71
72 type_string[0] = 0;
73 for (i = 0; i < 8; i++)
74 if (pheader->trigger_mask & (1 << i))
76
77 printf("serial %d, type %s, time %1.3lf\n",
78 pheader->serial_number, type_string, pheader->time_stamp / 1000.0);
79 printf("%s\n\n", pstring);
80 } while (1);
81 }
82
83 if (argv[1][1] == 'c') {
84 printf("Clients attached to current message system:\n");
85 printf("===========================================\n\n");
86
87 for (i = 0; i < buffer_header.max_client_index; i++)
88 if (buffer_header.client[i].pid)
89 printf("#%d: pid=%d name=%s\n", i, buffer_header.client[i].pid,
90 buffer_header.client[i].name);
91 }
92
93 if (argv[1][1] == 'w') {
94 printf("Message collecting active, hit ENTER to stop.\n");
95
96 getchar();
97
98 printf("Writing MSGDUMP.ASC ...\n");
99
100 f = fopen("MSGDUMP.ASC", "w");
101
102 bm_get_buffer_info(msg_buf, &buffer_header);
103
104 do {
105 size = 10000;
106 status = bm_receive_event(msg_buf, event, &size, BM_NO_WAIT);
107 if (status == BM_ASYNC_RETURN) {
108 fclose(f);
109 break;
110 }
111
112 type_string[0] = 0;
113 for (i = 0; i < 8; i++)
114 if (pheader->trigger_mask & (1 << i))
116
117 fprintf(f, "serial %d, type %s, time %1.3lf\n",
118 pheader->serial_number, type_string, pheader->time_stamp / 1000.0);
119 fprintf(f, "%s\n\n", pstring);
120 } while (1);
121 }
122
123
125 return 1;
126}
INT bm_open_buffer(const char *buffer_name, INT buffer_size, INT *buffer_handle)
Definition midas.cxx:6717
INT bm_request_event(HNDLE buffer_handle, short int event_id, short int trigger_mask, INT sampling_type, HNDLE *request_id, EVENT_HANDLER *func)
Definition midas.cxx:8465
INT bm_receive_event(INT buffer_handle, void *destination, INT *buf_size, int timeout_msec)
Definition midas.cxx:10650
INT cm_connect_experiment(const char *host_name, const char *exp_name, const char *client_name, void(*func)(char *))
Definition midas.cxx:2278
INT cm_disconnect_experiment(void)
Definition midas.cxx:2846
#define CM_SUCCESS
Definition midas.h:582
#define BM_ASYNC_RETURN
Definition midas.h:613
#define BM_SUCCESS
Definition midas.h:605
#define GET_NONBLOCKING
Definition midas.h:322
#define TRIGGER_ALL
Definition midas.h:538
#define BM_NO_WAIT
Definition midas.h:366
#define EVENTID_ALL
Definition midas.h:537
#define BM_WAIT
Definition midas.h:365
#define MESSAGE_BUFFER_NAME
Definition msystem.h:111
#define MESSAGE_BUFFER_SIZE
Definition msystem.h:110
INT i
Definition mdump.cxx:32
INT bm_get_buffer_info(INT buffer_handle, BUFFER_HEADER *buffer_header)
Definition midas.cxx:7791
char * type_name[]
Definition msgdump.c:18
DWORD status
Definition odbhist.cxx:39
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
char name[NAME_LENGTH]
Definition midas.h:935
INT max_client_index
Definition midas.h:960
BUFFER_CLIENT client[MAX_CLIENTS]
Definition midas.h:967
DWORD serial_number
Definition midas.h:854
DWORD time_stamp
Definition midas.h:855
short int trigger_mask
Definition midas.h:853
Here is the call graph for this function:

Variable Documentation

◆ type_name

char* type_name[]
Initial value:
= {
"ERROR",
"INFO",
"DEBUG" "USER",
"LOG",
"TALK",
"CALL",
}

Definition at line 18 of file msgdump.c.

18 {
19 "ERROR",
20 "INFO",
21 "DEBUG" "USER",
22 "LOG",
23 "TALK",
24 "CALL",
25};