4 | | This program is free software; you can redistribute it and/or modify * |
---|
5 | | it under the terms of the GNU General Public License as published by * |
---|
6 | | the Free Software Foundation; either version 2 of the License, or * |
---|
7 | | (at your option) any later version. * |
---|
| 4 | This program is free software; you can redistribute it and/or modify * |
---|
| 5 | it under the terms of the GNU General Public License as published by * |
---|
| 6 | the Free Software Foundation; either version 2 of the License, or * |
---|
| 7 | (at your option) any later version. * |
---|
9 | | This program is distributed in the hope that it will be useful, * |
---|
10 | | but WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
11 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
---|
12 | | GNU General Public License for more details. * |
---|
| 9 | This program is distributed in the hope that it will be useful, * |
---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
---|
| 12 | GNU General Public License for more details. * |
---|
14 | | You should have received a copy of the GNU General Public License * |
---|
15 | | along with this program; if not, write to the * |
---|
16 | | Free Software Foundation, Inc., * |
---|
17 | | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
---|
18 | | ***************************************************************************/ |
---|
| 14 | You should have received a copy of the GNU General Public License * |
---|
| 15 | along with this program; if not, write to the * |
---|
| 16 | Free Software Foundation, Inc., * |
---|
| 17 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
---|
| 18 | ***************************************************************************/ |
---|
124 | | } |
---|
125 | | |
---|
126 | | if(sscanf( arg, "%d,%d", |
---|
127 | | &arguments->args[state->arg_num].port, |
---|
128 | | &arguments->args[state->arg_num].channel) != 2) { |
---|
129 | | fprintf( stderr, "Could not parse port-channel specification ('%s')\n", arg); |
---|
130 | | |
---|
131 | | } else { |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | if(sscanf( arg, "%d,%d", |
---|
| 127 | &arguments->args[state->arg_num].port, |
---|
| 128 | &arguments->args[state->arg_num].channel) != 2) { |
---|
| 129 | fprintf( stderr, "Could not parse port-channel specification ('%s')\n", arg); |
---|
| 130 | |
---|
| 131 | } else { |
---|
195 | | run=1; |
---|
196 | | |
---|
197 | | run_realtime=arguments.realtime; |
---|
198 | | realtime_prio=arguments.rtprio; |
---|
199 | | |
---|
200 | | signal (SIGINT, sighandler); |
---|
201 | | signal (SIGPIPE, sighandler); |
---|
202 | | |
---|
203 | | debugOutput(DEBUG_LEVEL_NORMAL, "Freebob SYT monitor\n"); |
---|
204 | | |
---|
205 | | m_isoManager=new IsoHandlerManager(); |
---|
206 | | |
---|
207 | | if(!m_isoManager) { |
---|
208 | | debugOutput(DEBUG_LEVEL_NORMAL, "Could not create IsoHandlerManager\n"); |
---|
209 | | goto finish; |
---|
210 | | } |
---|
211 | | |
---|
212 | | m_isoManager->setVerboseLevel(DEBUG_LEVEL_VERBOSE); |
---|
213 | | |
---|
| 195 | run=1; |
---|
| 196 | |
---|
| 197 | run_realtime=arguments.realtime; |
---|
| 198 | realtime_prio=arguments.rtprio; |
---|
| 199 | |
---|
| 200 | signal (SIGINT, sighandler); |
---|
| 201 | signal (SIGPIPE, sighandler); |
---|
| 202 | |
---|
| 203 | debugOutput(DEBUG_LEVEL_NORMAL, "Freebob SYT monitor\n"); |
---|
| 204 | |
---|
| 205 | m_isoManager=new IsoHandlerManager(); |
---|
| 206 | |
---|
| 207 | if(!m_isoManager) { |
---|
| 208 | debugOutput(DEBUG_LEVEL_NORMAL, "Could not create IsoHandlerManager\n"); |
---|
| 209 | goto finish; |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | m_isoManager->setVerboseLevel(DEBUG_LEVEL_VERBOSE); |
---|
| 213 | |
---|
215 | | m_isoManagerThread=new PosixThread( |
---|
216 | | m_isoManager, |
---|
217 | | run_realtime, realtime_prio, |
---|
218 | | PTHREAD_CANCEL_DEFERRED); |
---|
219 | | |
---|
220 | | if(!m_isoManagerThread) { |
---|
221 | | debugOutput(DEBUG_LEVEL_NORMAL, "Could not create iso manager thread\n"); |
---|
222 | | goto finish; |
---|
223 | | } |
---|
224 | | |
---|
225 | | // register monitors |
---|
226 | | for (i=0;i<arguments.nb_combos;i++) { |
---|
227 | | debugOutput(DEBUG_LEVEL_NORMAL, "Registering SytMonitor %d\n",i); |
---|
228 | | |
---|
229 | | // add a stream to the manager so that it has something to do |
---|
230 | | monitors[i]=new SytMonitor(arguments.args[i].port); |
---|
231 | | |
---|
232 | | if (!monitors[i]) { |
---|
233 | | debugOutput(DEBUG_LEVEL_NORMAL, "Could not create SytMonitor %d\n", i); |
---|
234 | | goto finish; |
---|
235 | | } |
---|
236 | | |
---|
237 | | monitors[i]->setVerboseLevel(DEBUG_LEVEL_VERBOSE); |
---|
238 | | |
---|
239 | | if (!monitors[i]->init()) { |
---|
240 | | debugOutput(DEBUG_LEVEL_NORMAL, "Could not init SytMonitor %d\n", i); |
---|
241 | | goto finish; |
---|
242 | | } |
---|
243 | | |
---|
244 | | monitors[i]->setChannel(arguments.args[i].channel); |
---|
245 | | |
---|
246 | | if(!m_isoManager->registerStream(monitors[i])) { |
---|
| 215 | m_isoManagerThread=new PosixThread( |
---|
| 216 | m_isoManager, |
---|
| 217 | run_realtime, realtime_prio, |
---|
| 218 | PTHREAD_CANCEL_DEFERRED); |
---|
| 219 | |
---|
| 220 | if(!m_isoManagerThread) { |
---|
| 221 | debugOutput(DEBUG_LEVEL_NORMAL, "Could not create iso manager thread\n"); |
---|
| 222 | goto finish; |
---|
| 223 | } |
---|
| 224 | |
---|
| 225 | // register monitors |
---|
| 226 | for (i=0;i<arguments.nb_combos;i++) { |
---|
| 227 | debugOutput(DEBUG_LEVEL_NORMAL, "Registering SytMonitor %d\n",i); |
---|
| 228 | |
---|
| 229 | // add a stream to the manager so that it has something to do |
---|
| 230 | monitors[i]=new SytMonitor(arguments.args[i].port); |
---|
| 231 | |
---|
| 232 | if (!monitors[i]) { |
---|
| 233 | debugOutput(DEBUG_LEVEL_NORMAL, "Could not create SytMonitor %d\n", i); |
---|
| 234 | goto finish; |
---|
| 235 | } |
---|
| 236 | |
---|
| 237 | monitors[i]->setVerboseLevel(DEBUG_LEVEL_VERBOSE); |
---|
| 238 | |
---|
| 239 | if (!monitors[i]->init()) { |
---|
| 240 | debugOutput(DEBUG_LEVEL_NORMAL, "Could not init SytMonitor %d\n", i); |
---|
| 241 | goto finish; |
---|
| 242 | } |
---|
| 243 | |
---|
| 244 | monitors[i]->setChannel(arguments.args[i].channel); |
---|
| 245 | |
---|
| 246 | if(!m_isoManager->registerStream(monitors[i])) { |
---|
251 | | |
---|
252 | | |
---|
253 | | debugOutput(DEBUG_LEVEL_NORMAL, "Preparing IsoHandlerManager...\n"); |
---|
254 | | if (!m_isoManager->prepare()) { |
---|
255 | | debugOutput(DEBUG_LEVEL_NORMAL, "Could not prepare isoManager\n"); |
---|
256 | | goto finish; |
---|
257 | | } |
---|
258 | | |
---|
259 | | debugOutput(DEBUG_LEVEL_NORMAL, "Starting ISO manager sync update thread...\n"); |
---|
| 251 | |
---|
| 252 | |
---|
| 253 | debugOutput(DEBUG_LEVEL_NORMAL, "Preparing IsoHandlerManager...\n"); |
---|
| 254 | if (!m_isoManager->prepare()) { |
---|
| 255 | debugOutput(DEBUG_LEVEL_NORMAL, "Could not prepare isoManager\n"); |
---|
| 256 | goto finish; |
---|
| 257 | } |
---|
| 258 | |
---|
| 259 | debugOutput(DEBUG_LEVEL_NORMAL, "Starting ISO manager sync update thread...\n"); |
---|
264 | | debugOutput(DEBUG_LEVEL_NORMAL, "Starting IsoHandlers...\n"); |
---|
265 | | if (!m_isoManager->startHandlers(0)) { |
---|
266 | | debugOutput(DEBUG_LEVEL_NORMAL, "Could not start handlers...\n"); |
---|
267 | | goto finish; |
---|
268 | | } |
---|
269 | | |
---|
270 | | if (arguments.realtime) { |
---|
271 | | // get rt priority for this thread too. |
---|
272 | | params.sched_priority = arguments.rtprio + 1; |
---|
273 | | if (pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶ms)) { |
---|
274 | | debugWarning("Couldn't set realtime prio for main thread..."); |
---|
275 | | } |
---|
276 | | } |
---|
277 | | |
---|
278 | | // do the actual work |
---|
279 | | nb_iter=0; |
---|
280 | | while(run) { |
---|
| 264 | debugOutput(DEBUG_LEVEL_NORMAL, "Starting IsoHandlers...\n"); |
---|
| 265 | if (!m_isoManager->startHandlers(0)) { |
---|
| 266 | debugOutput(DEBUG_LEVEL_NORMAL, "Could not start handlers...\n"); |
---|
| 267 | goto finish; |
---|
| 268 | } |
---|
| 269 | |
---|
| 270 | if (arguments.realtime) { |
---|
| 271 | // get rt priority for this thread too. |
---|
| 272 | params.sched_priority = arguments.rtprio + 1; |
---|
| 273 | if (pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶ms)) { |
---|
| 274 | debugWarning("Couldn't set realtime prio for main thread..."); |
---|
| 275 | } |
---|
| 276 | } |
---|
| 277 | |
---|
| 278 | // do the actual work |
---|
| 279 | nb_iter=0; |
---|
| 280 | while(run) { |
---|
427 | | } |
---|
428 | | } |
---|
429 | | } |
---|
430 | | |
---|
431 | | debugOutput(DEBUG_LEVEL_NORMAL, "Stopping handlers...\n"); |
---|
432 | | if(!m_isoManager->stopHandlers()) { |
---|
433 | | debugOutput(DEBUG_LEVEL_NORMAL, "Could not stop ISO handlers\n"); |
---|
434 | | goto finish; |
---|
435 | | } |
---|
436 | | |
---|
437 | | // stop the sync thread |
---|
438 | | debugOutput(DEBUG_LEVEL_NORMAL, "Stopping ISO manager sync update thread...\n"); |
---|
439 | | m_isoManagerThread->Stop(); |
---|
440 | | |
---|
441 | | // unregister monitors |
---|
442 | | for (i=0;i<arguments.nb_combos;i++) { |
---|
| 427 | } |
---|
| 428 | } |
---|
| 429 | } |
---|
| 430 | |
---|
| 431 | debugOutput(DEBUG_LEVEL_NORMAL, "Stopping handlers...\n"); |
---|
| 432 | if(!m_isoManager->stopHandlers()) { |
---|
| 433 | debugOutput(DEBUG_LEVEL_NORMAL, "Could not stop ISO handlers\n"); |
---|
| 434 | goto finish; |
---|
| 435 | } |
---|
| 436 | |
---|
| 437 | // stop the sync thread |
---|
| 438 | debugOutput(DEBUG_LEVEL_NORMAL, "Stopping ISO manager sync update thread...\n"); |
---|
| 439 | m_isoManagerThread->Stop(); |
---|
| 440 | |
---|
| 441 | // unregister monitors |
---|
| 442 | for (i=0;i<arguments.nb_combos;i++) { |
---|