mirror of
				https://github.com/mik3y/usb-serial-for-android
				synced 2025-10-31 02:17:23 +00:00 
			
		
		
		
	Initial commit.
This commit is contained in:
		
						commit
						bd50024ebc
					
				
							
								
								
									
										3
									
								
								CHANGELOG.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								CHANGELOG.txt
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | |||||||
|  | 2011-12-28  mike wakerly  <opensource@hoho.com> | ||||||
|  | 
 | ||||||
|  | 	* Initial release. | ||||||
							
								
								
									
										165
									
								
								LICENSE.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										165
									
								
								LICENSE.txt
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,165 @@ | |||||||
|  |                    GNU LESSER GENERAL PUBLIC LICENSE | ||||||
|  |                        Version 3, 29 June 2007 | ||||||
|  | 
 | ||||||
|  |  Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> | ||||||
|  |  Everyone is permitted to copy and distribute verbatim copies | ||||||
|  |  of this license document, but changing it is not allowed. | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |   This version of the GNU Lesser General Public License incorporates | ||||||
|  | the terms and conditions of version 3 of the GNU General Public | ||||||
|  | License, supplemented by the additional permissions listed below. | ||||||
|  | 
 | ||||||
|  |   0. Additional Definitions. | ||||||
|  | 
 | ||||||
|  |   As used herein, "this License" refers to version 3 of the GNU Lesser | ||||||
|  | General Public License, and the "GNU GPL" refers to version 3 of the GNU | ||||||
|  | General Public License. | ||||||
|  | 
 | ||||||
|  |   "The Library" refers to a covered work governed by this License, | ||||||
|  | other than an Application or a Combined Work as defined below. | ||||||
|  | 
 | ||||||
|  |   An "Application" is any work that makes use of an interface provided | ||||||
|  | by the Library, but which is not otherwise based on the Library. | ||||||
|  | Defining a subclass of a class defined by the Library is deemed a mode | ||||||
|  | of using an interface provided by the Library. | ||||||
|  | 
 | ||||||
|  |   A "Combined Work" is a work produced by combining or linking an | ||||||
|  | Application with the Library.  The particular version of the Library | ||||||
|  | with which the Combined Work was made is also called the "Linked | ||||||
|  | Version". | ||||||
|  | 
 | ||||||
|  |   The "Minimal Corresponding Source" for a Combined Work means the | ||||||
|  | Corresponding Source for the Combined Work, excluding any source code | ||||||
|  | for portions of the Combined Work that, considered in isolation, are | ||||||
|  | based on the Application, and not on the Linked Version. | ||||||
|  | 
 | ||||||
|  |   The "Corresponding Application Code" for a Combined Work means the | ||||||
|  | object code and/or source code for the Application, including any data | ||||||
|  | and utility programs needed for reproducing the Combined Work from the | ||||||
|  | Application, but excluding the System Libraries of the Combined Work. | ||||||
|  | 
 | ||||||
|  |   1. Exception to Section 3 of the GNU GPL. | ||||||
|  | 
 | ||||||
|  |   You may convey a covered work under sections 3 and 4 of this License | ||||||
|  | without being bound by section 3 of the GNU GPL. | ||||||
|  | 
 | ||||||
|  |   2. Conveying Modified Versions. | ||||||
|  | 
 | ||||||
|  |   If you modify a copy of the Library, and, in your modifications, a | ||||||
|  | facility refers to a function or data to be supplied by an Application | ||||||
|  | that uses the facility (other than as an argument passed when the | ||||||
|  | facility is invoked), then you may convey a copy of the modified | ||||||
|  | version: | ||||||
|  | 
 | ||||||
|  |    a) under this License, provided that you make a good faith effort to | ||||||
|  |    ensure that, in the event an Application does not supply the | ||||||
|  |    function or data, the facility still operates, and performs | ||||||
|  |    whatever part of its purpose remains meaningful, or | ||||||
|  | 
 | ||||||
|  |    b) under the GNU GPL, with none of the additional permissions of | ||||||
|  |    this License applicable to that copy. | ||||||
|  | 
 | ||||||
|  |   3. Object Code Incorporating Material from Library Header Files. | ||||||
|  | 
 | ||||||
|  |   The object code form of an Application may incorporate material from | ||||||
|  | a header file that is part of the Library.  You may convey such object | ||||||
|  | code under terms of your choice, provided that, if the incorporated | ||||||
|  | material is not limited to numerical parameters, data structure | ||||||
|  | layouts and accessors, or small macros, inline functions and templates | ||||||
|  | (ten or fewer lines in length), you do both of the following: | ||||||
|  | 
 | ||||||
|  |    a) Give prominent notice with each copy of the object code that the | ||||||
|  |    Library is used in it and that the Library and its use are | ||||||
|  |    covered by this License. | ||||||
|  | 
 | ||||||
|  |    b) Accompany the object code with a copy of the GNU GPL and this license | ||||||
|  |    document. | ||||||
|  | 
 | ||||||
|  |   4. Combined Works. | ||||||
|  | 
 | ||||||
|  |   You may convey a Combined Work under terms of your choice that, | ||||||
|  | taken together, effectively do not restrict modification of the | ||||||
|  | portions of the Library contained in the Combined Work and reverse | ||||||
|  | engineering for debugging such modifications, if you also do each of | ||||||
|  | the following: | ||||||
|  | 
 | ||||||
|  |    a) Give prominent notice with each copy of the Combined Work that | ||||||
|  |    the Library is used in it and that the Library and its use are | ||||||
|  |    covered by this License. | ||||||
|  | 
 | ||||||
|  |    b) Accompany the Combined Work with a copy of the GNU GPL and this license | ||||||
|  |    document. | ||||||
|  | 
 | ||||||
|  |    c) For a Combined Work that displays copyright notices during | ||||||
|  |    execution, include the copyright notice for the Library among | ||||||
|  |    these notices, as well as a reference directing the user to the | ||||||
|  |    copies of the GNU GPL and this license document. | ||||||
|  | 
 | ||||||
|  |    d) Do one of the following: | ||||||
|  | 
 | ||||||
|  |        0) Convey the Minimal Corresponding Source under the terms of this | ||||||
|  |        License, and the Corresponding Application Code in a form | ||||||
|  |        suitable for, and under terms that permit, the user to | ||||||
|  |        recombine or relink the Application with a modified version of | ||||||
|  |        the Linked Version to produce a modified Combined Work, in the | ||||||
|  |        manner specified by section 6 of the GNU GPL for conveying | ||||||
|  |        Corresponding Source. | ||||||
|  | 
 | ||||||
|  |        1) Use a suitable shared library mechanism for linking with the | ||||||
|  |        Library.  A suitable mechanism is one that (a) uses at run time | ||||||
|  |        a copy of the Library already present on the user's computer | ||||||
|  |        system, and (b) will operate properly with a modified version | ||||||
|  |        of the Library that is interface-compatible with the Linked | ||||||
|  |        Version. | ||||||
|  | 
 | ||||||
|  |    e) Provide Installation Information, but only if you would otherwise | ||||||
|  |    be required to provide such information under section 6 of the | ||||||
|  |    GNU GPL, and only to the extent that such information is | ||||||
|  |    necessary to install and execute a modified version of the | ||||||
|  |    Combined Work produced by recombining or relinking the | ||||||
|  |    Application with a modified version of the Linked Version. (If | ||||||
|  |    you use option 4d0, the Installation Information must accompany | ||||||
|  |    the Minimal Corresponding Source and Corresponding Application | ||||||
|  |    Code. If you use option 4d1, you must provide the Installation | ||||||
|  |    Information in the manner specified by section 6 of the GNU GPL | ||||||
|  |    for conveying Corresponding Source.) | ||||||
|  | 
 | ||||||
|  |   5. Combined Libraries. | ||||||
|  | 
 | ||||||
|  |   You may place library facilities that are a work based on the | ||||||
|  | Library side by side in a single library together with other library | ||||||
|  | facilities that are not Applications and are not covered by this | ||||||
|  | License, and convey such a combined library under terms of your | ||||||
|  | choice, if you do both of the following: | ||||||
|  | 
 | ||||||
|  |    a) Accompany the combined library with a copy of the same work based | ||||||
|  |    on the Library, uncombined with any other library facilities, | ||||||
|  |    conveyed under the terms of this License. | ||||||
|  | 
 | ||||||
|  |    b) Give prominent notice with the combined library that part of it | ||||||
|  |    is a work based on the Library, and explaining where to find the | ||||||
|  |    accompanying uncombined form of the same work. | ||||||
|  | 
 | ||||||
|  |   6. Revised Versions of the GNU Lesser General Public License. | ||||||
|  | 
 | ||||||
|  |   The Free Software Foundation may publish revised and/or new versions | ||||||
|  | of the GNU Lesser 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 | ||||||
|  | Library as you received it specifies that a certain numbered version | ||||||
|  | of the GNU Lesser General Public License "or any later version" | ||||||
|  | applies to it, you have the option of following the terms and | ||||||
|  | conditions either of that published version or of any later version | ||||||
|  | published by the Free Software Foundation. If the Library as you | ||||||
|  | received it does not specify a version number of the GNU Lesser | ||||||
|  | General Public License, you may choose any version of the GNU Lesser | ||||||
|  | General Public License ever published by the Free Software Foundation. | ||||||
|  | 
 | ||||||
|  |   If the Library as you received it specifies that a proxy can decide | ||||||
|  | whether future versions of the GNU Lesser General Public License shall | ||||||
|  | apply, that proxy's public statement of acceptance of any version is | ||||||
|  | permanent authorization for you to choose that version for the | ||||||
|  | Library. | ||||||
							
								
								
									
										81
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,81 @@ | |||||||
|  | # usb-serial-for-android | ||||||
|  | 
 | ||||||
|  | Library for talking to Arduinos and other USB serial devices on Android, using | ||||||
|  | USB Host mode and Android 3.1+ | ||||||
|  | 
 | ||||||
|  | Homepage: http://code.google.com/p/usb-serial-for-android | ||||||
|  | 
 | ||||||
|  | ## About | ||||||
|  | 
 | ||||||
|  | This project provides an Android userspace driver for USB serial devices.  You | ||||||
|  | can use it to talk to your Arduino, or any other supported serial devices. | ||||||
|  | 
 | ||||||
|  | ## Usage | ||||||
|  | 
 | ||||||
|  | Download the sources.  Inside you will find two Eclipse projects: | ||||||
|  | 
 | ||||||
|  | * UsbSerialLibrary - the main library code, an "Android Library" project. | ||||||
|  | * UsbSerialExamples - a demo Android application | ||||||
|  | 
 | ||||||
|  | In Eclipse, open "File", "Import", and then select "General, "Existing Projects | ||||||
|  | into Workspace". | ||||||
|  | 
 | ||||||
|  | Navigate to the directory you just checked out and import both projects.  Then | ||||||
|  | run the demo application. | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | ## Compatible Serial Devices | ||||||
|  | 
 | ||||||
|  | Supported and tested: | ||||||
|  | 
 | ||||||
|  | *   FT232R | ||||||
|  | 
 | ||||||
|  | Possibly supported (untested): | ||||||
|  | 
 | ||||||
|  | *   FT232H | ||||||
|  | *   FT2232D | ||||||
|  | *   FT2432H | ||||||
|  | 
 | ||||||
|  | Unsupported (send patches!): | ||||||
|  | 
 | ||||||
|  | *   Arduino Uno (CDC) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | ## Compatible Android Devices | ||||||
|  | 
 | ||||||
|  | Supported and tested: | ||||||
|  | 
 | ||||||
|  | *   Motorola Xoom, Android 3.1/3.2 | ||||||
|  | 
 | ||||||
|  | Possibly supported (untested): | ||||||
|  | 
 | ||||||
|  | *   Samsung Galaxy Tab 10.1 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | ## License and Copyright | ||||||
|  | 
 | ||||||
|  | This library is licensed under LGPL Version 2.1.  Please see LICENSE.txt for the | ||||||
|  | complete license. | ||||||
|  | 
 | ||||||
|  | Copyright 2011, Google Inc. All Rights Reserved. | ||||||
|  | 
 | ||||||
|  | Portions of this library are based on libftdi | ||||||
|  | (http://www.intra2net.com/en/developer/libftdi).  Please see | ||||||
|  | FtdiSerialDriver.java for more information. | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | ## Contributing | ||||||
|  | 
 | ||||||
|  | Patches are welcome.  We're especially interested in supporting more devices. | ||||||
|  | Please open a bug report. | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | ## Credits | ||||||
|  | 
 | ||||||
|  | Author/maintainer: mike wakerly <opensource@hoho.com> | ||||||
|  | 
 | ||||||
|  | Contributors: | ||||||
|  | 
 | ||||||
|  | *   Robert Tsai <rob@tsaiberspace.com> (code review) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
							
								
								
									
										9
									
								
								UsbSerialExamples/.classpath
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								UsbSerialExamples/.classpath
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | |||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <classpath> | ||||||
|  | 	<classpathentry combineaccessrules="false" kind="src" path="/UsbSerialLibrary"/> | ||||||
|  | 	<classpathentry kind="src" path="src"/> | ||||||
|  | 	<classpathentry kind="src" path="gen"/> | ||||||
|  | 	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> | ||||||
|  | 	<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> | ||||||
|  | 	<classpathentry kind="output" path="bin/classes"/> | ||||||
|  | </classpath> | ||||||
							
								
								
									
										33
									
								
								UsbSerialExamples/.project
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								UsbSerialExamples/.project
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | |||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <projectDescription> | ||||||
|  | 	<name>UsbSerialExamples</name> | ||||||
|  | 	<comment></comment> | ||||||
|  | 	<projects> | ||||||
|  | 	</projects> | ||||||
|  | 	<buildSpec> | ||||||
|  | 		<buildCommand> | ||||||
|  | 			<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> | ||||||
|  | 			<arguments> | ||||||
|  | 			</arguments> | ||||||
|  | 		</buildCommand> | ||||||
|  | 		<buildCommand> | ||||||
|  | 			<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> | ||||||
|  | 			<arguments> | ||||||
|  | 			</arguments> | ||||||
|  | 		</buildCommand> | ||||||
|  | 		<buildCommand> | ||||||
|  | 			<name>org.eclipse.jdt.core.javabuilder</name> | ||||||
|  | 			<arguments> | ||||||
|  | 			</arguments> | ||||||
|  | 		</buildCommand> | ||||||
|  | 		<buildCommand> | ||||||
|  | 			<name>com.android.ide.eclipse.adt.ApkBuilder</name> | ||||||
|  | 			<arguments> | ||||||
|  | 			</arguments> | ||||||
|  | 		</buildCommand> | ||||||
|  | 	</buildSpec> | ||||||
|  | 	<natures> | ||||||
|  | 		<nature>com.android.ide.eclipse.adt.AndroidNature</nature> | ||||||
|  | 		<nature>org.eclipse.jdt.core.javanature</nature> | ||||||
|  | 	</natures> | ||||||
|  | </projectDescription> | ||||||
							
								
								
									
										280
									
								
								UsbSerialExamples/.settings/org.eclipse.jdt.core.prefs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										280
									
								
								UsbSerialExamples/.settings/org.eclipse.jdt.core.prefs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,280 @@ | |||||||
|  | #Thu Jun 02 12:32:09 PDT 2011 | ||||||
|  | eclipse.preferences.version=1 | ||||||
|  | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||||||
|  | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 | ||||||
|  | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||||||
|  | org.eclipse.jdt.core.compiler.compliance=1.6 | ||||||
|  | org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||||||
|  | org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||||||
|  | org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||||||
|  | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||||||
|  | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||||||
|  | org.eclipse.jdt.core.compiler.source=1.6 | ||||||
|  | org.eclipse.jdt.core.formatter.align_type_members_on_columns=false | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_assignment=0 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_after_package=1 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_before_field=0 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_before_method=1 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_before_package=1 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.format_block_comments=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.format_header=false | ||||||
|  | org.eclipse.jdt.core.formatter.comment.format_html=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.format_line_comments=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.format_source_code=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.indent_root_tags=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert | ||||||
|  | org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.comment.line_length=80 | ||||||
|  | org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true | ||||||
|  | org.eclipse.jdt.core.formatter.compact_else_if=true | ||||||
|  | org.eclipse.jdt.core.formatter.continuation_indentation=2 | ||||||
|  | org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 | ||||||
|  | org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off | ||||||
|  | org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on | ||||||
|  | org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false | ||||||
|  | org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true | ||||||
|  | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true | ||||||
|  | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true | ||||||
|  | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true | ||||||
|  | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true | ||||||
|  | org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true | ||||||
|  | org.eclipse.jdt.core.formatter.indent_empty_lines=false | ||||||
|  | org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true | ||||||
|  | org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true | ||||||
|  | org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true | ||||||
|  | org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true | ||||||
|  | org.eclipse.jdt.core.formatter.indentation.size=4 | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.join_lines_in_comments=true | ||||||
|  | org.eclipse.jdt.core.formatter.join_wrapped_lines=false | ||||||
|  | org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false | ||||||
|  | org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false | ||||||
|  | org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false | ||||||
|  | org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false | ||||||
|  | org.eclipse.jdt.core.formatter.lineSplit=100 | ||||||
|  | org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false | ||||||
|  | org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false | ||||||
|  | org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 | ||||||
|  | org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 | ||||||
|  | org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true | ||||||
|  | org.eclipse.jdt.core.formatter.tabulation.char=space | ||||||
|  | org.eclipse.jdt.core.formatter.tabulation.size=4 | ||||||
|  | org.eclipse.jdt.core.formatter.use_on_off_tags=false | ||||||
|  | org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false | ||||||
|  | org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true | ||||||
|  | org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true | ||||||
							
								
								
									
										4
									
								
								UsbSerialExamples/.settings/org.eclipse.jdt.ui.prefs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								UsbSerialExamples/.settings/org.eclipse.jdt.ui.prefs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | |||||||
|  | #Thu Apr 21 23:18:48 PDT 2011 | ||||||
|  | eclipse.preferences.version=1 | ||||||
|  | formatter_profile=_Android | ||||||
|  | formatter_settings_version=11 | ||||||
							
								
								
									
										32
									
								
								UsbSerialExamples/AndroidManifest.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								UsbSerialExamples/AndroidManifest.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | |||||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||||
|  | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||||||
|  |     package="com.hoho.android.usbserial.examples" | ||||||
|  |     android:versionCode="1" | ||||||
|  |     android:versionName="1.0" > | ||||||
|  | 
 | ||||||
|  |     <uses-sdk android:minSdkVersion="12" /> | ||||||
|  |      | ||||||
|  |     <uses-feature android:name="android.hardware.usb.host" /> | ||||||
|  | 
 | ||||||
|  |     <application | ||||||
|  |         android:icon="@drawable/ic_launcher" | ||||||
|  |         android:label="@string/app_name" > | ||||||
|  |         <activity | ||||||
|  |             android:label="@string/app_name" | ||||||
|  |             android:name="com.hoho.android.usbserial.examples.DemoActivity" > | ||||||
|  |             <intent-filter > | ||||||
|  |                 <action android:name="android.intent.action.MAIN" /> | ||||||
|  |                 <category android:name="android.intent.category.DEFAULT" /> | ||||||
|  |                 <category android:name="android.intent.category.LAUNCHER" /> | ||||||
|  |             </intent-filter> | ||||||
|  |             <intent-filter> | ||||||
|  |                 <action | ||||||
|  |                     android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /> | ||||||
|  |             </intent-filter> | ||||||
|  |             <meta-data | ||||||
|  |                 android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" | ||||||
|  |                 android:resource="@xml/device_filter" /> | ||||||
|  |         </activity> | ||||||
|  |     </application> | ||||||
|  | 
 | ||||||
|  | </manifest> | ||||||
							
								
								
									
										40
									
								
								UsbSerialExamples/proguard.cfg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								UsbSerialExamples/proguard.cfg
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | |||||||
|  | -optimizationpasses 5 | ||||||
|  | -dontusemixedcaseclassnames | ||||||
|  | -dontskipnonpubliclibraryclasses | ||||||
|  | -dontpreverify | ||||||
|  | -verbose | ||||||
|  | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* | ||||||
|  | 
 | ||||||
|  | -keep public class * extends android.app.Activity | ||||||
|  | -keep public class * extends android.app.Application | ||||||
|  | -keep public class * extends android.app.Service | ||||||
|  | -keep public class * extends android.content.BroadcastReceiver | ||||||
|  | -keep public class * extends android.content.ContentProvider | ||||||
|  | -keep public class * extends android.app.backup.BackupAgentHelper | ||||||
|  | -keep public class * extends android.preference.Preference | ||||||
|  | -keep public class com.android.vending.licensing.ILicensingService | ||||||
|  | 
 | ||||||
|  | -keepclasseswithmembernames class * { | ||||||
|  |     native <methods>; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | -keepclasseswithmembers class * { | ||||||
|  |     public <init>(android.content.Context, android.util.AttributeSet); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | -keepclasseswithmembers class * { | ||||||
|  |     public <init>(android.content.Context, android.util.AttributeSet, int); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | -keepclassmembers class * extends android.app.Activity { | ||||||
|  |    public void *(android.view.View); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | -keepclassmembers enum * { | ||||||
|  |     public static **[] values(); | ||||||
|  |     public static ** valueOf(java.lang.String); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | -keep class * implements android.os.Parcelable { | ||||||
|  |   public static final android.os.Parcelable$Creator *; | ||||||
|  | } | ||||||
							
								
								
									
										12
									
								
								UsbSerialExamples/project.properties
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								UsbSerialExamples/project.properties
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | |||||||
|  | # This file is automatically generated by Android Tools. | ||||||
|  | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! | ||||||
|  | # | ||||||
|  | # This file must be checked in Version Control Systems. | ||||||
|  | # | ||||||
|  | # To customize properties used by the Ant build system use, | ||||||
|  | # "ant.properties", and override values to adapt the script to your | ||||||
|  | # project structure. | ||||||
|  | 
 | ||||||
|  | # Project target. | ||||||
|  | target=android-12 | ||||||
|  | android.library.reference.1=../UsbSerialLibrary | ||||||
							
								
								
									
										
											BIN
										
									
								
								UsbSerialExamples/res/drawable-hdpi/ic_launcher.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								UsbSerialExamples/res/drawable-hdpi/ic_launcher.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 4.0 KiB | 
							
								
								
									
										
											BIN
										
									
								
								UsbSerialExamples/res/drawable-ldpi/ic_launcher.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								UsbSerialExamples/res/drawable-ldpi/ic_launcher.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.7 KiB | 
							
								
								
									
										
											BIN
										
									
								
								UsbSerialExamples/res/drawable-mdpi/ic_launcher.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								UsbSerialExamples/res/drawable-mdpi/ic_launcher.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 2.5 KiB | 
							
								
								
									
										26
									
								
								UsbSerialExamples/res/layout/main.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								UsbSerialExamples/res/layout/main.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,26 @@ | |||||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||||
|  | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||||
|  |     android:layout_width="fill_parent" | ||||||
|  |     android:layout_height="fill_parent" | ||||||
|  |     android:orientation="vertical" > | ||||||
|  | 
 | ||||||
|  |     <TextView | ||||||
|  |         android:id="@+id/demoTitle" | ||||||
|  |         android:layout_width="match_parent" | ||||||
|  |         android:layout_height="wrap_content" | ||||||
|  |         android:text="@string/hello" /> | ||||||
|  | 
 | ||||||
|  |     <ScrollView | ||||||
|  |         android:id="@+id/demoScroller" | ||||||
|  |         android:layout_width="match_parent" | ||||||
|  |         android:layout_height="wrap_content" > | ||||||
|  | 
 | ||||||
|  |         <TextView | ||||||
|  |             android:id="@+id/demoText" | ||||||
|  |             android:layout_width="match_parent" | ||||||
|  |             android:layout_height="match_parent" | ||||||
|  |             android:typeface="monospace" /> | ||||||
|  |          | ||||||
|  |     </ScrollView> | ||||||
|  | 
 | ||||||
|  | </LinearLayout> | ||||||
							
								
								
									
										7
									
								
								UsbSerialExamples/res/values/strings.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								UsbSerialExamples/res/values/strings.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | |||||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||||
|  | <resources> | ||||||
|  | 
 | ||||||
|  |     <string name="hello">Hello World, DemoActivity!</string> | ||||||
|  |     <string name="app_name">UsbSerialExamples</string> | ||||||
|  | 
 | ||||||
|  | </resources> | ||||||
							
								
								
									
										5
									
								
								UsbSerialExamples/res/xml/device_filter.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								UsbSerialExamples/res/xml/device_filter.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,5 @@ | |||||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||||
|  | <resources> | ||||||
|  |     <!-- 0x0403 / 0x6001: FTDI FT232R UART --> | ||||||
|  |     <usb-device vendor-id="1027" product-id="24577" /> | ||||||
|  | </resources> | ||||||
| @ -0,0 +1,165 @@ | |||||||
|  | /* Copyright 2011 Google Inc. | ||||||
|  |  * | ||||||
|  |  * This library is free software; you can redistribute it and/or | ||||||
|  |  * modify it under the terms of the GNU Lesser General Public | ||||||
|  |  * License as published by the Free Software Foundation; either | ||||||
|  |  * version 2.1 of the License, or (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * This library 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 | ||||||
|  |  * Lesser General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU Lesser General Public | ||||||
|  |  * License along with this library; if not, write to the Free Software | ||||||
|  |  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, | ||||||
|  |  * USA. | ||||||
|  |  * | ||||||
|  |  * Project home page: http://code.google.com/p/usb-serial-for-android/ | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package com.hoho.android.usbserial.examples; | ||||||
|  | 
 | ||||||
|  | import android.app.Activity; | ||||||
|  | import android.content.Context; | ||||||
|  | import android.hardware.usb.UsbManager; | ||||||
|  | import android.os.Bundle; | ||||||
|  | import android.util.Log; | ||||||
|  | import android.widget.ScrollView; | ||||||
|  | import android.widget.TextView; | ||||||
|  | 
 | ||||||
|  | import com.hoho.android.usbserial.R; | ||||||
|  | import com.hoho.android.usbserial.driver.UsbSerialDriver; | ||||||
|  | import com.hoho.android.usbserial.driver.UsbSerialProber; | ||||||
|  | import com.hoho.android.usbserial.util.HexDump; | ||||||
|  | import com.hoho.android.usbserial.util.SerialInputOutputManager; | ||||||
|  | 
 | ||||||
|  | import java.io.IOException; | ||||||
|  | import java.util.concurrent.ExecutorService; | ||||||
|  | import java.util.concurrent.Executors; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * A sample Activity demonstrating USB-Serial support. | ||||||
|  |  * | ||||||
|  |  * @author mike wakerly (opensource@hoho.com) | ||||||
|  |  */ | ||||||
|  | public class DemoActivity extends Activity { | ||||||
|  | 
 | ||||||
|  |     private final String TAG = DemoActivity.class.getSimpleName(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * The device currently in use, or {@code null}. | ||||||
|  |      */ | ||||||
|  |     private UsbSerialDriver mSerialDevice; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * The system's USB service. | ||||||
|  |      */ | ||||||
|  |     private UsbManager mUsbManager; | ||||||
|  | 
 | ||||||
|  |     private TextView mTitleTextView; | ||||||
|  |     private TextView mDumpTextView; | ||||||
|  |     private ScrollView mScrollView; | ||||||
|  | 
 | ||||||
|  |     private final ExecutorService mExecutor = Executors.newSingleThreadExecutor(); | ||||||
|  | 
 | ||||||
|  |     private SerialInputOutputManager mSerialIoManager; | ||||||
|  | 
 | ||||||
|  |     private final SerialInputOutputManager.Listener mListener = | ||||||
|  |             new SerialInputOutputManager.Listener() { | ||||||
|  | 
 | ||||||
|  |         @Override | ||||||
|  |         public void onRunError(Exception e) { | ||||||
|  |             Log.d(TAG, "Runner stopped."); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         @Override | ||||||
|  |         public void onNewData(final byte[] data) { | ||||||
|  |             DemoActivity.this.runOnUiThread(new Runnable() { | ||||||
|  |                 @Override | ||||||
|  |                 public void run() { | ||||||
|  |                     DemoActivity.this.updateReceivedData(data); | ||||||
|  |                 } | ||||||
|  |             }); | ||||||
|  |         } | ||||||
|  |     }; | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public void onCreate(Bundle savedInstanceState) { | ||||||
|  |         super.onCreate(savedInstanceState); | ||||||
|  |         setContentView(R.layout.main); | ||||||
|  |         mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE); | ||||||
|  |         mTitleTextView = (TextView) findViewById(R.id.demoTitle); | ||||||
|  |         mDumpTextView = (TextView) findViewById(R.id.demoText); | ||||||
|  |         mScrollView = (ScrollView) findViewById(R.id.demoScroller); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     protected void onPause() { | ||||||
|  |         super.onPause(); | ||||||
|  |         stopIoManager(); | ||||||
|  |         if (mSerialDevice != null) { | ||||||
|  |             try { | ||||||
|  |                 mSerialDevice.close(); | ||||||
|  |             } catch (IOException e) { | ||||||
|  |                 // Ignore. | ||||||
|  |             } | ||||||
|  |             mSerialDevice = null; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     protected void onResume() { | ||||||
|  |         super.onResume(); | ||||||
|  |         mSerialDevice = UsbSerialProber.acquire(mUsbManager); | ||||||
|  |         Log.d(TAG, "Resumed, mSerialDevice=" + mSerialDevice); | ||||||
|  |         if (mSerialDevice == null) { | ||||||
|  |             mTitleTextView.setText("No serial device."); | ||||||
|  |         } else { | ||||||
|  |             try { | ||||||
|  |                 mSerialDevice.open(); | ||||||
|  |             } catch (IOException e) { | ||||||
|  |                 Log.e(TAG, "Error setting up device: " + e.getMessage(), e); | ||||||
|  |                 mTitleTextView.setText("Error opening device: " + e.getMessage()); | ||||||
|  |                 try { | ||||||
|  |                     mSerialDevice.close(); | ||||||
|  |                 } catch (IOException e2) { | ||||||
|  |                     // Ignore. | ||||||
|  |                 } | ||||||
|  |                 mSerialDevice = null; | ||||||
|  |                 return; | ||||||
|  |             } | ||||||
|  |             mTitleTextView.setText("Serial device: " + mSerialDevice); | ||||||
|  |         } | ||||||
|  |         onDeviceStateChange(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private void stopIoManager() { | ||||||
|  |         if (mSerialIoManager != null) { | ||||||
|  |             Log.i(TAG, "Stopping io manager .."); | ||||||
|  |             mSerialIoManager.stop(); | ||||||
|  |             mSerialIoManager = null; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private void startIoManager() { | ||||||
|  |         if (mSerialDevice != null) { | ||||||
|  |             Log.i(TAG, "Starting io manager .."); | ||||||
|  |             mSerialIoManager = new SerialInputOutputManager(mSerialDevice, mListener); | ||||||
|  |             mExecutor.submit(mSerialIoManager); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private void onDeviceStateChange() { | ||||||
|  |         stopIoManager(); | ||||||
|  |         startIoManager(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private void updateReceivedData(byte[] data) { | ||||||
|  |         final String message = "Read " + data.length + " bytes: \n" | ||||||
|  |                 + HexDump.dumpHexString(data) + "\n\n"; | ||||||
|  |         mDumpTextView.append(message); | ||||||
|  |         mScrollView.smoothScrollTo(0, mDumpTextView.getBottom()); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
							
								
								
									
										7
									
								
								UsbSerialLibrary/.classpath
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								UsbSerialLibrary/.classpath
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | |||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <classpath> | ||||||
|  | 	<classpathentry kind="src" path="src"/> | ||||||
|  | 	<classpathentry kind="src" path="gen"/> | ||||||
|  | 	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> | ||||||
|  | 	<classpathentry kind="output" path="bin/classes"/> | ||||||
|  | </classpath> | ||||||
							
								
								
									
										33
									
								
								UsbSerialLibrary/.project
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								UsbSerialLibrary/.project
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | |||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <projectDescription> | ||||||
|  | 	<name>UsbSerialLibrary</name> | ||||||
|  | 	<comment></comment> | ||||||
|  | 	<projects> | ||||||
|  | 	</projects> | ||||||
|  | 	<buildSpec> | ||||||
|  | 		<buildCommand> | ||||||
|  | 			<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> | ||||||
|  | 			<arguments> | ||||||
|  | 			</arguments> | ||||||
|  | 		</buildCommand> | ||||||
|  | 		<buildCommand> | ||||||
|  | 			<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> | ||||||
|  | 			<arguments> | ||||||
|  | 			</arguments> | ||||||
|  | 		</buildCommand> | ||||||
|  | 		<buildCommand> | ||||||
|  | 			<name>org.eclipse.jdt.core.javabuilder</name> | ||||||
|  | 			<arguments> | ||||||
|  | 			</arguments> | ||||||
|  | 		</buildCommand> | ||||||
|  | 		<buildCommand> | ||||||
|  | 			<name>com.android.ide.eclipse.adt.ApkBuilder</name> | ||||||
|  | 			<arguments> | ||||||
|  | 			</arguments> | ||||||
|  | 		</buildCommand> | ||||||
|  | 	</buildSpec> | ||||||
|  | 	<natures> | ||||||
|  | 		<nature>com.android.ide.eclipse.adt.AndroidNature</nature> | ||||||
|  | 		<nature>org.eclipse.jdt.core.javanature</nature> | ||||||
|  | 	</natures> | ||||||
|  | </projectDescription> | ||||||
							
								
								
									
										280
									
								
								UsbSerialLibrary/.settings/org.eclipse.jdt.core.prefs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										280
									
								
								UsbSerialLibrary/.settings/org.eclipse.jdt.core.prefs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,280 @@ | |||||||
|  | #Thu Jun 02 12:32:09 PDT 2011 | ||||||
|  | eclipse.preferences.version=1 | ||||||
|  | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||||||
|  | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 | ||||||
|  | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||||||
|  | org.eclipse.jdt.core.compiler.compliance=1.6 | ||||||
|  | org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||||||
|  | org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||||||
|  | org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||||||
|  | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||||||
|  | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||||||
|  | org.eclipse.jdt.core.compiler.source=1.6 | ||||||
|  | org.eclipse.jdt.core.formatter.align_type_members_on_columns=false | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_assignment=0 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 | ||||||
|  | org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_after_package=1 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_before_field=0 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_before_method=1 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_before_package=1 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 | ||||||
|  | org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line | ||||||
|  | org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.format_block_comments=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.format_header=false | ||||||
|  | org.eclipse.jdt.core.formatter.comment.format_html=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.format_line_comments=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.format_source_code=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.indent_root_tags=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert | ||||||
|  | org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.comment.line_length=80 | ||||||
|  | org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true | ||||||
|  | org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true | ||||||
|  | org.eclipse.jdt.core.formatter.compact_else_if=true | ||||||
|  | org.eclipse.jdt.core.formatter.continuation_indentation=2 | ||||||
|  | org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 | ||||||
|  | org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off | ||||||
|  | org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on | ||||||
|  | org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false | ||||||
|  | org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true | ||||||
|  | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true | ||||||
|  | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true | ||||||
|  | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true | ||||||
|  | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true | ||||||
|  | org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true | ||||||
|  | org.eclipse.jdt.core.formatter.indent_empty_lines=false | ||||||
|  | org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true | ||||||
|  | org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true | ||||||
|  | org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true | ||||||
|  | org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true | ||||||
|  | org.eclipse.jdt.core.formatter.indentation.size=4 | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert | ||||||
|  | org.eclipse.jdt.core.formatter.join_lines_in_comments=true | ||||||
|  | org.eclipse.jdt.core.formatter.join_wrapped_lines=false | ||||||
|  | org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false | ||||||
|  | org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false | ||||||
|  | org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false | ||||||
|  | org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false | ||||||
|  | org.eclipse.jdt.core.formatter.lineSplit=100 | ||||||
|  | org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false | ||||||
|  | org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false | ||||||
|  | org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 | ||||||
|  | org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 | ||||||
|  | org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true | ||||||
|  | org.eclipse.jdt.core.formatter.tabulation.char=space | ||||||
|  | org.eclipse.jdt.core.formatter.tabulation.size=4 | ||||||
|  | org.eclipse.jdt.core.formatter.use_on_off_tags=false | ||||||
|  | org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false | ||||||
|  | org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true | ||||||
|  | org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true | ||||||
							
								
								
									
										4
									
								
								UsbSerialLibrary/.settings/org.eclipse.jdt.ui.prefs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								UsbSerialLibrary/.settings/org.eclipse.jdt.ui.prefs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | |||||||
|  | #Thu Apr 21 23:18:48 PDT 2011 | ||||||
|  | eclipse.preferences.version=1 | ||||||
|  | formatter_profile=_Android | ||||||
|  | formatter_settings_version=11 | ||||||
							
								
								
									
										7
									
								
								UsbSerialLibrary/AndroidManifest.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								UsbSerialLibrary/AndroidManifest.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | |||||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||||
|  | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||||||
|  |       package="com.hoho.android.usbserial" | ||||||
|  |       android:versionCode="1" | ||||||
|  |       android:versionName="1.0"> | ||||||
|  |     <uses-sdk android:minSdkVersion="12" /> | ||||||
|  | </manifest> | ||||||
							
								
								
									
										36
									
								
								UsbSerialLibrary/proguard.cfg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								UsbSerialLibrary/proguard.cfg
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,36 @@ | |||||||
|  | -optimizationpasses 5 | ||||||
|  | -dontusemixedcaseclassnames | ||||||
|  | -dontskipnonpubliclibraryclasses | ||||||
|  | -dontpreverify | ||||||
|  | -verbose | ||||||
|  | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* | ||||||
|  | 
 | ||||||
|  | -keep public class * extends android.app.Activity | ||||||
|  | -keep public class * extends android.app.Application | ||||||
|  | -keep public class * extends android.app.Service | ||||||
|  | -keep public class * extends android.content.BroadcastReceiver | ||||||
|  | -keep public class * extends android.content.ContentProvider | ||||||
|  | -keep public class * extends android.app.backup.BackupAgentHelper | ||||||
|  | -keep public class * extends android.preference.Preference | ||||||
|  | -keep public class com.android.vending.licensing.ILicensingService | ||||||
|  | 
 | ||||||
|  | -keepclasseswithmembernames class * { | ||||||
|  |     native <methods>; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | -keepclasseswithmembernames class * { | ||||||
|  |     public <init>(android.content.Context, android.util.AttributeSet); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | -keepclasseswithmembernames class * { | ||||||
|  |     public <init>(android.content.Context, android.util.AttributeSet, int); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | -keepclassmembers enum * { | ||||||
|  |     public static **[] values(); | ||||||
|  |     public static ** valueOf(java.lang.String); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | -keep class * implements android.os.Parcelable { | ||||||
|  |   public static final android.os.Parcelable$Creator *; | ||||||
|  | } | ||||||
							
								
								
									
										12
									
								
								UsbSerialLibrary/project.properties
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								UsbSerialLibrary/project.properties
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | |||||||
|  | # This file is automatically generated by Android Tools. | ||||||
|  | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! | ||||||
|  | # | ||||||
|  | # This file must be checked in Version Control Systems. | ||||||
|  | # | ||||||
|  | # To customize properties used by the Ant build system use, | ||||||
|  | # "ant.properties", and override values to adapt the script to your | ||||||
|  | # project structure. | ||||||
|  | 
 | ||||||
|  | # Project target. | ||||||
|  | target=android-12 | ||||||
|  | android.library=true | ||||||
| @ -0,0 +1,376 @@ | |||||||
|  | /* Copyright 2011 Google Inc. | ||||||
|  |  * | ||||||
|  |  * This library is free software; you can redistribute it and/or | ||||||
|  |  * modify it under the terms of the GNU Lesser General Public | ||||||
|  |  * License as published by the Free Software Foundation; either | ||||||
|  |  * version 2.1 of the License, or (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * This library 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 | ||||||
|  |  * Lesser General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU Lesser General Public | ||||||
|  |  * License along with this library; if not, write to the Free Software | ||||||
|  |  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, | ||||||
|  |  * USA. | ||||||
|  |  * | ||||||
|  |  * Project home page: http://code.google.com/p/usb-serial-for-android/ | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package com.hoho.android.usbserial.driver; | ||||||
|  | 
 | ||||||
|  | import android.hardware.usb.UsbConstants; | ||||||
|  | import android.hardware.usb.UsbDevice; | ||||||
|  | import android.hardware.usb.UsbDeviceConnection; | ||||||
|  | import android.hardware.usb.UsbEndpoint; | ||||||
|  | import android.util.Log; | ||||||
|  | 
 | ||||||
|  | import java.io.IOException; | ||||||
|  | import java.util.Arrays; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * A {@link UsbSerialDriver} implementation for a variety of FTDI devices | ||||||
|  |  * <p> | ||||||
|  |  * This driver is based on <a | ||||||
|  |  * href="http://www.intra2net.com/en/developer/libftdi">libftdi</a>, and is | ||||||
|  |  * copyright and subject to the following terms: | ||||||
|  |  * | ||||||
|  |  * <pre> | ||||||
|  |  *   Copyright (C) 2003 by Intra2net AG | ||||||
|  |  * | ||||||
|  |  *   This program is free software; you can redistribute it and/or modify | ||||||
|  |  *   it under the terms of the GNU Lesser General Public License | ||||||
|  |  *   version 2.1 as published by the Free Software Foundation; | ||||||
|  |  * | ||||||
|  |  *   opensource@intra2net.com | ||||||
|  |  *   http://www.intra2net.com/en/developer/libftdi | ||||||
|  |  * </pre> | ||||||
|  |  * | ||||||
|  |  * </p> | ||||||
|  |  * <p> | ||||||
|  |  * Some FTDI devices have not been tested; see later listing of supported and | ||||||
|  |  * unsupported devices. Devices listed as "supported" support the following | ||||||
|  |  * features: | ||||||
|  |  * <ul> | ||||||
|  |  * <li>Read and write of serial data (see {@link #read(byte[], int)} and | ||||||
|  |  * {@link #write(byte[], int)}. | ||||||
|  |  * <li>Setting baud rate (see {@link #setBaudRate(int)}). | ||||||
|  |  * </ul> | ||||||
|  |  * </p> | ||||||
|  |  * <p> | ||||||
|  |  * Supported and tested devices: | ||||||
|  |  * <ul> | ||||||
|  |  * <li>{@value DeviceType#TYPE_R}</li> | ||||||
|  |  * </ul> | ||||||
|  |  * </p> | ||||||
|  |  * <p> | ||||||
|  |  * Unsupported but possibly working devices (please contact the author with | ||||||
|  |  * feedback or patches): | ||||||
|  |  * <ul> | ||||||
|  |  * <li>{@value DeviceType#TYPE_2232C}</li> | ||||||
|  |  * <li>{@value DeviceType#TYPE_2232H}</li> | ||||||
|  |  * <li>{@value DeviceType#TYPE_4232H}</li> | ||||||
|  |  * <li>{@value DeviceType#TYPE_AM}</li> | ||||||
|  |  * <li>{@value DeviceType#TYPE_BM}</li> | ||||||
|  |  * </ul> | ||||||
|  |  * </p> | ||||||
|  |  * | ||||||
|  |  * @author mike wakerly (opensource@hoho.com) | ||||||
|  |  * @see <a href="http://code.google.com/p/usb-serial-for-android/">USB Serial | ||||||
|  |  * for Android project page</a> | ||||||
|  |  * @see <a href="http://www.ftdichip.com/">FTDI Homepage</a> | ||||||
|  |  * @see <a href="http://www.intra2net.com/en/developer/libftdi">libftdi</a> | ||||||
|  |  */ | ||||||
|  | public class FtdiSerialDriver implements UsbSerialDriver { | ||||||
|  | 
 | ||||||
|  |     private static final int DEFAULT_BAUD_RATE = 115200; | ||||||
|  | 
 | ||||||
|  |     public static final int USB_TYPE_STANDARD = 0x00 << 5; | ||||||
|  |     public static final int USB_TYPE_CLASS = 0x00 << 5; | ||||||
|  |     public static final int USB_TYPE_VENDOR = 0x00 << 5; | ||||||
|  |     public static final int USB_TYPE_RESERVED = 0x00 << 5; | ||||||
|  | 
 | ||||||
|  |     public static final int USB_RECIP_DEVICE = 0x00; | ||||||
|  |     public static final int USB_RECIP_INTERFACE = 0x01; | ||||||
|  |     public static final int USB_RECIP_ENDPOINT = 0x02; | ||||||
|  |     public static final int USB_RECIP_OTHER = 0x03; | ||||||
|  | 
 | ||||||
|  |     public static final int USB_ENDPOINT_IN = 0x80; | ||||||
|  |     public static final int USB_ENDPOINT_OUT = 0x00; | ||||||
|  | 
 | ||||||
|  |     public static final int USB_WRITE_TIMEOUT_MILLIS = 5000; | ||||||
|  |     public static final int USB_READ_TIMEOUT_MILLIS = 5000; | ||||||
|  | 
 | ||||||
|  |     // From ftdi.h | ||||||
|  |     /** | ||||||
|  |      * Reset the port. | ||||||
|  |      */ | ||||||
|  |     private static final int SIO_RESET_REQUEST = 0; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Set the modem control register. | ||||||
|  |      */ | ||||||
|  |     private static final int SIO_MODEM_CTRL_REQUEST = 1; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Set flow control register. | ||||||
|  |      */ | ||||||
|  |     private static final int SIO_SET_FLOW_CTRL_REQUEST = 2; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Set baud rate. | ||||||
|  |      */ | ||||||
|  |     private static final int SIO_SET_BAUD_RATE_REQUEST = 3; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Set the data characteristics of the port. | ||||||
|  |      */ | ||||||
|  |     private static final int SIO_SET_DATA_REQUEST = 4; | ||||||
|  | 
 | ||||||
|  |     private static final int SIO_RESET_SIO = 0; | ||||||
|  | 
 | ||||||
|  |     public static final int FTDI_DEVICE_OUT_REQTYPE = | ||||||
|  |             UsbConstants.USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT; | ||||||
|  | 
 | ||||||
|  |     public static final int FTDI_DEVICE_IN_REQTYPE = | ||||||
|  |             UsbConstants.USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Size of chunks, used in {@link #write(byte[], int)}. | ||||||
|  |      */ | ||||||
|  |     private static final int WRITE_CHUNKSIZE = 4096; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Length of the modem status header, transmitted with every read. | ||||||
|  |      */ | ||||||
|  |     private static final int MODEM_STATUS_HEADER_LENGTH = 2; | ||||||
|  | 
 | ||||||
|  |     private final String TAG = FtdiSerialDriver.class.getSimpleName(); | ||||||
|  | 
 | ||||||
|  |     private UsbDevice mDevice; | ||||||
|  |     private UsbDeviceConnection mConnection; | ||||||
|  |     private DeviceType mType; | ||||||
|  | 
 | ||||||
|  |     private final byte[] mReadBuffer = new byte[4096]; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * FTDI chip types. | ||||||
|  |      */ | ||||||
|  |     private static enum DeviceType { | ||||||
|  |         TYPE_BM, TYPE_AM, TYPE_2232C, TYPE_R, TYPE_2232H, TYPE_4232H; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private int mInterface = 0; /* INTERFACE_ANY */ | ||||||
|  | 
 | ||||||
|  |     private int mMaxPacketSize = 64; // TODO(mikey): detect | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor. | ||||||
|  |      * | ||||||
|  |      * @param usbDevice the {@link UsbDevice} to use | ||||||
|  |      * @param usbConnection the {@link UsbDeviceConnection} to use | ||||||
|  |      * @throws UsbSerialRuntimeException if the given device is incompatible | ||||||
|  |      *             with this driver | ||||||
|  |      */ | ||||||
|  |     public FtdiSerialDriver(UsbDevice usbDevice, UsbDeviceConnection usbConnection) { | ||||||
|  |         if (!probe(usbDevice)) { | ||||||
|  |             throw new UsbSerialRuntimeException("Device type not supported."); | ||||||
|  |         } | ||||||
|  |         mConnection = usbConnection; | ||||||
|  |         mDevice = usbDevice; | ||||||
|  |         mType = null; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void reset() throws IOException { | ||||||
|  |         int result = mConnection.controlTransfer(FTDI_DEVICE_OUT_REQTYPE, SIO_RESET_REQUEST, | ||||||
|  |                 SIO_RESET_SIO, 0 /* index */, null, 0, USB_WRITE_TIMEOUT_MILLIS); | ||||||
|  |         if (result != 0) { | ||||||
|  |             throw new IOException("Reset failed: result=" + result); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // TODO(mikey): autodetect. | ||||||
|  |         mType = DeviceType.TYPE_R; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public void open() throws IOException { | ||||||
|  |         boolean opened = false; | ||||||
|  |         try { | ||||||
|  |             for (int i = 0; i < mDevice.getInterfaceCount(); i++) { | ||||||
|  |                 if (mConnection.claimInterface(mDevice.getInterface(i), true)) { | ||||||
|  |                     Log.d(TAG, "claimInterface " + i + " SUCCESS"); | ||||||
|  |                 } else { | ||||||
|  |                     Log.d(TAG, "claimInterface " + i + " FAIL"); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             reset(); | ||||||
|  |             setBaudRate(DEFAULT_BAUD_RATE); | ||||||
|  |             opened = true; | ||||||
|  |         } finally { | ||||||
|  |             if (!opened) { | ||||||
|  |                 close(); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public void close() { | ||||||
|  |         mConnection.close(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public int read(byte[] dest, int timeoutMillis) throws IOException { | ||||||
|  |         final int readAmt = Math.min(dest.length, mReadBuffer.length); | ||||||
|  |         final UsbEndpoint endpoint = mDevice.getInterface(0).getEndpoint(0); | ||||||
|  | 
 | ||||||
|  |         final int transferred = mConnection.bulkTransfer(endpoint, mReadBuffer, readAmt, | ||||||
|  |                 timeoutMillis); | ||||||
|  |         if (transferred < MODEM_STATUS_HEADER_LENGTH) { | ||||||
|  |             throw new IOException("Expected at least " + MODEM_STATUS_HEADER_LENGTH + " bytes"); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         final int nread = transferred - MODEM_STATUS_HEADER_LENGTH; | ||||||
|  |         if (nread > 0) { | ||||||
|  |             System.arraycopy(mReadBuffer, MODEM_STATUS_HEADER_LENGTH, dest, 0, nread); | ||||||
|  |         } | ||||||
|  |         return nread; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public int write(byte[] src, int timeoutMillis) throws IOException { | ||||||
|  |         final UsbEndpoint endpoint = mDevice.getInterface(0).getEndpoint(0); | ||||||
|  |         int offset = 0; | ||||||
|  | 
 | ||||||
|  |         while (offset < src.length) { | ||||||
|  |             final byte[] writeBuffer; | ||||||
|  |             final int writeLength; | ||||||
|  | 
 | ||||||
|  |             // bulkTransfer does not support offsets; make a copy if necessary. | ||||||
|  |             writeLength = Math.min(src.length - offset, WRITE_CHUNKSIZE); | ||||||
|  |             if (offset == 0) { | ||||||
|  |                 writeBuffer = src; | ||||||
|  |             } else { | ||||||
|  |                 writeBuffer = Arrays.copyOfRange(src, offset, offset + writeLength); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             final int amt = mConnection.bulkTransfer(endpoint, writeBuffer, writeLength, | ||||||
|  |                     timeoutMillis); | ||||||
|  |             if (amt <= 0) { | ||||||
|  |                 throw new IOException("Error writing " + writeLength | ||||||
|  |                         + " bytes at offset " + offset); | ||||||
|  |             } | ||||||
|  |             offset += amt; | ||||||
|  |         } | ||||||
|  |         return offset; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public int setBaudRate(int baudRate) throws IOException { | ||||||
|  |         long[] vals = convertBaudrate(baudRate); | ||||||
|  |         long actualBaudrate = vals[0]; | ||||||
|  |         long index = vals[1]; | ||||||
|  |         long value = vals[2]; | ||||||
|  |         Log.i(TAG, "Requested baudrate=" + baudRate + ", actual=" + actualBaudrate); | ||||||
|  | 
 | ||||||
|  |         int result = mConnection.controlTransfer(FTDI_DEVICE_OUT_REQTYPE, | ||||||
|  |                 SIO_SET_BAUD_RATE_REQUEST, (int) value, (int) index, | ||||||
|  |                 null, 0, USB_WRITE_TIMEOUT_MILLIS); | ||||||
|  |         if (result != 0) { | ||||||
|  |             throw new IOException("Setting baudrate failed: result=" + result); | ||||||
|  |         } | ||||||
|  |         return (int) actualBaudrate; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private long[] convertBaudrate(int baudrate) { | ||||||
|  |         // TODO(mikey): Braindead transcription of libfti method.  Clean up, | ||||||
|  |         // using more idiomatic Java where possible. | ||||||
|  |         int divisor = 24000000 / baudrate; | ||||||
|  |         int bestDivisor = 0; | ||||||
|  |         int bestBaud = 0; | ||||||
|  |         int bestBaudDiff = 0; | ||||||
|  |         int fracCode[] = { | ||||||
|  |                 0, 3, 2, 4, 1, 5, 6, 7 | ||||||
|  |         }; | ||||||
|  | 
 | ||||||
|  |         for (int i = 0; i < 2; i++) { | ||||||
|  |             int tryDivisor = divisor + i; | ||||||
|  |             int baudEstimate; | ||||||
|  |             int baudDiff; | ||||||
|  | 
 | ||||||
|  |             if (tryDivisor <= 8) { | ||||||
|  |                 // Round up to minimum supported divisor | ||||||
|  |                 tryDivisor = 8; | ||||||
|  |             } else if (mType != DeviceType.TYPE_AM && tryDivisor < 12) { | ||||||
|  |                 // BM doesn't support divisors 9 through 11 inclusive | ||||||
|  |                 tryDivisor = 12; | ||||||
|  |             } else if (divisor < 16) { | ||||||
|  |                 // AM doesn't support divisors 9 through 15 inclusive | ||||||
|  |                 tryDivisor = 16; | ||||||
|  |             } else { | ||||||
|  |                 if (mType == DeviceType.TYPE_AM) { | ||||||
|  |                     // TODO | ||||||
|  |                 } else { | ||||||
|  |                     if (tryDivisor > 0x1FFFF) { | ||||||
|  |                         // Round down to maximum supported divisor value (for | ||||||
|  |                         // BM) | ||||||
|  |                         tryDivisor = 0x1FFFF; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             // Get estimated baud rate (to nearest integer) | ||||||
|  |             baudEstimate = (24000000 + (tryDivisor / 2)) / tryDivisor; | ||||||
|  | 
 | ||||||
|  |             // Get absolute difference from requested baud rate | ||||||
|  |             if (baudEstimate < baudrate) { | ||||||
|  |                 baudDiff = baudrate - baudEstimate; | ||||||
|  |             } else { | ||||||
|  |                 baudDiff = baudEstimate - baudrate; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             if (i == 0 || baudDiff < bestBaudDiff) { | ||||||
|  |                 // Closest to requested baud rate so far | ||||||
|  |                 bestDivisor = tryDivisor; | ||||||
|  |                 bestBaud = baudEstimate; | ||||||
|  |                 bestBaudDiff = baudDiff; | ||||||
|  |                 if (baudDiff == 0) { | ||||||
|  |                     // Spot on! No point trying | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Encode the best divisor value | ||||||
|  |         long encodedDivisor = (bestDivisor >> 3) | (fracCode[bestDivisor & 7] << 14); | ||||||
|  |         // Deal with special cases for encoded value | ||||||
|  |         if (encodedDivisor == 1) { | ||||||
|  |             encodedDivisor = 0; // 3000000 baud | ||||||
|  |         } else if (encodedDivisor == 0x4001) { | ||||||
|  |             encodedDivisor = 1; // 2000000 baud (BM only) | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Split into "value" and "index" values | ||||||
|  |         long value = encodedDivisor & 0xFFFF; | ||||||
|  |         long index; | ||||||
|  |         if (mType == DeviceType.TYPE_2232C || mType == DeviceType.TYPE_2232H | ||||||
|  |                 || mType == DeviceType.TYPE_4232H) { | ||||||
|  |             index = (encodedDivisor >> 8) & 0xffff; | ||||||
|  |             index &= 0xFF00; | ||||||
|  |             index |= 0 /* TODO mIndex */; | ||||||
|  |         } else { | ||||||
|  |             index = (encodedDivisor >> 16) & 0xffff; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Return the nearest baud rate | ||||||
|  |         return new long[] { | ||||||
|  |                 bestBaud, index, value | ||||||
|  |         }; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static boolean probe(UsbDevice usbDevice) { | ||||||
|  |         // TODO(mikey): Support other devices. | ||||||
|  |         return usbDevice.getVendorId() == 0x0403 && usbDevice.getProductId() == 0x6001; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,76 @@ | |||||||
|  | /* Copyright 2011 Google Inc. | ||||||
|  |  * | ||||||
|  |  * This library is free software; you can redistribute it and/or | ||||||
|  |  * modify it under the terms of the GNU Lesser General Public | ||||||
|  |  * License as published by the Free Software Foundation; either | ||||||
|  |  * version 2.1 of the License, or (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * This library 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 | ||||||
|  |  * Lesser General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU Lesser General Public | ||||||
|  |  * License along with this library; if not, write to the Free Software | ||||||
|  |  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, | ||||||
|  |  * USA. | ||||||
|  |  * | ||||||
|  |  * Project home page: http://code.google.com/p/usb-serial-for-android/ | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package com.hoho.android.usbserial.driver; | ||||||
|  | 
 | ||||||
|  | import java.io.IOException; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Driver interface for a supported USB serial device. | ||||||
|  |  * | ||||||
|  |  * @author mike wakerly (opensource@hoho.com) | ||||||
|  |  */ | ||||||
|  | public interface UsbSerialDriver { | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Opens and initializes the device as a USB serial device. Upon success, | ||||||
|  |      * caller must ensure that {@link #close()} is eventually called. | ||||||
|  |      *  | ||||||
|  |      * @throws IOException on error opening or initializing the device. | ||||||
|  |      */ | ||||||
|  |     public void open() throws IOException; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Closes the serial device. | ||||||
|  |      * | ||||||
|  |      * @throws IOException on error closing the device. | ||||||
|  |      */ | ||||||
|  |     public void close() throws IOException; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Reads as many bytes as possible into the destination buffer. | ||||||
|  |      * | ||||||
|  |      * @param dest the destination byte buffer | ||||||
|  |      * @param timeoutMillis the timeout for reading | ||||||
|  |      * @return the actual number of bytes read | ||||||
|  |      * @throws IOException if an error occurred during reading | ||||||
|  |      */ | ||||||
|  |     public int read(final byte[] dest, final int timeoutMillis) throws IOException; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Writes as many bytes as possible from the source buffer. | ||||||
|  |      * | ||||||
|  |      * @param src the source byte buffer | ||||||
|  |      * @param timeoutMillis the timeout for writing | ||||||
|  |      * @return the actual number of bytes written | ||||||
|  |      * @throws IOException if an error occurred during writing | ||||||
|  |      */ | ||||||
|  |     public int write(final byte[] src, final int timeoutMillis) throws IOException; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Sets the baud rate of the serial device. | ||||||
|  |      * | ||||||
|  |      * @param baudRate the desired baud rate, in bits per second | ||||||
|  |      * @return the actual rate set | ||||||
|  |      * @throws IOException on error setting the baud rate | ||||||
|  |      */ | ||||||
|  |     public int setBaudRate(final int baudRate) throws IOException; | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,105 @@ | |||||||
|  | /* Copyright 2011 Google Inc. | ||||||
|  |  * | ||||||
|  |  * This library is free software; you can redistribute it and/or | ||||||
|  |  * modify it under the terms of the GNU Lesser General Public | ||||||
|  |  * License as published by the Free Software Foundation; either | ||||||
|  |  * version 2.1 of the License, or (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * This library 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 | ||||||
|  |  * Lesser General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU Lesser General Public | ||||||
|  |  * License along with this library; if not, write to the Free Software | ||||||
|  |  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, | ||||||
|  |  * USA. | ||||||
|  |  * | ||||||
|  |  * Project home page: http://code.google.com/p/usb-serial-for-android/ | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package com.hoho.android.usbserial.driver; | ||||||
|  | 
 | ||||||
|  | import android.hardware.usb.UsbDevice; | ||||||
|  | import android.hardware.usb.UsbDeviceConnection; | ||||||
|  | import android.hardware.usb.UsbManager; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Helper class to assist in detecting and building {@link UsbSerialDriver} | ||||||
|  |  * instances from available hardware. | ||||||
|  |  * | ||||||
|  |  * @author mike wakerly (opensource@hoho.com) | ||||||
|  |  */ | ||||||
|  | public enum UsbSerialProber { | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Prober for {@link FtdiSerialDriver}. | ||||||
|  |      * | ||||||
|  |      * @see FtdiSerialDriver | ||||||
|  |      */ | ||||||
|  |     FTDI_SERIAL { | ||||||
|  |         @Override | ||||||
|  |         public UsbSerialDriver getDevice(final UsbManager manager, final UsbDevice usbDevice) { | ||||||
|  |             if (!FtdiSerialDriver.probe(usbDevice)) { | ||||||
|  |                 return null; | ||||||
|  |             } | ||||||
|  |             final UsbDeviceConnection connection = manager.openDevice(usbDevice); | ||||||
|  |             if (connection == null) { | ||||||
|  |                 return null; | ||||||
|  |             } | ||||||
|  |             return new FtdiSerialDriver(usbDevice, connection); | ||||||
|  |         } | ||||||
|  |     }; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Builds a new {@link UsbSerialDriver} instance from the raw device, or | ||||||
|  |      * returns <code>null</code> if it could not be built (for example, if the | ||||||
|  |      * probe failed). | ||||||
|  |      * | ||||||
|  |      * @param manager the {@link UsbManager} to use | ||||||
|  |      * @param usbDevice the raw {@link UsbDevice} to use | ||||||
|  |      * @return the first available {@link UsbSerialDriver}, or {@code null} if | ||||||
|  |      *         no devices could be acquired | ||||||
|  |      */ | ||||||
|  |     public abstract UsbSerialDriver getDevice(final UsbManager manager, final UsbDevice usbDevice); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Acquires and returns the first available serial device among all | ||||||
|  |      * available {@link UsbDevice}s, or returns {@code null} if no device could | ||||||
|  |      * be acquired. | ||||||
|  |      * | ||||||
|  |      * @param usbManager the {@link UsbManager} to use | ||||||
|  |      * @return the first available {@link UsbSerialDriver}, or {@code null} if | ||||||
|  |      *         no devices could be acquired | ||||||
|  |      */ | ||||||
|  |     public static UsbSerialDriver acquire(final UsbManager usbManager) { | ||||||
|  |         for (final UsbDevice usbDevice : usbManager.getDeviceList().values()) { | ||||||
|  |             final UsbSerialDriver probedDevice = acquire(usbManager, usbDevice); | ||||||
|  |             if (probedDevice != null) { | ||||||
|  |                 return probedDevice; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Builds and returns a new {@link UsbSerialDriver} from the given | ||||||
|  |      * {@link UsbDevice}, or returns {@code null} if no drivers supported this | ||||||
|  |      * device. | ||||||
|  |      * | ||||||
|  |      * @param usbManager the {@link UsbManager} to use | ||||||
|  |      * @param usbDevice the {@link UsbDevice} to use | ||||||
|  |      * @return a new {@link UsbSerialDriver}, or {@code null} if no devices | ||||||
|  |      *         could be acquired | ||||||
|  |      */ | ||||||
|  |     public static UsbSerialDriver acquire(final UsbManager usbManager, final UsbDevice usbDevice) { | ||||||
|  |         for (final UsbSerialProber prober : values()) { | ||||||
|  |             final UsbSerialDriver probedDevice = prober.getDevice(usbManager, usbDevice); | ||||||
|  |             if (probedDevice != null) { | ||||||
|  |                 return probedDevice; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,46 @@ | |||||||
|  | /* | ||||||
|  |  * Copyright 2011 Google Inc. | ||||||
|  |  * | ||||||
|  |  * This library is free software; you can redistribute it and/or | ||||||
|  |  * modify it under the terms of the GNU Lesser General Public | ||||||
|  |  * License as published by the Free Software Foundation; either | ||||||
|  |  * version 2.1 of the License, or (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * This library 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 | ||||||
|  |  * Lesser General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU Lesser General Public | ||||||
|  |  * License along with this library; if not, write to the Free Software | ||||||
|  |  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, | ||||||
|  |  * USA. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package com.hoho.android.usbserial.driver; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Generic unchecked exception for the usbserial package. | ||||||
|  |  * | ||||||
|  |  * @author mike wakerly (opensource@hoho.com) | ||||||
|  |  */ | ||||||
|  | @SuppressWarnings("serial") | ||||||
|  | public class UsbSerialRuntimeException extends RuntimeException { | ||||||
|  | 
 | ||||||
|  |     public UsbSerialRuntimeException() { | ||||||
|  |         super(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public UsbSerialRuntimeException(String detailMessage, Throwable throwable) { | ||||||
|  |         super(detailMessage, throwable); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public UsbSerialRuntimeException(String detailMessage) { | ||||||
|  |         super(detailMessage); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public UsbSerialRuntimeException(Throwable throwable) { | ||||||
|  |         super(throwable); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,149 @@ | |||||||
|  | /* | ||||||
|  |  * Copyright (C) 2006 The Android Open Source Project | ||||||
|  |  * | ||||||
|  |  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
|  |  * you may not use this file except in compliance with the License. | ||||||
|  |  * You may obtain a copy of the License at | ||||||
|  |  * | ||||||
|  |  *      http://www.apache.org/licenses/LICENSE-2.0 | ||||||
|  |  * | ||||||
|  |  * Unless required by applicable law or agreed to in writing, software | ||||||
|  |  * distributed under the License is distributed on an "AS IS" BASIS, | ||||||
|  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||
|  |  * See the License for the specific language governing permissions and | ||||||
|  |  * limitations under the License. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package com.hoho.android.usbserial.util; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Clone of Android's HexDump class, for use in debugging. Cosmetic changes | ||||||
|  |  * only. | ||||||
|  |  */ | ||||||
|  | public class HexDump { | ||||||
|  |     private final static char[] HEX_DIGITS = { | ||||||
|  |             '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' | ||||||
|  |     }; | ||||||
|  | 
 | ||||||
|  |     public static String dumpHexString(byte[] array) { | ||||||
|  |         return dumpHexString(array, 0, array.length); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static String dumpHexString(byte[] array, int offset, int length) { | ||||||
|  |         StringBuilder result = new StringBuilder(); | ||||||
|  | 
 | ||||||
|  |         byte[] line = new byte[16]; | ||||||
|  |         int lineIndex = 0; | ||||||
|  | 
 | ||||||
|  |         result.append("\n0x"); | ||||||
|  |         result.append(toHexString(offset)); | ||||||
|  | 
 | ||||||
|  |         for (int i = offset; i < offset + length; i++) { | ||||||
|  |             if (lineIndex == 16) { | ||||||
|  |                 result.append(" "); | ||||||
|  | 
 | ||||||
|  |                 for (int j = 0; j < 16; j++) { | ||||||
|  |                     if (line[j] > ' ' && line[j] < '~') { | ||||||
|  |                         result.append(new String(line, j, 1)); | ||||||
|  |                     } else { | ||||||
|  |                         result.append("."); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 result.append("\n0x"); | ||||||
|  |                 result.append(toHexString(i)); | ||||||
|  |                 lineIndex = 0; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             byte b = array[i]; | ||||||
|  |             result.append(" "); | ||||||
|  |             result.append(HEX_DIGITS[(b >>> 4) & 0x0F]); | ||||||
|  |             result.append(HEX_DIGITS[b & 0x0F]); | ||||||
|  | 
 | ||||||
|  |             line[lineIndex++] = b; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if (lineIndex != 16) { | ||||||
|  |             int count = (16 - lineIndex) * 3; | ||||||
|  |             count++; | ||||||
|  |             for (int i = 0; i < count; i++) { | ||||||
|  |                 result.append(" "); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             for (int i = 0; i < lineIndex; i++) { | ||||||
|  |                 if (line[i] > ' ' && line[i] < '~') { | ||||||
|  |                     result.append(new String(line, i, 1)); | ||||||
|  |                 } else { | ||||||
|  |                     result.append("."); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return result.toString(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static String toHexString(byte b) { | ||||||
|  |         return toHexString(toByteArray(b)); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static String toHexString(byte[] array) { | ||||||
|  |         return toHexString(array, 0, array.length); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static String toHexString(byte[] array, int offset, int length) { | ||||||
|  |         char[] buf = new char[length * 2]; | ||||||
|  | 
 | ||||||
|  |         int bufIndex = 0; | ||||||
|  |         for (int i = offset; i < offset + length; i++) { | ||||||
|  |             byte b = array[i]; | ||||||
|  |             buf[bufIndex++] = HEX_DIGITS[(b >>> 4) & 0x0F]; | ||||||
|  |             buf[bufIndex++] = HEX_DIGITS[b & 0x0F]; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return new String(buf); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static String toHexString(int i) { | ||||||
|  |         return toHexString(toByteArray(i)); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static byte[] toByteArray(byte b) { | ||||||
|  |         byte[] array = new byte[1]; | ||||||
|  |         array[0] = b; | ||||||
|  |         return array; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static byte[] toByteArray(int i) { | ||||||
|  |         byte[] array = new byte[4]; | ||||||
|  | 
 | ||||||
|  |         array[3] = (byte) (i & 0xFF); | ||||||
|  |         array[2] = (byte) ((i >> 8) & 0xFF); | ||||||
|  |         array[1] = (byte) ((i >> 16) & 0xFF); | ||||||
|  |         array[0] = (byte) ((i >> 24) & 0xFF); | ||||||
|  | 
 | ||||||
|  |         return array; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private static int toByte(char c) { | ||||||
|  |         if (c >= '0' && c <= '9') | ||||||
|  |             return (c - '0'); | ||||||
|  |         if (c >= 'A' && c <= 'F') | ||||||
|  |             return (c - 'A' + 10); | ||||||
|  |         if (c >= 'a' && c <= 'f') | ||||||
|  |             return (c - 'a' + 10); | ||||||
|  | 
 | ||||||
|  |         throw new RuntimeException("Invalid hex char '" + c + "'"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static byte[] hexStringToByteArray(String hexString) { | ||||||
|  |         int length = hexString.length(); | ||||||
|  |         byte[] buffer = new byte[length / 2]; | ||||||
|  | 
 | ||||||
|  |         for (int i = 0; i < length; i += 2) { | ||||||
|  |             buffer[i / 2] = (byte) ((toByte(hexString.charAt(i)) << 4) | toByte(hexString | ||||||
|  |                     .charAt(i + 1))); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return buffer; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,181 @@ | |||||||
|  | /* Copyright 2011 Google Inc. | ||||||
|  |  * | ||||||
|  |  * This library is free software; you can redistribute it and/or | ||||||
|  |  * modify it under the terms of the GNU Lesser General Public | ||||||
|  |  * License as published by the Free Software Foundation; either | ||||||
|  |  * version 2.1 of the License, or (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * This library 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 | ||||||
|  |  * Lesser General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU Lesser General Public | ||||||
|  |  * License along with this library; if not, write to the Free Software | ||||||
|  |  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, | ||||||
|  |  * USA. | ||||||
|  |  * | ||||||
|  |  * Project home page: http://code.google.com/p/usb-serial-for-android/ | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package com.hoho.android.usbserial.util; | ||||||
|  | 
 | ||||||
|  | import android.hardware.usb.UsbRequest; | ||||||
|  | import android.util.Log; | ||||||
|  | 
 | ||||||
|  | import com.hoho.android.usbserial.driver.UsbSerialDriver; | ||||||
|  | 
 | ||||||
|  | import java.io.IOException; | ||||||
|  | import java.nio.ByteBuffer; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Utility class which services a {@link UsbSerialDriver} in its {@link #run()} | ||||||
|  |  * method. | ||||||
|  |  * | ||||||
|  |  * @author opensource@hoho.com (mike wakerly) | ||||||
|  |  */ | ||||||
|  | public class SerialInputOutputManager implements Runnable { | ||||||
|  | 
 | ||||||
|  |     private static final String TAG = SerialInputOutputManager.class.getSimpleName(); | ||||||
|  |     private static final boolean DEBUG = true; | ||||||
|  | 
 | ||||||
|  |     private static final int READ_WAIT_MILLIS = 200; | ||||||
|  |     private static final int BUFSIZ = 4096; | ||||||
|  | 
 | ||||||
|  |     private final UsbSerialDriver mDriver; | ||||||
|  | 
 | ||||||
|  |     private final ByteBuffer mReadBuffer = ByteBuffer.allocate(BUFSIZ); | ||||||
|  |     private final ByteBuffer mWriteBuffer = ByteBuffer.allocate(BUFSIZ); | ||||||
|  | 
 | ||||||
|  |     private enum State { | ||||||
|  |         STOPPED, | ||||||
|  |         RUNNING, | ||||||
|  |         STOPPING | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // Synchronized by 'this' | ||||||
|  |     private State mState = State.STOPPED; | ||||||
|  | 
 | ||||||
|  |     // Synchronized by 'this' | ||||||
|  |     private Listener mListener; | ||||||
|  | 
 | ||||||
|  |     public interface Listener { | ||||||
|  |         /** | ||||||
|  |          * Called when new incoming data is available. | ||||||
|  |          */ | ||||||
|  |         public void onNewData(byte[] data); | ||||||
|  | 
 | ||||||
|  |         /** | ||||||
|  |          * Called when {@link SerialInputOutputManager#run()} aborts due to an | ||||||
|  |          * error. | ||||||
|  |          */ | ||||||
|  |         public void onRunError(Exception e); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Creates a new instance with no listener. | ||||||
|  |      */ | ||||||
|  |     public SerialInputOutputManager(UsbSerialDriver driver) { | ||||||
|  |         this(driver, null); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Creates a new instance with the provided listener. | ||||||
|  |      */ | ||||||
|  |     public SerialInputOutputManager(UsbSerialDriver driver, Listener listener) { | ||||||
|  |         mDriver = driver; | ||||||
|  |         mListener = listener; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public synchronized void setListener(Listener listener) { | ||||||
|  |         mListener = listener; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public synchronized Listener getListener() { | ||||||
|  |         return mListener; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void writeAsync(byte[] data) { | ||||||
|  |         mWriteBuffer.put(data); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public synchronized void stop() { | ||||||
|  |         if (getState() == State.RUNNING) { | ||||||
|  |             Log.i(TAG, "Stop requested"); | ||||||
|  |             mState = State.STOPPING; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private synchronized State getState() { | ||||||
|  |         return mState; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Continuously services the read and write buffers until {@link #stop()} is | ||||||
|  |      * called, or until a driver exception is raised. | ||||||
|  |      * | ||||||
|  |      * NOTE(mikey): Uses inefficient read/write-with-timeout. | ||||||
|  |      * TODO(mikey): Read asynchronously with {@link UsbRequest#queue(ByteBuffer, int)} | ||||||
|  |      */ | ||||||
|  |     @Override | ||||||
|  |     public void run() { | ||||||
|  |         synchronized (this) { | ||||||
|  |             if (getState() != State.STOPPED) { | ||||||
|  |                 throw new IllegalStateException("Already running."); | ||||||
|  |             } | ||||||
|  |             mState = State.RUNNING; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         Log.i(TAG, "Running .."); | ||||||
|  |         try { | ||||||
|  |             while (true) { | ||||||
|  |                 if (getState() != State.RUNNING) { | ||||||
|  |                     Log.i(TAG, "Stopping mState=" + getState()); | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  |                 step(); | ||||||
|  |             } | ||||||
|  |         } catch (Exception e) { | ||||||
|  |             Log.w(TAG, "Run ending due to exception: " + e.getMessage(), e); | ||||||
|  |             final Listener listener = getListener(); | ||||||
|  |             if (listener != null) { | ||||||
|  |               listener.onRunError(e); | ||||||
|  |             } | ||||||
|  |         } finally { | ||||||
|  |             synchronized (this) { | ||||||
|  |                 mState = State.STOPPED; | ||||||
|  |                 Log.i(TAG, "Stopped."); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private void step() throws IOException { | ||||||
|  |         // Handle incoming data. | ||||||
|  |         int len = mDriver.read(mReadBuffer.array(), READ_WAIT_MILLIS); | ||||||
|  |         if (len > 0) { | ||||||
|  |             if (DEBUG) Log.d(TAG, "Read data len=" + len); | ||||||
|  |             final Listener listener = getListener(); | ||||||
|  |             if (listener != null) { | ||||||
|  |                 final byte[] data = new byte[len]; | ||||||
|  |                 mReadBuffer.get(data, 0, len); | ||||||
|  |                 listener.onNewData(data); | ||||||
|  |             } | ||||||
|  |             mReadBuffer.clear(); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Handle outgoing data. | ||||||
|  |         if (mWriteBuffer.position() > 0) { | ||||||
|  |             final byte[] outBuff; | ||||||
|  |             synchronized (mWriteBuffer) { | ||||||
|  |                 len = mWriteBuffer.position(); | ||||||
|  |                 outBuff = new byte[len]; | ||||||
|  |                 mWriteBuffer.get(outBuff, 0, len); | ||||||
|  |                 mWriteBuffer.clear(); | ||||||
|  |             } | ||||||
|  |             if (DEBUG) | ||||||
|  |                 Log.d(TAG, "Writing data len=" + len); | ||||||
|  |             mDriver.write(outBuff, READ_WAIT_MILLIS); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user