00001 /// 00002 /// \file common.cc 00003 /// General Barry interface routines 00004 /// 00005 00006 /* 00007 Copyright (C) 2005-2008, Net Direct Inc. (http://www.netdirect.ca/) 00008 00009 This program is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; either version 2 of the License, or 00012 (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00017 00018 See the GNU General Public License in the COPYING file at the 00019 root directory of this project for more details. 00020 */ 00021 00022 #include "common.h" 00023 #include <usb.h> 00024 #include <pthread.h> 00025 #include "debug.h" 00026 00027 namespace Barry { 00028 00029 bool __data_dump_mode__; 00030 00031 std::ostream *LogStream = &std::cout; 00032 pthread_mutex_t LogStreamMutex; 00033 00034 00035 // 00036 // Init 00037 // 00038 /// Barry library initializer. Call this before anything else. 00039 /// This takes care of initializing the lower level libusb. 00040 /// 00041 /// \param[in] data_dump_mode If set to true, the protocol conversation 00042 /// will be sent to stdout via the C++ std::cout 00043 /// stream. 00044 /// \param[in] LogStream Pointer to std::ostream object to use for 00045 /// debug output and logging. Defaults to 00046 /// std::cout. 00047 /// 00048 void Init(bool data_dump_mode, std::ostream *logStream) 00049 { 00050 if( data_dump_mode ) 00051 usb_set_debug(9); 00052 usb_init(); 00053 00054 __data_dump_mode__ = data_dump_mode; 00055 LogStream = logStream; 00056 pthread_mutex_init(&LogStreamMutex, NULL); 00057 } 00058 00059 } // namespace Barry 00060