[tuxdroid-svn] r964 - in software_suite_v2/middleware: . tuxdriver tuxdriver/trunk tuxdriver/trunk/
Status: Beta
Brought to you by:
ks156
Author: remi Date: 2008-04-17 11:12:05 +0200 (Thu, 17 Apr 2008) New Revision: 964 Added: software_suite_v2/middleware/tuxdriver/ software_suite_v2/middleware/tuxdriver/branches/ software_suite_v2/middleware/tuxdriver/tags/ software_suite_v2/middleware/tuxdriver/trunk/ software_suite_v2/middleware/tuxdriver/trunk/AUTHORS software_suite_v2/middleware/tuxdriver/trunk/COPYING software_suite_v2/middleware/tuxdriver/trunk/README software_suite_v2/middleware/tuxdriver/trunk/doc/ software_suite_v2/middleware/tuxdriver/trunk/doc/Notes.txt software_suite_v2/middleware/tuxdriver/trunk/doc/TuxSSV2-Middleware-Driver.odt software_suite_v2/middleware/tuxdriver/trunk/include/ software_suite_v2/middleware/tuxdriver/trunk/include/tux_driver.h software_suite_v2/middleware/tuxdriver/trunk/libs/ software_suite_v2/middleware/tuxdriver/trunk/libs/libusb.lib software_suite_v2/middleware/tuxdriver/trunk/obj/ software_suite_v2/middleware/tuxdriver/trunk/src/ software_suite_v2/middleware/tuxdriver/trunk/src/log.c software_suite_v2/middleware/tuxdriver/trunk/src/log.h software_suite_v2/middleware/tuxdriver/trunk/src/threading_uniform.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_audio.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_audio.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_battery.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_battery.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_cmd_parser.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_cmd_parser.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_descriptor.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_descriptor.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_driver.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_error.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_error.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_eyes.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_eyes.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_firmware.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_firmware.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_hw_cmd.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_hw_status.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_hw_status.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_id.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_id.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_leds.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_leds.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_light.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_light.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_misc.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_misc.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_mouth.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_mouth.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_movements.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_movements.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_pong.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_pong.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_sound_flash.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_sound_flash.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_spinning.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_spinning.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_sw_status.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_sw_status.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_usb.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_usb.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_user_inputs.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_user_inputs.h software_suite_v2/middleware/tuxdriver/trunk/src/tux_wings.c software_suite_v2/middleware/tuxdriver/trunk/src/tux_wings.h software_suite_v2/middleware/tuxdriver/trunk/src/usb.h software_suite_v2/middleware/tuxdriver/trunk/src/version.h software_suite_v2/middleware/tuxdriver/trunk/test/ software_suite_v2/middleware/tuxdriver/trunk/test/Makefile.unix software_suite_v2/middleware/tuxdriver/trunk/test/Makefile.win32 software_suite_v2/middleware/tuxdriver/trunk/test/compile.bat software_suite_v2/middleware/tuxdriver/trunk/test/descriptor.txt software_suite_v2/middleware/tuxdriver/trunk/test/main.c software_suite_v2/middleware/tuxdriver/trunk/test/tada.wav software_suite_v2/middleware/tuxdriver/trunk/test/test_macro.txt software_suite_v2/middleware/tuxdriver/trunk/unix/ software_suite_v2/middleware/tuxdriver/trunk/unix/Makefile software_suite_v2/middleware/tuxdriver/trunk/win32/ software_suite_v2/middleware/tuxdriver/trunk/win32/Makefile software_suite_v2/middleware/tuxdriver/trunk/win32/compile.bat Log: Start of tux_driver project. Added: software_suite_v2/middleware/tuxdriver/trunk/AUTHORS =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/AUTHORS (rev 0) +++ software_suite_v2/middleware/tuxdriver/trunk/AUTHORS 2008-04-17 09:12:05 UTC (rev 964) @@ -0,0 +1,10 @@ +tux_driver was written by: + + Remi Jocaille <rem...@c2...> + +Contributors: + + David Bourgeois <da...@ja...> + Paul Rathgeb <pau...@c2...> + Frans Meulenbroeks aka eFfeM + Added: software_suite_v2/middleware/tuxdriver/trunk/COPYING =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/COPYING (rev 0) +++ software_suite_v2/middleware/tuxdriver/trunk/COPYING 2008-04-17 09:12:05 UTC (rev 964) @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. Added: software_suite_v2/middleware/tuxdriver/trunk/README =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/README (rev 0) +++ software_suite_v2/middleware/tuxdriver/trunk/README 2008-04-17 09:12:05 UTC (rev 964) @@ -0,0 +1,8 @@ +tuxdriver-0.0.1 b007 ALPHA + +tux_driver is a shared library to control the tuxdroid robot. + +For all information about tuxdroid, please visit: + + http://www.tuxisalive.com + Added: software_suite_v2/middleware/tuxdriver/trunk/doc/Notes.txt =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/doc/Notes.txt (rev 0) +++ software_suite_v2/middleware/tuxdriver/trunk/doc/Notes.txt 2008-04-17 09:12:05 UTC (rev 964) @@ -0,0 +1,5 @@ +Directives of compilations: +USE_MUTEX +LOCK_TUX +USB_DEBUG +GENERATE_DOC \ No newline at end of file Added: software_suite_v2/middleware/tuxdriver/trunk/doc/TuxSSV2-Middleware-Driver.odt =================================================================== (Binary files differ) Property changes on: software_suite_v2/middleware/tuxdriver/trunk/doc/TuxSSV2-Middleware-Driver.odt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software_suite_v2/middleware/tuxdriver/trunk/include/tux_driver.h =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/include/tux_driver.h (rev 0) +++ software_suite_v2/middleware/tuxdriver/trunk/include/tux_driver.h 2008-04-17 09:12:05 UTC (rev 964) @@ -0,0 +1,442 @@ +/* + * Tux Droid - Driver + * Copyright (C) 2008 C2ME Sa + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ +/* + * Imported functions: + * extern HMODULE TuxDrv_InitDll(const char *lpsz); + * extern long TuxDrv_UninitDll(void); + * extern void TuxDrv_Start(void); + * extern void TuxDrv_Stop(void); + * extern const char *TuxDrv_StrError(TuxDrvError error_code); + * extern void TuxDrv_GetDescriptor(tux_descriptor_t *tux_desc); + * extern void TuxDrv_SetStatusCallback(drv_status_callback_t funct); + * extern void TuxDrv_SetEndCycleCallback(drv_simple_callback_t funct); + * extern void TuxDrv_SetDongleConnectedCallback(drv_simple_callback_t funct); + * extern void TuxDrv_SetDongleDisconnectedCallback(drv_simple_callback_t funct); + * extern TuxDrvError TuxDrv_PerformCommand(double delay, char *cmd_str); + * extern void TuxDrv_ClearCommandStack(void); + * extern TuxDrvError TuxDrv_PerformMacroFile(char *file_path); + * extern TuxDrvError TuxDrv_PerformMacroText(char *macro); + * extern TuxDrvError TuxDrv_SoundReflash(char *tracks); + * extern void TuxDrv_SetLogLevel(log_level_t level); + * extern void TuxDrv_SetLogTarget(log_target_t target); + * extern TuxDrvError TuxDrv_GetStatusName(int id, char* name); + * extern TuxDrvError TuxDrv_GetStatusId(char* name, int *id); + * extern TuxDrvError TuxDrv_GetStatusState(int id, char *state); + * extern TuxDrvError TuxDrv_GetStatusValue(int id, char *value); + * extern void TuxDrv_GetAllStatusState(char *state); + * extern int TuxDrv_TokenizeStatus(char *status, drv_tokens_t *tokens); + * extern void TuxDrv_ResetPositions(void); + * extern void TuxDrv_ResetDongle(void); + * extern double get_time(void); + */ + +#ifndef _TUX_DRIVER_H_ +#define _TUX_DRIVER_H_ + +#include <stdbool.h> + +#ifndef WINAPI +# define WINAPI +#endif + +/** + * Id enumeration of high level status. + */ +typedef enum { + SW_ID_WINGS_POSITION = 0, + SW_ID_WINGS_REMAINING_MVM, + SW_ID_SPINNING_DIRECTION, + SW_ID_SPINNING_REMAINING_MVM, + SW_ID_LEFT_WING_BUTTON, + SW_ID_RIGHT_WING_BUTTON, + SW_ID_HEAD_BUTTON, + SW_ID_REMOTE_BUTTON, + SW_ID_MOUTH_POSITION, + SW_ID_MOUTH_REMAINING_MVM, + SW_ID_EYES_POSITION, + SW_ID_EYES_REMAINING_MVM, + SW_ID_DESCRIPTOR_COMPLETE, + SW_ID_RF_STATE, + SW_ID_DONGLE_PLUG, + SW_ID_CHARGER_STATE, + SW_ID_BATTERY_LEVEL, + SW_ID_BATTERY_STATE, + SW_ID_LIGHT_LEVEL, + SW_ID_LEFT_LED_STATE, + SW_ID_RIGHT_LED_STATE, + SW_ID_CONNECTION_QUALITY, + SW_ID_AUDIO_FLASH_PLAY, + SW_ID_AUDIO_GENERAL_PLAY, + SW_ID_FLASH_PROG_CURR_TRACK, + SW_ID_FLASH_PROG_LAST_TRACK_SIZE, + SW_ID_TUXCORE_SYMBOLIC_VERSION, + SW_ID_TUXAUDIO_SYMBOLIC_VERSION, + SW_ID_FUXUSB_SYMBOLIC_VERSION, + SW_ID_FUXRF_SYMBOLIC_VERSION, + SW_ID_TUXRF_SYMBOLIC_VERSION, + SW_ID_DRIVER_SYMBOLIC_VERSION, + SW_ID_SOUND_REFLASH_BEGIN, + SW_ID_SOUND_REFLASH_END, + SW_ID_SOUND_REFLASH_CURRENT_TRACK, +} SW_ID_DRIVER; + +#if defined(__cplusplus) +extern "C" { +#endif + +/** + * Error codes + */ +#define TUX_ERROR_BEGIN 256 +typedef int TuxDrvError; +typedef enum +{ + E_TUXDRV_NOERROR = 0, + E_TUXDRV_PARSERISDISABLED = TUX_ERROR_BEGIN, + E_TUXDRV_INVALIDCOMMAND, + E_TUXDRV_STACKOVERFLOW, + E_TUXDRV_FILEERROR, + E_TUXDRV_BADWAVFILE, + E_TUXDRV_INVALIDIDENTIFIER, + E_TUXDRV_INVALIDNAME, + E_TUXDRV_INVALIDPARAMETER, + E_TUXDRV_BUSY, + E_TUXDRV_WAVSIZEEXCEDED, +} tux_drv_error_t; + +/** + * CPU number enumeration. + */ +typedef enum { + TUXCORE_CPU_NUM = 0, + TUXAUDIO_CPU_NUM = 1, + TUXRF_CPU_NUM = 2, + FUXRF_CPU_NUM = 3, + FUXUSB_CPU_NUM = 4, + INVALID_CPU_NUM = -1, +} CPU_IDENTIFIERS; + +/** + * Descriptor structure of a firmaware. + */ +typedef struct { + CPU_IDENTIFIERS cpu_id; + unsigned int version_major; + unsigned int version_minor; + unsigned int version_update; + unsigned int revision; + bool release; + bool local_modification; + bool mixed_revisions; + unsigned int author; + unsigned int variation; + char version_string[256]; +} firmware_descriptor_t; + +/** + * Descriptor structure of sound flash. + */ +typedef struct { + unsigned int number_of_sounds; + unsigned int flash_usage; + unsigned int available_record_time; +} sound_flash_descriptor_t; + +/** + * Descriptor structure of ID connection. + */ +typedef struct { + unsigned int number; +} id_descriptor_t; + +/** + * Global descriptor structure of tuxdroid. + */ +typedef struct { + struct firmwares_t { + firmware_descriptor_t *package; + firmware_descriptor_t *tuxcore; + firmware_descriptor_t *tuxaudio; + firmware_descriptor_t *tuxrf; + firmware_descriptor_t *fuxrf; + firmware_descriptor_t *fuxusb; + } firmwares; + struct driver_version_t { + unsigned int version_major; + unsigned int version_minor; + unsigned int version_update; + unsigned int version_build; + char version_state[100]; + char version_string[100]; + } driver; + sound_flash_descriptor_t *sound_flash; + id_descriptor_t *id; +} tux_descriptor_t; + +/** + * Simple callback definition. + */ +typedef void(*drv_simple_callback_t)(void); + +/** + * Status callback definition. + */ +typedef void(*drv_status_callback_t)(char *status); + +/** + * Tokens structure + */ +typedef char drv_token_str_t[1024]; +typedef drv_token_str_t drv_tokens_t[256]; + +/** + * Logging target + */ +typedef enum log_target +{ + LOG_TARGET_TUX, + LOG_TARGET_SHELL +} log_target_t; + +/** + * Logging levels, in increasing priorities + */ +typedef enum log_level +{ + LOG_LEVEL_DEBUG, + LOG_LEVEL_INFO, + LOG_LEVEL_WARNING, + LOG_LEVEL_ERROR, + LOG_LEVEL_NONE +} log_level_t; + +/** + * Dynamic library definitions for specific os. + */ + +/** + * Windows arch. + */ +#ifdef WIN32 +# ifndef LOADSYMBOL +# define LOADSYMBOL GetProcAddress +# endif +# ifndef CLOSELIB +# define CLOSELIB FreeLibrary +# endif +# ifndef DYNHANDLE + typedef HMODULE DYNHANDLE; +# endif +/** + * Linux and mac arch. + */ +#else +# ifndef HWND +# define HWND void* +# endif +# ifndef HMODULE +# define HMODULE void* +# endif +# include <dlfcn.h> +# include <unistd.h> +# include <stdlib.h> +# include <string.h> +# ifndef LOADSYMBOL +# define LOADSYMBOL dlsym +# endif +# ifndef CLOSELIB +# define CLOSELIB dlclose +# endif +# ifndef DYNHANDLE + typedef void* DYNHANDLE; +# endif +#endif +/** + * Common arch. + */ +#ifndef DDECL +# define DDECL(x) LP_##x x=NULL; +#endif +#ifndef DCLEAR +# define DCLEAR(x) x=NULL; +#endif +#ifndef DYN +# define DYN(x) x=( LP_##x )LOADSYMBOL(hMod,#x); +#endif + +/** + * Function prototypes + */ +typedef void (WINAPI *LP_TuxDrv_Start)(void); +typedef void (WINAPI *LP_TuxDrv_Stop)(void); +typedef const char * (WINAPI *LP_TuxDrv_StrError)(TuxDrvError error_code); +typedef void (WINAPI *LP_TuxDrv_GetDescriptor)(tux_descriptor_t *tux_desc); +typedef void (WINAPI *LP_TuxDrv_SetStatusCallback)(drv_status_callback_t funct); +typedef void (WINAPI *LP_TuxDrv_SetEndCycleCallback)(drv_simple_callback_t funct); +typedef void (WINAPI *LP_TuxDrv_SetDongleConnectedCallback)(drv_simple_callback_t funct); +typedef void (WINAPI *LP_TuxDrv_SetDongleDisconnectedCallback)(drv_simple_callback_t funct); +typedef TuxDrvError (WINAPI *LP_TuxDrv_PerformCommand)(double delay, char *cmd_str); +typedef void (WINAPI *LP_TuxDrv_ClearCommandStack)(void); +typedef TuxDrvError (WINAPI *LP_TuxDrv_PerformMacroFile)(char *file_path); +typedef TuxDrvError (WINAPI *LP_TuxDrv_PerformMacroText)(char *macro); +typedef TuxDrvError (WINAPI *LP_TuxDrv_SoundReflash)(char *tracks); +typedef void (WINAPI *LP_TuxDrv_SetLogLevel)(log_level_t level); +typedef void (WINAPI *LP_TuxDrv_SetLogTarget)(log_target_t target); +typedef TuxDrvError (WINAPI *LP_TuxDrv_GetStatusName)(int id, char* name); +typedef TuxDrvError (WINAPI *LP_TuxDrv_GetStatusId)(char* name, int *id); +typedef TuxDrvError (WINAPI *LP_TuxDrv_GetStatusState)(int id, char *state); +typedef TuxDrvError (WINAPI *LP_TuxDrv_GetStatusValue)(int id, char *value); +typedef void (WINAPI *LP_TuxDrv_GetAllStatusState)(char *state); +typedef int (WINAPI *LP_TuxDrv_TokenizeStatus)(char *status, drv_tokens_t *tokens); +typedef void (WINAPI *LP_TuxDrv_ResetPositions)(void); +typedef void (WINAPI *LP_TuxDrv_ResetDongle)(void); +typedef double (WINAPI *LP_get_time)(void); + +/** + * Made instance of functions. + */ +DDECL(TuxDrv_Start); +DDECL(TuxDrv_Stop); +DDECL(TuxDrv_StrError); +DDECL(TuxDrv_GetDescriptor); +DDECL(TuxDrv_SetStatusCallback); +DDECL(TuxDrv_SetEndCycleCallback); +DDECL(TuxDrv_SetDongleConnectedCallback); +DDECL(TuxDrv_SetDongleDisconnectedCallback); +DDECL(TuxDrv_PerformCommand); +DDECL(TuxDrv_ClearCommandStack); +DDECL(TuxDrv_PerformMacroFile); +DDECL(TuxDrv_PerformMacroText); +DDECL(TuxDrv_SoundReflash); +DDECL(TuxDrv_SetLogLevel); +DDECL(TuxDrv_SetLogTarget); +DDECL(TuxDrv_GetStatusName); +DDECL(TuxDrv_GetStatusId); +DDECL(TuxDrv_GetStatusState); +DDECL(TuxDrv_GetStatusValue); +DDECL(TuxDrv_GetAllStatusState); +DDECL(TuxDrv_TokenizeStatus); +DDECL(TuxDrv_ResetPositions); +DDECL(TuxDrv_ResetDongle); +DDECL(get_time); + +/** + * Declaration of the handle to the library. + */ +HMODULE _TUXDRIVER_hMod = NULL; + +/** + * Get the function address in the library. + */ +void +LoadFunctions(hMod) +HMODULE hMod; +{ + _TUXDRIVER_hMod = hMod; + DYN(TuxDrv_Start); + DYN(TuxDrv_Stop); + DYN(TuxDrv_StrError); + DYN(TuxDrv_GetDescriptor); + DYN(TuxDrv_SetStatusCallback); + DYN(TuxDrv_SetEndCycleCallback); + DYN(TuxDrv_SetDongleConnectedCallback); + DYN(TuxDrv_SetDongleDisconnectedCallback); + DYN(TuxDrv_PerformCommand); + DYN(TuxDrv_ClearCommandStack); + DYN(TuxDrv_PerformMacroFile); + DYN(TuxDrv_PerformMacroText); + DYN(TuxDrv_SoundReflash); + DYN(TuxDrv_SetLogLevel); + DYN(TuxDrv_SetLogTarget); + DYN(TuxDrv_GetStatusName); + DYN(TuxDrv_GetStatusId); + DYN(TuxDrv_GetStatusState); + DYN(TuxDrv_GetStatusValue); + DYN(TuxDrv_GetAllStatusState); + DYN(TuxDrv_TokenizeStatus); + DYN(TuxDrv_ResetPositions); + DYN(TuxDrv_ResetDongle); + DYN(get_time); +} + +/** + * Initialization of library. + */ +HMODULE +TuxDrv_InitDll(lpsz) +const char *lpsz; +{ + + HMODULE hMod = NULL; +#ifdef WIN32 + hMod = LoadLibrary(lpsz); + if(!hMod || (hMod < (HMODULE)32)) + return hMod; +#else + hMod = dlopen(lpsz, RTLD_NOW); + if(!hMod) + return NULL; + + setenv("TUXDRIVERLIBPATH", lpsz, 1); +#endif + LoadFunctions(hMod); + return hMod; +} + +/** + * Finalization of library. + */ +long +TuxDrv_UninitDll() +{ + CLOSELIB(_TUXDRIVER_hMod); + _TUXDRIVER_hMod = NULL; + DCLEAR(TuxDrv_Start); + DCLEAR(TuxDrv_Stop); + DCLEAR(TuxDrv_StrError); + DCLEAR(TuxDrv_GetDescriptor); + DCLEAR(TuxDrv_SetStatusCallback); + DCLEAR(TuxDrv_SetEndCycleCallback); + DCLEAR(TuxDrv_SetDongleConnectedCallback); + DCLEAR(TuxDrv_SetDongleDisconnectedCallback); + DCLEAR(TuxDrv_PerformCommand); + DCLEAR(TuxDrv_ClearCommandStack); + DCLEAR(TuxDrv_PerformMacroFile); + DCLEAR(TuxDrv_PerformMacroText); + DCLEAR(TuxDrv_SoundReflash); + DCLEAR(TuxDrv_SetLogLevel); + DCLEAR(TuxDrv_SetLogTarget); + DCLEAR(TuxDrv_GetStatusName); + DCLEAR(TuxDrv_GetStatusId); + DCLEAR(TuxDrv_GetStatusState); + DCLEAR(TuxDrv_GetStatusValue); + DCLEAR(TuxDrv_GetAllStatusState); + DCLEAR(TuxDrv_TokenizeStatus); + DCLEAR(TuxDrv_ResetPositions); + DCLEAR(TuxDrv_ResetDongle); + DCLEAR(get_time); + return 0; +} + +#if defined(__cplusplus) +} +#endif + +#endif /* _TUX_DRIVER_H_ */ Added: software_suite_v2/middleware/tuxdriver/trunk/libs/libusb.lib =================================================================== (Binary files differ) Property changes on: software_suite_v2/middleware/tuxdriver/trunk/libs/libusb.lib ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software_suite_v2/middleware/tuxdriver/trunk/src/log.c =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/src/log.c (rev 0) +++ software_suite_v2/middleware/tuxdriver/trunk/src/log.c 2008-04-17 09:12:05 UTC (rev 964) @@ -0,0 +1,217 @@ +/* + * Tux Droid - Log + * Copyright (C) 2007 C2ME S.A. <tux...@c2...> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include <stdlib.h> +#include <stdio.h> +#include <stdarg.h> +#include <time.h> +#include <assert.h> + +#include "log.h" + +/** Name of log file for target LOG_TARGET_TUX */ +#ifdef WIN32 +# define LOG_FILE "tux_driver.log" +#else +# define LOG_FILE "/var/log/tux_driver.log" +#endif + +/** All logged messages are prefixed with this text */ +#define LOG_PREFIX "tux_driver" + +/** Current logging level */ +static log_level_t current_level = LOG_LEVEL_INFO; + +/** Logging level names */ +static const char *level_names[] = +{ + [LOG_LEVEL_DEBUG] = "debug", + [LOG_LEVEL_INFO] = "info", + [LOG_LEVEL_WARNING] = "warning", + [LOG_LEVEL_ERROR] = "error", + [LOG_LEVEL_NONE] = "none" +}; + +/** Current logging target */ +static log_target_t log_target = LOG_TARGET_SHELL; + +/** Log file for target LOG_TARGET_TUX */ +static FILE *log_file; + +/** Whether the log has been opened */ +static bool log_opened; + +/** + * Open the log. + * + * /param[in] target Logging target + * + * /return true if successfull, false otherwise + */ +bool +log_open(log_target_t target) +{ + if (log_opened) + return true; + + switch (target) + { + case LOG_TARGET_TUX: + log_file = fopen(LOG_FILE, "at"); + if (log_file == NULL) + return false; + break; + + case LOG_TARGET_SHELL: + break; + } + + log_target = target; + log_opened = true; + + return true; +} + +/** + * Close the log. + */ +void +log_close(void) +{ + if (!log_opened) + return; + + switch (log_target) + { + case LOG_TARGET_TUX: + fclose(log_file); + log_file = NULL; + break; + + case LOG_TARGET_SHELL: + break; + } + + log_opened = false; +} + +/** + * Set the logging level. + * + * /param[in] new_level New logging level + */ +void +log_set_level(log_level_t new_level) +{ + assert(new_level >= LOG_LEVEL_DEBUG && new_level <= LOG_LEVEL_NONE); + current_level = new_level; +} + +/** + * Get the logging level. + * + * /return current logging level + */ +log_level_t +log_get_level(void) +{ + return current_level; +} + +/** + * Log formatted message at the specified level. + * + * /param[in] at_level Level to log the message at + * /param[in] fmt Message format + * /param[in] ... Optional message data + * + * If the priority of the specifed level is lower than the priority + * of the current logging level, the message is silently dropped. + * + * /return true if successful, false otherwise + */ +bool +log_text(log_level_t at_level, const char *fmt, ...) +{ + char text[1024], *p = text; + size_t size = sizeof(text); + time_t now; + va_list al; + int r; + + /* No need for the log to be 'opened' when logging to std{out,err} */ + if (log_target != LOG_TARGET_SHELL && !log_opened) + return false; + + /* Logging at level NONE has no sense */ + assert(at_level >= LOG_LEVEL_DEBUG && at_level < LOG_LEVEL_NONE); + + if (at_level < current_level) + return true; + + /* Add date & time when LOG_TARGET_TUX */ + if (log_target == LOG_TARGET_TUX) + { + now = time(NULL); +#ifdef WIN32 + r = strftime(p, size, "%y-%m-%d %H-%M-%S ", localtime(&now)); +#else + r = strftime(p, size, "%F %T ", localtime(&now)); +#endif + if (r == 0) + return false; + + p += r; + size -= r; + } + + /* Only prefix non-INFO level messages */ + if (at_level != LOG_LEVEL_INFO) + { + r = snprintf(p, size, "%s: ", level_names[at_level]); + if (r < 0) + return false; + + p += r; + size -= r; + } + + va_start(al, fmt); + r = vsnprintf(p, size, fmt, al); + va_end(al); + if (r < 0) + return false; + + switch (log_target) + { + case LOG_TARGET_TUX: + fprintf(log_file, "%s\n", text); + break; + + case LOG_TARGET_SHELL: + if (at_level == LOG_LEVEL_WARNING || at_level == LOG_LEVEL_ERROR) + fprintf(stderr, "tux_driver: %s\n", text); + else + fprintf(stdout, "tux_driver: %s\n", text); + break; + } + + return true; +} Added: software_suite_v2/middleware/tuxdriver/trunk/src/log.h =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/src/log.h (rev 0) +++ software_suite_v2/middleware/tuxdriver/trunk/src/log.h 2008-04-17 09:12:05 UTC (rev 964) @@ -0,0 +1,37 @@ +#ifndef __LOG_H__ +#define __LOG_H__ + +#include <stdbool.h> + +/** Logging target */ +typedef enum log_target +{ + LOG_TARGET_TUX, + LOG_TARGET_SHELL +} log_target_t; + +extern bool log_open(log_target_t target); +extern void log_close(void); + +/** Logging levels, in increasing priorities */ +typedef enum log_level +{ + LOG_LEVEL_DEBUG, + LOG_LEVEL_INFO, + LOG_LEVEL_WARNING, + LOG_LEVEL_ERROR, + LOG_LEVEL_NONE +} log_level_t; + +extern void log_set_level(log_level_t new_level); +extern log_level_t log_get_level(void); + +extern bool log_text(log_level_t at_level, const char *fmt, ...) + __attribute__((format(printf, 2, 3))); + +#define log_debug(fmt, ...) log_text(LOG_LEVEL_DEBUG, (fmt), ## __VA_ARGS__) +#define log_info(fmt, ...) log_text(LOG_LEVEL_INFO, (fmt), ## __VA_ARGS__) +#define log_warning(fmt, ...) log_text(LOG_LEVEL_WARNING, (fmt), ## __VA_ARGS__) +#define log_error(fmt, ...) log_text(LOG_LEVEL_ERROR, (fmt), ## __VA_ARGS__) + +#endif /* __LOG_H__ */ Added: software_suite_v2/middleware/tuxdriver/trunk/src/threading_uniform.h =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/src/threading_uniform.h (rev 0) +++ software_suite_v2/middleware/tuxdriver/trunk/src/threading_uniform.h 2008-04-17 09:12:05 UTC (rev 964) @@ -0,0 +1,54 @@ +/* + * FICHIER .H pour la realisation de THREADS PORTABLES LINUX/WINDOWS + * + * ce code a it par Smeagol(sme...@if...) et revu par + * Jerry Kan (pil...@gm...) + * pour le site + * http://www.irrlicht.fr/ communautrancaise Irrlicht + * + * retrouvez ce tutoriel et beaucoup d'autres sur notre forum, + */ + +#ifdef USE_MUTEX +#ifndef _THREADING_UNIFORM_H_ +#define _THREADING_UNIFORM_H_ + +#ifdef WIN32 +# include <windows.h> +# define callback_t unsigned long __stdcall +# define thread_t HANDLE +# define thread_create(thrd, fct, param) thrd = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)(fct),(param),0,NULL) +# define thread_delete(thrd) CloseHandle(thrd); +# define thread_wait_close(thrd) WaitForMultipleObjects(1, &thrd, TRUE, INFINITE) +# define mutex_t CRITICAL_SECTION +# define mutex_init(mutex) InitializeCriticalSection(& mutex) +# define mutex_lock(mutex) EnterCriticalSection(& mutex) +# define mutex_unlock(mutex) LeaveCriticalSection(& mutex) +# define mutex_delete(mutex) DeleteCriticalSection(& mutex) +# define semaphore_t HANDLE +# define semaphore_init(sema, max, place) ((sema) = CreateSemaphore(NULL, (max), (place), NULL)) +# define semaphore_lock(sema) WaitForSingleObject((sema), INFINITE) +# define semaphore_unlock(sema) ReleaseSemaphore((sema), 1, NULL) +# define semaphore_delete(sema) CloseHandle(sema) +#else +# include <pthread.h> +# define callback_t void * +# define thread_t pthread_t +# define thread_create(thrd, fct, param) pthread_create(&thrd, NULL, (fct), ((void *)param)); +# define thread_delete(thrd) +# define thread_wait_close(thrd) pthread_join(thrd, NULL) +# include <semaphore.h> +# define mutex_t pthread_mutex_t +# define mutex_init(mutex) pthread_mutex_init ((&mutex), NULL) +# define mutex_lock(mutex) pthread_mutex_lock((&mutex)) +# define mutex_unlock(mutex) pthread_mutex_unlock((&mutex)) +# define mutex_delete(mutex) pthread_mutex_destroy((&mutex)) +# define semaphore_t sem_t* +# define semaphore_init(sema, max, place) (sema) = new sem_t; sem_init ((sema), (max), (place)) +# define semaphore_lock(sema) sem_wait((sema)) +# define semaphore_unlock(sema) sem_post((sema)) +# define semaphore_delete(sema) sem_destroy((sema)); delete ((sema)) +#endif + +#endif +#endif Added: software_suite_v2/middleware/tuxdriver/trunk/src/tux_audio.c =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/src/tux_audio.c (rev 0) +++ software_suite_v2/middleware/tuxdriver/trunk/src/tux_audio.c 2008-04-17 09:12:05 UTC (rev 964) @@ -0,0 +1,71 @@ +/* + * Tux Droid - Audio + * Copyright (C) 2008 C2ME Sa + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <stdlib.h> +#include "tux_hw_cmd.h" +#include "tux_audio.h" +#include "tux_usb.h" + +/** + * + */ +LIBLOCAL bool +tux_audio_cmd_channel_general(void) +{ + unsigned char frame[TUX_SEND_LENGTH - 1] = {USB_DONGLE_AUDIO_CMD, + 0, 0, 0}; + return tux_usb_send_to_dongle(frame); +} + +/** + * + */ +LIBLOCAL bool +tux_audio_cmd_channel_tts(void) +{ + unsigned char frame[TUX_SEND_LENGTH - 1] = {USB_DONGLE_AUDIO_CMD, + 1, 0, 0}; + return tux_usb_send_to_dongle(frame); +} + +/** + * + */ +LIBLOCAL bool +tux_audio_cmd_mute(char *value) +{ + unsigned char frame[TUX_SEND_LENGTH - 1] = {AUDIO_MUTE_CMD, + 0, 0, 0}; + bool m_value; + + if (!str_to_bool(value, &m_value)) + return false; + + if (m_value) + frame[1] = 1; + else + frame[1] = 0; + + return tux_usb_send_to_tux(frame); +} + Added: software_suite_v2/middleware/tuxdriver/trunk/src/tux_audio.h =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/src/tux_audio.h (rev 0) +++ software_suite_v2/middleware/tuxdriver/trunk/src/tux_audio.h 2008-04-17 09:12:05 UTC (rev 964) @@ -0,0 +1,30 @@ +/* + * Tux Droid - Audio + * Copyright (C) 2008 C2ME Sa + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef _TUX_AUDIO_H_ +#define _TUX_AUDIO_H_ + +#include "tux_misc.h" + +extern bool tux_audio_cmd_channel_general(void); +extern bool tux_audio_cmd_channel_tts(void); +extern bool tux_audio_cmd_mute(char *value); + +#endif /* _TUX_AUDIO_H_ */ Added: software_suite_v2/middleware/tuxdriver/trunk/src/tux_battery.c =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/src/tux_battery.c (rev 0) +++ software_suite_v2/middleware/tuxdriver/trunk/src/tux_battery.c 2008-04-17 09:12:05 UTC (rev 964) @@ -0,0 +1,92 @@ +/* + * Tux Droid - Battery + * Copyright (C) 2008 C2ME Sa + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <stdlib.h> +#include <math.h> +#include "tux_hw_status.h" +#include "tux_sw_status.h" +#include "tux_battery.h" + +typedef enum +{ + FULL, + HIGH, + LOW, + EMPTY, +} battery_state_t; + +static battery_state_t battery_state = EMPTY; +static float last_level_for_event = 0.0; + +/** + * Update the status of the battery voltage. + */ +LIBLOCAL void +tux_battery_update_level(void) +{ + float new_level = 0.0; + float old_level = 0.0; + int adc_value; + char *new_state_str = ""; + char *old_state_str = ""; + + adc_value = (hw_status_table.battery.high_level << 8); + adc_value += hw_status_table.battery.low_level; + new_level = adc_value * 0.00322 * 2.319; + + old_level = *(float *)tux_sw_status_get_value(SW_ID_BATTERY_LEVEL); + + if (fabs(new_level - last_level_for_event) > 0.1) { + last_level_for_event = new_level; + if (!hw_status_table.battery.motors_state) + tux_sw_status_set_value(SW_ID_BATTERY_LEVEL, + (void *)&new_level, true); + + if (new_level >= TUX_BATTERY_FULL_VALUE) { + new_state_str = STRING_VALUE_FULL; + battery_state = FULL; + } else if ((new_level < TUX_BATTERY_FULL_VALUE) && + (new_level >= TUX_BATTERY_HIGH_VALUE)) + { + new_state_str = STRING_VALUE_HIGH; + battery_state = HIGH; + } else if ((new_level < TUX_BATTERY_HIGH_VALUE) && + (new_level >= TUX_BATTERY_LOW_VALUE)) + { + new_state_str = STRING_VALUE_LOW; + battery_state = LOW; + } else { + new_state_str = STRING_VALUE_EMPTY; + battery_state = EMPTY; + } + + old_state_str = (char *)tux_sw_status_get_value(SW_ID_BATTERY_STATE); + + if (strcmp(new_state_str, old_state_str)) + tux_sw_status_set_value(SW_ID_BATTERY_STATE, (void *)new_state_str, + true); + } else + if (old_level != new_level) + tux_sw_status_set_value(SW_ID_BATTERY_LEVEL, (void *)&new_level, + false); +} Added: software_suite_v2/middleware/tuxdriver/trunk/src/tux_battery.h =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/src/tux_battery.h (rev 0) +++ software_suite_v2/middleware/tuxdriver/trunk/src/tux_battery.h 2008-04-17 09:12:05 UTC (rev 964) @@ -0,0 +1,31 @@ +/* + * Tux Droid - Battery + * Copyright (C) 2008 C2ME Sa + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef _TUX_BATTERY_H_ +#define _TUX_BATTERY_H_ + +#define TUX_BATTERY_FULL_VALUE 6.0 +#define TUX_BATTERY_HIGH_VALUE 5.4 +#define TUX_BATTERY_LOW_VALUE 4.5 +#define TUX_BATTERY_EMPTY_VALUE 0.0 + +extern void tux_battery_update_level(void); + +#endif /* _TUX_BATTERY_H_ */ Added: software_suite_v2/middleware/tuxdriver/trunk/src/tux_cmd_parser.c =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/src/tux_cmd_parser.c (rev 0) +++ software_suite_v2/middleware/tuxdriver/trunk/src/tux_cmd_parser.c 2008-04-17 09:12:05 UTC (rev 964) @@ -0,0 +1,498 @@ +/* + * Tux Droid - Command parser + * Copyright (C) 2008 C2ME Sa + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include <string.h> +#include <errno.h> +#ifdef USE_MUTEX +# include "threading_uniform.h" +#endif +#include "tux_misc.h" +#include "tux_cmd_parser.h" +#include "tux_usb.h" +#include "tux_eyes.h" +#include "tux_mouth.h" +#include "tux_wings.h" +#include "tux_spinning.h" +#include "tux_user_inputs.h" +#include "tux_leds.h" +#include "tux_sound_flash.h" +#include "tux_audio.h" +#include "log.h" +#include "tux_error.h" + +typedef struct { + double timeout; + char cmd[1024]; +} delay_cmd_t; + +typedef struct { + delay_cmd_t cmd_list[256]; + int cmd_count; +} cmd_stack_t; + +static cmd_stack_t user_cmd_stack; +static cmd_stack_t sys_cmd_stack; +#ifdef USE_MUTEX +static mutex_t __stack_mutex; +static mutex_t __macro_mutex; +#endif +static bool cmd_parser_enable = true; + +/** + * + */ +LIBLOCAL void +tux_cmd_parser_init(void) +{ + memset(&user_cmd_stack, 0, sizeof(cmd_stack_t)); + memset(&sys_cmd_stack, 0, sizeof(cmd_stack_t)); +#ifdef USE_MUTEX + mutex_init(__stack_mutex); + mutex_init(__macro_mutex); +#endif +} + +/** + * + */ +LIBLOCAL void +tux_cmd_parser_set_enable(bool value) +{ + cmd_parser_enable = value; +} + +/** + * + */ +/* TODO : It has surely a better way to do this. */ +LIBLOCAL int +tux_cmd_parser_get_tokens(char *src_str, tokens_t *toks, int max_tokens) +{ + tokens_t tokens; + char tok[12] = "%[^:,]%[:,]"; + char toke[7] = "%[^\n]"; + char reg_ex[1024] = ""; + char ts[8] = ""; + int i; + + for (i = 0; i < (max_tokens - 1); i++) + strncat(reg_ex, tok, sizeof(tok) - 1); + + strncat(reg_ex, toke, sizeof(toke) - 1); + + i = sscanf(src_str, reg_ex, + tokens[0], ts, tokens[1], ts, tokens[2], ts, tokens[3], ts, + tokens[4], ts, tokens[5], ts, tokens[6], ts, tokens[7], ts, + tokens[8], ts, tokens[9], ts, tokens[10], ts, tokens[11], ts, + tokens[12], ts, tokens[13], ts, tokens[14], ts, tokens[15], ts, + tokens[16], ts, tokens[17], ts, tokens[18], ts, tokens[19], ts, + tokens[20], ts, tokens[21], ts, tokens[22], ts, tokens[23], ts, + tokens[24], ts, tokens[25], ts, tokens[26], ts, tokens[27], ts, + tokens[28], ts, tokens[29], ts, tokens[30], ts, tokens[31], ts); + + memcpy(toks, &tokens, sizeof(tokens_t)); + + i -= i / 2; + return i; +} + +/** + * + */ +static bool +tux_cmd_parser_parse_raw_cmd(char *p0, char *p1, char *p2, char *p3, char *p4) +{ + unsigned char data[TUX_SEND_LENG... [truncated message content] |