3 /// General Barry interface routines
7 Copyright (C) 2005-2010, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
29 bool __data_dump_mode__
;
31 std::ostream
*LogStream
= &std::cout
;
32 pthread_mutex_t LogStreamMutex
;
38 /// Barry library initializer. Call this before anything else.
39 /// This takes care of initializing the lower level libusb.
41 /// This function is safe to be called multiple times. The
42 /// data_dump_mode and the log stream will be updated each time
43 /// it is called, but the USB library will not be re-initialized.
45 /// \param[in] data_dump_mode If set to true, the protocol conversation
46 /// will be sent to the logStream specified
47 /// in the second argument.
48 /// \param[in] LogStream Pointer to std::ostream object to use for
49 /// debug output and logging. Defaults to
52 void Init(bool data_dump_mode
, std::ostream
*logStream
)
54 static bool initialized
= false;
56 // set usb debug mode first, so that USB's initialization
61 // perform one-time initalization
63 // if the environment variable USB_DEBUG is set, that
64 // level value will be used instead of our 9 above...
65 // if you need to *force* this to 9, call Verbose(true)
69 // only need to initialize this once
70 pthread_mutex_init(&LogStreamMutex
, NULL
);
76 __data_dump_mode__
= data_dump_mode
;
77 LogStream
= logStream
;
83 /// This API call lets the application enable / disable verbose debug
84 /// output on the fly.
86 /// \param[in] data_dump_mode If set to true, the protocol conversation
87 /// will be sent to the logStream specified
88 /// in the Barry::Init() call.
90 void Verbose(bool data_dump_mode
)
92 __data_dump_mode__
= data_dump_mode
;
103 /// Returns true if data dump mode is enabled.
107 return __data_dump_mode__
;