Mercurial > pt1.oyama
comparison src/recpt1ctl.c @ 164:7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
KNOWN ISSUE: Cannnot split BS-TBS(BS1_1).
enable compile recpt1ctl.
SID can specified by recpt1ctl.
author | Naoya OYAMA <naoya.oyama@gmail.com> |
---|---|
date | Mon, 01 Oct 2012 21:52:05 +0900 |
parents | 9c7bc6c0327e |
children | 061ef2cd98f0 |
comparison
equal
deleted
inserted
replaced
163:57eae2aec60d | 164:7d8a5bb874ad |
---|---|
7 | 7 |
8 #include <ctype.h> | 8 #include <ctype.h> |
9 #include <getopt.h> | 9 #include <getopt.h> |
10 | 10 |
11 #include "version.h" | 11 #include "version.h" |
12 | 12 #include "pt1_common.h" |
13 #define MSGSZ 255 | |
14 | |
15 typedef struct msgbuf { | |
16 long mtype; | |
17 char mtext[MSGSZ]; | |
18 } message_buf; | |
19 | 13 |
20 void | 14 void |
21 show_usage(char *cmd) | 15 show_usage(char *cmd) |
22 { | 16 { |
23 fprintf(stderr, "Usage: \n%s --pid pid [--channel channel] [--extend time_to_extend] [--time recording_time]\n", cmd); | 17 fprintf(stderr, "Usage: \n%s --pid pid [--channel channel] [--extend time_to_extend] [--time recording_time]\n", cmd); |
128 main(int argc, char **argv) | 122 main(int argc, char **argv) |
129 { | 123 { |
130 int msqid; | 124 int msqid; |
131 int msgflg = IPC_CREAT | 0666; | 125 int msgflg = IPC_CREAT | 0666; |
132 key_t key = 0; | 126 key_t key = 0; |
133 int channel=0, recsec = 0, extsec=0; | 127 int recsec = 0, extsec=0; |
134 message_buf sbuf; | 128 char *channel = NULL; |
129 pt1_message_buf sbuf; | |
135 size_t buf_length; | 130 size_t buf_length; |
131 char *sid_list = NULL; | |
136 | 132 |
137 int result; | 133 int result; |
138 int option_index; | 134 int option_index; |
139 struct option long_options[] = { | 135 struct option long_options[] = { |
140 { "pid", 1, NULL, 'p'}, | 136 { "pid", 1, NULL, 'p'}, |
142 { "extend", 1, NULL, 'e'}, | 138 { "extend", 1, NULL, 'e'}, |
143 { "time", 1, NULL, 't'}, | 139 { "time", 1, NULL, 't'}, |
144 { "help", 0, NULL, 'h'}, | 140 { "help", 0, NULL, 'h'}, |
145 { "version", 0, NULL, 'v'}, | 141 { "version", 0, NULL, 'v'}, |
146 { "list", 0, NULL, 'l'}, | 142 { "list", 0, NULL, 'l'}, |
143 { "sid", 1, NULL, 'i'}, | |
144 { "SID", 1, NULL, 'i'}, | |
147 {0, 0, NULL, 0} /* terminate */ | 145 {0, 0, NULL, 0} /* terminate */ |
148 }; | 146 }; |
149 | 147 |
150 while((result = getopt_long(argc, argv, "p:c:e:t:hvl", | 148 while((result = getopt_long(argc, argv, "p:c:e:t:hvli", |
151 long_options, &option_index)) != -1) { | 149 long_options, &option_index)) != -1) { |
152 switch(result) { | 150 switch(result) { |
153 case 'h': | 151 case 'h': |
154 fprintf(stderr, "\n"); | 152 fprintf(stderr, "\n"); |
155 show_usage(argv[0]); | 153 show_usage(argv[0]); |
173 case 'p': | 171 case 'p': |
174 key = (key_t)atoi(optarg); | 172 key = (key_t)atoi(optarg); |
175 fprintf(stderr, "Pid = %d\n", key); | 173 fprintf(stderr, "Pid = %d\n", key); |
176 break; | 174 break; |
177 case 'c': | 175 case 'c': |
178 channel = atoi(optarg); | 176 channel = optarg; |
179 fprintf(stderr, "Channel = %d\n", channel); | 177 fprintf(stderr, "Channel = %s\n", channel); |
180 break; | 178 break; |
181 case 'e': | 179 case 'e': |
182 parse_time(optarg, &extsec); | 180 parse_time(optarg, &extsec); |
183 fprintf(stderr, "Extend %d sec\n", extsec); | 181 fprintf(stderr, "Extend %d sec\n", extsec); |
184 break; | 182 break; |
185 case 't': | 183 case 't': |
186 parse_time(optarg, &recsec); | 184 parse_time(optarg, &recsec); |
187 fprintf(stderr, "Total recording time = %d sec\n", recsec); | 185 fprintf(stderr, "Total recording time = %d sec\n", recsec); |
186 break; | |
187 case 'i': | |
188 sid_list = optarg; | |
188 break; | 189 break; |
189 } | 190 } |
190 } | 191 } |
191 | 192 |
192 if(!key) { | 193 if(!key) { |
199 perror("msgget"); | 200 perror("msgget"); |
200 exit(1); | 201 exit(1); |
201 } | 202 } |
202 | 203 |
203 sbuf.mtype = 1; | 204 sbuf.mtype = 1; |
204 sprintf(sbuf.mtext, "ch=%d t=%d e=%d", channel, recsec, extsec); | 205 sprintf(sbuf.mtext, "ch=%s t=%d e=%d i=%s", channel, recsec, extsec, sid_list); |
205 | 206 |
206 buf_length = strlen(sbuf.mtext) + 1 ; | 207 buf_length = strlen(sbuf.mtext) + 1 ; |
207 | 208 |
208 if (msgsnd(msqid, &sbuf, buf_length, IPC_NOWAIT) < 0) { | 209 if (msgsnd(msqid, &sbuf, buf_length, IPC_NOWAIT) < 0) { |
209 perror("msgsnd"); | 210 perror("msgsnd"); |