mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-15 00:02:49 +03:00
Split IDE into 2 projects.
BEWARE: HIGHLY EXPERIMENTAL BRANCH
This commit is contained in:
12
arduino-core/.classpath
Normal file
12
arduino-core/.classpath
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="lib/jna.jar"/>
|
||||
<classpathentry kind="lib" path="lib/apple.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-logging-1.0.4.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jmdns-3.4.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jssc-2.8.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jsch-0.1.50.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
1
arduino-core/.gitignore
vendored
Normal file
1
arduino-core/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/bin/
|
17
arduino-core/.project
Normal file
17
arduino-core/.project
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>arduino-core</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
1
arduino-core/lib/apple.LICENSE.BSD-like.txt
Normal file
1
arduino-core/lib/apple.LICENSE.BSD-like.txt
Normal file
@ -0,0 +1 @@
|
||||
http://developer.apple.com/library/mac/#/legacy/library/samplecode/AppleJavaExtensions/Listings/README_txt.html#//apple_ref/doc/uid/DTS10000677-README_txt-DontLinkElementID_3
|
BIN
arduino-core/lib/apple.jar
Normal file
BIN
arduino-core/lib/apple.jar
Normal file
Binary file not shown.
BIN
arduino-core/lib/commons-logging-1.0.4.jar
Normal file
BIN
arduino-core/lib/commons-logging-1.0.4.jar
Normal file
Binary file not shown.
202
arduino-core/lib/commons-logging.LICENSE.ASL-2.0.txt
Normal file
202
arduino-core/lib/commons-logging.LICENSE.ASL-2.0.txt
Normal file
@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
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.
|
BIN
arduino-core/lib/jmdns-3.4.1.jar
Normal file
BIN
arduino-core/lib/jmdns-3.4.1.jar
Normal file
Binary file not shown.
2
arduino-core/lib/jmdns.LICENSE.ASL-2.0-LGPL-2.1.txt
Normal file
2
arduino-core/lib/jmdns.LICENSE.ASL-2.0-LGPL-2.1.txt
Normal file
@ -0,0 +1,2 @@
|
||||
https://jmdns.svn.sourceforge.net/svnroot/jmdns/tags/jmdns-3.4.1/LICENSE-LGPL.txt
|
||||
https://jmdns.svn.sourceforge.net/svnroot/jmdns/tags/jmdns-3.4.1/LICENSE
|
1
arduino-core/lib/jna.LICENSE.LGPL-2.1.txt
Normal file
1
arduino-core/lib/jna.LICENSE.LGPL-2.1.txt
Normal file
@ -0,0 +1 @@
|
||||
https://github.com/twall/jna/blob/master/LICENSE
|
BIN
arduino-core/lib/jna.jar
Normal file
BIN
arduino-core/lib/jna.jar
Normal file
Binary file not shown.
BIN
arduino-core/lib/jsch-0.1.50.jar
Normal file
BIN
arduino-core/lib/jsch-0.1.50.jar
Normal file
Binary file not shown.
1
arduino-core/lib/jsch.LICENSE.BSD.txt
Normal file
1
arduino-core/lib/jsch.LICENSE.BSD.txt
Normal file
@ -0,0 +1 @@
|
||||
http://www.jcraft.com/jsch/LICENSE.txt
|
BIN
arduino-core/lib/jssc-2.8.0.jar
Normal file
BIN
arduino-core/lib/jssc-2.8.0.jar
Normal file
Binary file not shown.
674
arduino-core/lib/jssc.LICENSE.GPL.txt
Normal file
674
arduino-core/lib/jssc.LICENSE.GPL.txt
Normal file
@ -0,0 +1,674 @@
|
||||
GNU 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.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
165
arduino-core/lib/jssc.LICENSE.LGPL.txt
Normal file
165
arduino-core/lib/jssc.LICENSE.LGPL.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.
|
82
arduino-core/src/cc/arduino/packages/BoardPort.java
Normal file
82
arduino-core/src/cc/arduino/packages/BoardPort.java
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Arduino is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2013 Arduino LLC (http://www.arduino.cc/)
|
||||
*/
|
||||
|
||||
package cc.arduino.packages;
|
||||
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
|
||||
public class BoardPort {
|
||||
|
||||
private String address;
|
||||
private String protocol;
|
||||
private String boardName;
|
||||
private String label;
|
||||
private PreferencesMap prefs;
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public void setProtocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public String getBoardName() {
|
||||
return boardName;
|
||||
}
|
||||
|
||||
public void setBoardName(String boardName) {
|
||||
this.boardName = boardName;
|
||||
}
|
||||
|
||||
public void setPrefs(PreferencesMap prefs) {
|
||||
this.prefs = prefs;
|
||||
}
|
||||
|
||||
public PreferencesMap getPrefs() {
|
||||
return prefs;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
}
|
64
arduino-core/src/cc/arduino/packages/Discovery.java
Normal file
64
arduino-core/src/cc/arduino/packages/Discovery.java
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Arduino is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2013 Arduino LLC (http://www.arduino.cc/)
|
||||
*/
|
||||
|
||||
package cc.arduino.packages;
|
||||
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface Discovery {
|
||||
|
||||
/**
|
||||
* Set discovery preferences
|
||||
*
|
||||
* @param options
|
||||
*/
|
||||
public void setPreferences(PreferencesMap options);
|
||||
|
||||
/**
|
||||
* Start discovery service
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void start() throws Exception;
|
||||
|
||||
/**
|
||||
* Stop discovery service
|
||||
*/
|
||||
public void stop() throws Exception;
|
||||
|
||||
/**
|
||||
* Return the list of discovered ports.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<BoardPort> discovery();
|
||||
|
||||
}
|
91
arduino-core/src/cc/arduino/packages/DiscoveryManager.java
Normal file
91
arduino-core/src/cc/arduino/packages/DiscoveryManager.java
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Arduino is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2013 Arduino LLC (http://www.arduino.cc/)
|
||||
*/
|
||||
|
||||
package cc.arduino.packages;
|
||||
|
||||
import cc.arduino.packages.discoverers.NetworkDiscovery;
|
||||
import cc.arduino.packages.discoverers.SerialDiscovery;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
public class DiscoveryManager {
|
||||
|
||||
private final List<Discovery> discoverers;
|
||||
|
||||
public DiscoveryManager() {
|
||||
discoverers = new ArrayList<Discovery>();
|
||||
discoverers.add(new SerialDiscovery());
|
||||
discoverers.add(new NetworkDiscovery());
|
||||
|
||||
// Start all discoverers
|
||||
for (Discovery d : discoverers) {
|
||||
try {
|
||||
d.start();
|
||||
} catch (Exception e) {
|
||||
System.err.println(_("Error starting discovery method: ") + d.getClass());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Thread closeHook = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Discovery d : discoverers) {
|
||||
try {
|
||||
d.stop();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Runtime.getRuntime().addShutdownHook(closeHook);
|
||||
}
|
||||
|
||||
public List<BoardPort> discovery() {
|
||||
List<BoardPort> res = new ArrayList<BoardPort>();
|
||||
for (Discovery d : discoverers) {
|
||||
res.addAll(d.discovery());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public BoardPort find(String address) {
|
||||
for (BoardPort boardPort : discovery()) {
|
||||
if (boardPort.getAddress().equals(address)) {
|
||||
return boardPort;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
164
arduino-core/src/cc/arduino/packages/Uploader.java
Normal file
164
arduino-core/src/cc/arduino/packages/Uploader.java
Normal file
@ -0,0 +1,164 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Uploader - abstract uploading baseclass (common to both uisp and avrdude)
|
||||
Part of the Arduino project - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2004-05
|
||||
Hernando Barragan
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package cc.arduino.packages;
|
||||
|
||||
import processing.app.I18n;
|
||||
import processing.app.PreferencesData;
|
||||
import processing.app.debug.MessageConsumer;
|
||||
import processing.app.debug.MessageSiphon;
|
||||
import processing.app.debug.RunnerException;
|
||||
import processing.app.helpers.ProcessUtils;
|
||||
import processing.app.helpers.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
public abstract class Uploader implements MessageConsumer {
|
||||
|
||||
private static final List<String> STRINGS_TO_SUPPRESS;
|
||||
private static final List<String> AVRDUDE_PROBLEMS;
|
||||
|
||||
static {
|
||||
STRINGS_TO_SUPPRESS = Arrays.asList("Connecting to programmer:",
|
||||
"Found programmer: Id = \"CATERIN\"; type = S",
|
||||
"Software Version = 1.0; No Hardware Version given.",
|
||||
"Programmer supports auto addr increment.",
|
||||
"Programmer supports buffered memory access with buffersize=128 bytes.",
|
||||
"Programmer supports the following devices:", "Device code: 0x44");
|
||||
|
||||
AVRDUDE_PROBLEMS = Arrays.asList("Programmer is not responding",
|
||||
"programmer is not responding",
|
||||
"protocol error", "avrdude: ser_open(): can't open device",
|
||||
"avrdude: ser_drain(): read error",
|
||||
"avrdude: ser_send(): write error",
|
||||
"avrdude: error: buffered memory access not supported.");
|
||||
}
|
||||
|
||||
protected final boolean verbose;
|
||||
|
||||
private String error;
|
||||
protected boolean notFoundError;
|
||||
protected boolean noUploadPort;
|
||||
|
||||
protected Uploader() {
|
||||
this.verbose = PreferencesData.getBoolean("upload.verbose");
|
||||
init(false);
|
||||
}
|
||||
|
||||
protected Uploader(boolean nup) {
|
||||
this.verbose = PreferencesData.getBoolean("upload.verbose");
|
||||
init(nup);
|
||||
}
|
||||
|
||||
private void init(boolean nup) {
|
||||
this.error = null;
|
||||
this.notFoundError = false;
|
||||
this.noUploadPort = nup;
|
||||
}
|
||||
|
||||
public abstract boolean uploadUsingPreferences(File sourcePath, String buildPath, String className, boolean usingProgrammer, List<String> warningsAccumulator) throws Exception;
|
||||
|
||||
public abstract boolean burnBootloader() throws Exception;
|
||||
|
||||
public boolean requiresAuthorization() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getAuthorizationKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected boolean executeUploadCommand(Collection<String> command) throws Exception {
|
||||
return executeUploadCommand(command.toArray(new String[command.size()]));
|
||||
}
|
||||
|
||||
protected boolean executeUploadCommand(String command[]) throws Exception {
|
||||
// Skip empty commands
|
||||
if (command == null || command.length == 0)
|
||||
return true;
|
||||
|
||||
notFoundError = false;
|
||||
int result = -1;
|
||||
|
||||
try {
|
||||
if (verbose) {
|
||||
for (String c : command)
|
||||
System.out.print(c + " ");
|
||||
System.out.println();
|
||||
}
|
||||
Process process = ProcessUtils.exec(command);
|
||||
new MessageSiphon(process.getInputStream(), this, 100);
|
||||
new MessageSiphon(process.getErrorStream(), this, 100);
|
||||
|
||||
// wait for the process to finish.
|
||||
result = process.waitFor();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (error != null) {
|
||||
RunnerException exception = new RunnerException(error);
|
||||
exception.hideStackTrace();
|
||||
throw exception;
|
||||
}
|
||||
|
||||
return result == 0;
|
||||
}
|
||||
|
||||
public void message(String s) {
|
||||
// selectively suppress a bunch of avrdude output for AVR109/Caterina that should already be quelled but isn't
|
||||
if (!verbose && StringUtils.stringContainsOneOf(s, STRINGS_TO_SUPPRESS)) {
|
||||
s = "";
|
||||
}
|
||||
|
||||
System.err.print(s);
|
||||
|
||||
// ignore cautions
|
||||
if (s.contains("Error")) {
|
||||
notFoundError = true;
|
||||
return;
|
||||
}
|
||||
if (notFoundError) {
|
||||
error = I18n.format(_("the selected serial port {0} does not exist or your board is not connected"), s);
|
||||
return;
|
||||
}
|
||||
if (s.contains("Device is not responding")) {
|
||||
error = _("Device is not responding, check the right serial port is selected or RESET the board right before exporting");
|
||||
return;
|
||||
}
|
||||
if (StringUtils.stringContainsOneOf(s, AVRDUDE_PROBLEMS)) {
|
||||
error = _("Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.");
|
||||
return;
|
||||
}
|
||||
if (s.contains("Expected signature")) {
|
||||
error = _("Wrong microcontroller found. Did you select the right board from the Tools > Board menu?");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
49
arduino-core/src/cc/arduino/packages/UploaderFactory.java
Normal file
49
arduino-core/src/cc/arduino/packages/UploaderFactory.java
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Arduino is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2013 Arduino LLC (http://www.arduino.cc/)
|
||||
*/
|
||||
|
||||
package cc.arduino.packages;
|
||||
|
||||
import cc.arduino.packages.uploaders.SSHUploader;
|
||||
import cc.arduino.packages.uploaders.SerialUploader;
|
||||
import processing.app.debug.TargetBoard;
|
||||
|
||||
public class UploaderFactory {
|
||||
|
||||
public Uploader newUploader(TargetBoard board, BoardPort port, boolean noUploadPort) {
|
||||
if (noUploadPort)
|
||||
return new SerialUploader(noUploadPort);
|
||||
|
||||
if ("true".equals(board.getPreferences().get("upload.via_ssh")) && port != null && "network".equals(port.getProtocol())) {
|
||||
return new SSHUploader(port);
|
||||
}
|
||||
|
||||
return new SerialUploader();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,196 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Arduino is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2013 Arduino LLC (http://www.arduino.cc/)
|
||||
*/
|
||||
|
||||
package cc.arduino.packages.discoverers;
|
||||
|
||||
import cc.arduino.packages.BoardPort;
|
||||
import cc.arduino.packages.Discovery;
|
||||
import cc.arduino.packages.discoverers.network.*;
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.helpers.NetUtils;
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
import processing.app.zeroconf.jmdns.ArduinoDNSTaskStarter;
|
||||
|
||||
import javax.jmdns.*;
|
||||
import javax.jmdns.impl.DNSTaskStarter;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.*;
|
||||
|
||||
public class NetworkDiscovery implements Discovery, ServiceListener, cc.arduino.packages.discoverers.network.NetworkTopologyListener {
|
||||
|
||||
private Timer timer;
|
||||
private final List<BoardPort> ports;
|
||||
private final Map<InetAddress, JmDNS> mappedJmDNSs;
|
||||
|
||||
public NetworkDiscovery() {
|
||||
DNSTaskStarter.Factory.setClassDelegate(new ArduinoDNSTaskStarter());
|
||||
this.ports = new ArrayList<BoardPort>();
|
||||
this.mappedJmDNSs = new Hashtable<InetAddress, JmDNS>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BoardPort> discovery() {
|
||||
List<BoardPort> ports = clonePortsList();
|
||||
Iterator<BoardPort> iterator = ports.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
try {
|
||||
BoardPort board = iterator.next();
|
||||
if (!NetUtils.isReachable(InetAddress.getByName(board.getAddress()), Integer.parseInt(board.getPrefs().get("port")))) {
|
||||
iterator.remove();
|
||||
}
|
||||
} catch (UnknownHostException e) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return ports;
|
||||
}
|
||||
|
||||
private List<BoardPort> clonePortsList() {
|
||||
synchronized (this) {
|
||||
return new ArrayList<BoardPort>(this.ports);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPreferences(PreferencesMap options) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws IOException {
|
||||
this.timer = new Timer(this.getClass().getName() + " timer");
|
||||
new NetworkChecker(this, NetworkTopologyDiscovery.Factory.getInstance()).start(timer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws IOException {
|
||||
timer.purge();
|
||||
// we don't close each JmDNS instance as it's too slow
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serviceAdded(ServiceEvent serviceEvent) {
|
||||
String type = serviceEvent.getType();
|
||||
String name = serviceEvent.getName();
|
||||
|
||||
JmDNS dns = serviceEvent.getDNS();
|
||||
|
||||
dns.requestServiceInfo(type, name);
|
||||
ServiceInfo serviceInfo = dns.getServiceInfo(type, name);
|
||||
if (serviceInfo != null) {
|
||||
dns.requestServiceInfo(type, name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serviceRemoved(ServiceEvent serviceEvent) {
|
||||
String name = serviceEvent.getName();
|
||||
synchronized (this) {
|
||||
for (BoardPort port : ports) {
|
||||
if (port.getBoardName().equals(name))
|
||||
ports.remove(port);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serviceResolved(ServiceEvent serviceEvent) {
|
||||
ServiceInfo info = serviceEvent.getInfo();
|
||||
for (InetAddress inetAddress : info.getInet4Addresses()) {
|
||||
String address = inetAddress.getHostAddress();
|
||||
String name = serviceEvent.getName();
|
||||
|
||||
PreferencesMap prefs = null;
|
||||
String board = null;
|
||||
if (info.hasData()) {
|
||||
prefs = new PreferencesMap();
|
||||
board = info.getPropertyString("board");
|
||||
prefs.put("board", board);
|
||||
prefs.put("distro_version", info.getPropertyString("distro_version"));
|
||||
}
|
||||
|
||||
prefs.put("port", "" + info.getPort());
|
||||
|
||||
String label = name + " at " + address;
|
||||
if (board != null) {
|
||||
String boardName = BaseNoGui.getPlatform().resolveDeviceByBoardID(BaseNoGui.packages, board);
|
||||
label += " (" + boardName + ")";
|
||||
}
|
||||
|
||||
BoardPort port = new BoardPort();
|
||||
port.setAddress(address);
|
||||
port.setBoardName(name);
|
||||
port.setProtocol("network");
|
||||
port.setPrefs(prefs);
|
||||
port.setLabel(label);
|
||||
|
||||
synchronized (this) {
|
||||
removeDuplicateBoards(port);
|
||||
ports.add(port);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeDuplicateBoards(BoardPort newBoard) {
|
||||
Iterator<BoardPort> iterator = ports.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
BoardPort board = iterator.next();
|
||||
if (newBoard.getAddress().equals(board.getAddress())) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inetAddressAdded(InetAddress address) {
|
||||
if (mappedJmDNSs.containsKey(address)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
JmDNS jmDNS = JmDNS.create(address);
|
||||
jmDNS.addServiceListener("_arduino._tcp.local.", this);
|
||||
mappedJmDNSs.put(address, jmDNS);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inetAddressRemoved(InetAddress address) {
|
||||
JmDNS jmDNS = mappedJmDNSs.remove(address);
|
||||
if (jmDNS != null) {
|
||||
try {
|
||||
jmDNS.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Arduino is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2013 Arduino LLC (http://www.arduino.cc/)
|
||||
*/
|
||||
|
||||
package cc.arduino.packages.discoverers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.Platform;
|
||||
import processing.app.Serial;
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
import cc.arduino.packages.BoardPort;
|
||||
import cc.arduino.packages.Discovery;
|
||||
|
||||
public class SerialDiscovery implements Discovery {
|
||||
|
||||
@Override
|
||||
public List<BoardPort> discovery() {
|
||||
Platform os = BaseNoGui.getPlatform();
|
||||
String devicesListOutput = os.preListAllCandidateDevices();
|
||||
|
||||
List<BoardPort> res = new ArrayList<BoardPort>();
|
||||
|
||||
List<String> ports = Serial.list();
|
||||
|
||||
for (String port : ports) {
|
||||
String boardName = os.resolveDeviceAttachedTo(port, BaseNoGui.packages, devicesListOutput);
|
||||
String label = port;
|
||||
if (boardName != null)
|
||||
label += " (" + boardName + ")";
|
||||
|
||||
BoardPort boardPort = new BoardPort();
|
||||
boardPort.setAddress(port);
|
||||
boardPort.setProtocol("serial");
|
||||
boardPort.setBoardName(boardName);
|
||||
boardPort.setLabel(label);
|
||||
res.add(boardPort);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPreferences(PreferencesMap options) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Arduino is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2013 Arduino LLC (http://www.arduino.cc/)
|
||||
*/
|
||||
|
||||
package cc.arduino.packages.discoverers.network;
|
||||
|
||||
import javax.jmdns.NetworkTopologyDiscovery;
|
||||
import java.net.InetAddress;
|
||||
import java.util.*;
|
||||
|
||||
public class NetworkChecker extends TimerTask {
|
||||
|
||||
private final NetworkTopologyListener topologyListener;
|
||||
private final NetworkTopologyDiscovery topology;
|
||||
|
||||
private Set<InetAddress> knownAddresses;
|
||||
|
||||
public NetworkChecker(NetworkTopologyListener topologyListener, NetworkTopologyDiscovery topology) {
|
||||
super();
|
||||
this.topologyListener = topologyListener;
|
||||
this.topology = topology;
|
||||
this.knownAddresses = Collections.synchronizedSet(new HashSet<InetAddress>());
|
||||
}
|
||||
|
||||
public void start(Timer timer) {
|
||||
timer.schedule(this, 0, 3000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
InetAddress[] curentAddresses = topology.getInetAddresses();
|
||||
Set<InetAddress> current = new HashSet<InetAddress>(curentAddresses.length);
|
||||
for (InetAddress address : curentAddresses) {
|
||||
current.add(address);
|
||||
if (!knownAddresses.contains(address)) {
|
||||
topologyListener.inetAddressAdded(address);
|
||||
}
|
||||
}
|
||||
for (InetAddress address : knownAddresses) {
|
||||
if (!current.contains(address)) {
|
||||
topologyListener.inetAddressRemoved(address);
|
||||
}
|
||||
}
|
||||
knownAddresses = current;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Arduino is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2013 Arduino LLC (http://www.arduino.cc/)
|
||||
*/
|
||||
|
||||
package cc.arduino.packages.discoverers.network;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
public interface NetworkTopologyListener {
|
||||
|
||||
void inetAddressAdded(InetAddress address);
|
||||
|
||||
void inetAddressRemoved(InetAddress address);
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package cc.arduino.packages.ssh;
|
||||
|
||||
import com.jcraft.jsch.UserInfo;
|
||||
|
||||
public class NoInteractionUserInfo implements UserInfo {
|
||||
|
||||
private final String password;
|
||||
|
||||
public NoInteractionUserInfo(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public boolean promptYesNo(String str) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getPassphrase() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public boolean promptPassphrase(String message) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean promptPassword(String message) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void showMessage(String message) {
|
||||
}
|
||||
|
||||
}
|
139
arduino-core/src/cc/arduino/packages/ssh/SCP.java
Normal file
139
arduino-core/src/cc/arduino/packages/ssh/SCP.java
Normal file
@ -0,0 +1,139 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Arduino is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2013 Arduino LLC (http://www.arduino.cc/)
|
||||
*/
|
||||
|
||||
package cc.arduino.packages.ssh;
|
||||
|
||||
import com.jcraft.jsch.Channel;
|
||||
import com.jcraft.jsch.ChannelExec;
|
||||
import com.jcraft.jsch.Session;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class SCP extends SSH {
|
||||
|
||||
private Channel channel;
|
||||
private OutputStream out;
|
||||
private InputStream in;
|
||||
|
||||
public SCP(Session session) {
|
||||
super(session);
|
||||
}
|
||||
|
||||
public void open() throws IOException {
|
||||
try {
|
||||
channel = session.openChannel("exec");
|
||||
((ChannelExec) channel).setCommand("scp -t -r -d /");
|
||||
|
||||
out = channel.getOutputStream();
|
||||
in = channel.getInputStream();
|
||||
|
||||
channel.connect();
|
||||
ensureAcknowledged();
|
||||
} catch (Exception e) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
if (channel != null) {
|
||||
channel.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
protected void ensureAcknowledged() throws IOException {
|
||||
out.flush();
|
||||
|
||||
int b = in.read();
|
||||
|
||||
if (b == 0) return;
|
||||
if (b == -1) return;
|
||||
|
||||
if (b == 1 || b == 2) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("SCP error: ");
|
||||
|
||||
int c;
|
||||
do {
|
||||
c = in.read();
|
||||
sb.append((char) c);
|
||||
} while (c != '\n');
|
||||
|
||||
throw new IOException(sb.toString());
|
||||
}
|
||||
|
||||
throw new IOException("Uknown SCP error: " + b);
|
||||
}
|
||||
|
||||
public void sendFile(File localFile) throws IOException {
|
||||
sendFile(localFile, localFile.getName());
|
||||
}
|
||||
|
||||
public void sendFile(File localFile, String remoteFile) throws IOException {
|
||||
out.write(("C0644 " + localFile.length() + " " + remoteFile + "\n").getBytes());
|
||||
ensureAcknowledged();
|
||||
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
fis = new FileInputStream(localFile);
|
||||
byte[] buf = new byte[4096];
|
||||
while (true) {
|
||||
int len = fis.read(buf, 0, buf.length);
|
||||
if (len <= 0) break;
|
||||
out.write(buf, 0, len);
|
||||
}
|
||||
|
||||
// \0 terminates file
|
||||
buf[0] = 0;
|
||||
out.write(buf, 0, 1);
|
||||
} finally {
|
||||
if (fis != null) {
|
||||
fis.close();
|
||||
}
|
||||
}
|
||||
|
||||
ensureAcknowledged();
|
||||
}
|
||||
|
||||
public void startFolder(String folder) throws IOException {
|
||||
out.write(("D0755 0 " + folder + "\n").getBytes());
|
||||
ensureAcknowledged();
|
||||
}
|
||||
|
||||
public void endFolder() throws IOException {
|
||||
out.write("E\n".getBytes());
|
||||
ensureAcknowledged();
|
||||
}
|
||||
|
||||
}
|
114
arduino-core/src/cc/arduino/packages/ssh/SSH.java
Normal file
114
arduino-core/src/cc/arduino/packages/ssh/SSH.java
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Arduino is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2013 Arduino LLC (http://www.arduino.cc/)
|
||||
*/
|
||||
|
||||
package cc.arduino.packages.ssh;
|
||||
|
||||
import com.jcraft.jsch.Channel;
|
||||
import com.jcraft.jsch.ChannelExec;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import com.jcraft.jsch.Session;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class SSH {
|
||||
|
||||
protected final Session session;
|
||||
|
||||
public SSH(Session session) {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
public boolean execSyncCommand(String command) throws JSchException, IOException {
|
||||
return execSyncCommand(command, null, null);
|
||||
}
|
||||
|
||||
public boolean execSyncCommand(String command, PrintStream stdoutConsumer, PrintStream stderrConsumer) throws JSchException, IOException {
|
||||
InputStream stdout = null;
|
||||
InputStream stderr = null;
|
||||
Channel channel = null;
|
||||
try {
|
||||
channel = session.openChannel("exec");
|
||||
((ChannelExec) channel).setCommand(command);
|
||||
|
||||
channel.setInputStream(null);
|
||||
|
||||
stdout = channel.getInputStream();
|
||||
stderr = ((ChannelExec) channel).getErrStream();
|
||||
|
||||
channel.connect();
|
||||
|
||||
int exitCode = consumeOutputSyncAndReturnExitCode(channel, stdout, stdoutConsumer, stderr, stderrConsumer);
|
||||
|
||||
return exitCode == 0;
|
||||
|
||||
} finally {
|
||||
if (stdout != null) {
|
||||
stdout.close();
|
||||
}
|
||||
if (stderr != null) {
|
||||
stderr.close();
|
||||
}
|
||||
if (channel != null) {
|
||||
channel.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected int consumeOutputSyncAndReturnExitCode(Channel channel, InputStream stdout, PrintStream stdoutConsumer, InputStream stderr, PrintStream stderrConsumer) throws IOException {
|
||||
byte[] tmp = new byte[102400];
|
||||
while (true) {
|
||||
consumeStream(tmp, stdout, stdoutConsumer);
|
||||
consumeStream(tmp, stderr, stderrConsumer);
|
||||
|
||||
if (channel.isClosed()) {
|
||||
return channel.getExitStatus();
|
||||
}
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (Exception ee) {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void consumeStream(byte[] buffer, InputStream in, PrintStream out) throws IOException {
|
||||
while (in.available() > 0) {
|
||||
int length = in.read(buffer, 0, buffer.length);
|
||||
if (length < 0) {
|
||||
break;
|
||||
}
|
||||
if (out != null) {
|
||||
out.print(new String(buffer, 0, length));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package cc.arduino.packages.ssh;
|
||||
|
||||
import cc.arduino.packages.BoardPort;
|
||||
import com.jcraft.jsch.JSch;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import com.jcraft.jsch.Session;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface SSHClientSetupChainRing {
|
||||
|
||||
/*
|
||||
Chain is actually useless as default JSCH behaviour is to follow SSH Server authentication methods list
|
||||
*/
|
||||
Session setup(BoardPort port, JSch jSch) throws JSchException, IOException;
|
||||
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package cc.arduino.packages.ssh;
|
||||
|
||||
import cc.arduino.packages.BoardPort;
|
||||
import com.jcraft.jsch.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class SSHConfigFileSetup implements SSHClientSetupChainRing {
|
||||
|
||||
private final SSHClientSetupChainRing nextChainRing;
|
||||
|
||||
public SSHConfigFileSetup(SSHClientSetupChainRing nextChainRing) {
|
||||
this.nextChainRing = nextChainRing;
|
||||
}
|
||||
|
||||
public Session setup(BoardPort port, JSch jSch) throws JSchException, IOException {
|
||||
String ipAddress = port.getAddress();
|
||||
String hostname = port.getBoardName().contains(".local") ? port.getBoardName() : port.getBoardName() + ".local";
|
||||
|
||||
File sshFolder = new File(System.getProperty("user.home"), ".ssh");
|
||||
File sshConfig = new File(sshFolder, "config");
|
||||
|
||||
if (!sshFolder.exists() || !sshConfig.exists()) {
|
||||
if (nextChainRing != null) {
|
||||
return nextChainRing.setup(port, jSch);
|
||||
}
|
||||
throw new JSchException("Unable to find a way to connect");
|
||||
}
|
||||
|
||||
OpenSSHConfig configRepository = OpenSSHConfig.parseFile(sshConfig.getAbsolutePath());
|
||||
|
||||
jSch.setConfigRepository(new OpenSSHConfigWrapper(configRepository, ipAddress));
|
||||
|
||||
return jSch.getSession(hostname);
|
||||
}
|
||||
|
||||
public static class OpenSSHConfigWrapper implements ConfigRepository {
|
||||
|
||||
private final OpenSSHConfig config;
|
||||
private final String ipAddress;
|
||||
|
||||
public OpenSSHConfigWrapper(OpenSSHConfig config, String ipAddress) {
|
||||
this.config = config;
|
||||
this.ipAddress = ipAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Config getConfig(String host) {
|
||||
return new ConfigWrapper(config.getConfig(host), ipAddress);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConfigWrapper implements ConfigRepository.Config {
|
||||
|
||||
private final ConfigRepository.Config config;
|
||||
private final String ipAddress;
|
||||
|
||||
public ConfigWrapper(OpenSSHConfig.Config config, String ipAddress) {
|
||||
this.config = config;
|
||||
this.ipAddress = ipAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHostname() {
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUser() {
|
||||
String user = config.getUser();
|
||||
if (user != null) {
|
||||
return user;
|
||||
}
|
||||
return "root";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return config.getPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(String key) {
|
||||
return config.getValue(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getValues(String key) {
|
||||
return config.getValues(key);
|
||||
}
|
||||
}
|
||||
}
|
21
arduino-core/src/cc/arduino/packages/ssh/SSHPwdSetup.java
Normal file
21
arduino-core/src/cc/arduino/packages/ssh/SSHPwdSetup.java
Normal file
@ -0,0 +1,21 @@
|
||||
package cc.arduino.packages.ssh;
|
||||
|
||||
import cc.arduino.packages.BoardPort;
|
||||
import com.jcraft.jsch.JSch;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import com.jcraft.jsch.Session;
|
||||
import processing.app.PreferencesData;
|
||||
|
||||
public class SSHPwdSetup implements SSHClientSetupChainRing {
|
||||
|
||||
@Override
|
||||
public Session setup(BoardPort port, JSch jSch) throws JSchException {
|
||||
String ipAddress = port.getAddress();
|
||||
|
||||
Session session = jSch.getSession("root", ipAddress, 22);
|
||||
session.setPassword(PreferencesData.get("runtime.pwd." + ipAddress));
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
}
|
194
arduino-core/src/cc/arduino/packages/uploaders/SSHUploader.java
Normal file
194
arduino-core/src/cc/arduino/packages/uploaders/SSHUploader.java
Normal file
@ -0,0 +1,194 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Arduino is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2013 Arduino LLC (http://www.arduino.cc/)
|
||||
*/
|
||||
|
||||
package cc.arduino.packages.uploaders;
|
||||
|
||||
import cc.arduino.packages.BoardPort;
|
||||
import cc.arduino.packages.Uploader;
|
||||
import cc.arduino.packages.ssh.*;
|
||||
import com.jcraft.jsch.JSch;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import com.jcraft.jsch.Session;
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.I18n;
|
||||
import processing.app.PreferencesData;
|
||||
import processing.app.debug.RunnerException;
|
||||
import processing.app.debug.TargetPlatform;
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
import processing.app.helpers.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
public class SSHUploader extends Uploader {
|
||||
|
||||
private static final List<String> FILES_NOT_TO_COPY = Arrays.asList(".DS_Store", ".Trash", "Thumbs.db", "__MACOSX");
|
||||
|
||||
private final BoardPort port;
|
||||
|
||||
public SSHUploader(BoardPort port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public boolean requiresAuthorization() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthorizationKey() {
|
||||
return "runtime.pwd." + port.getAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean uploadUsingPreferences(File sourcePath, String buildPath, String className, boolean usingProgrammer, List<String> warningsAccumulator) throws RunnerException {
|
||||
if (usingProgrammer) {
|
||||
throw new RunnerException(_("Network upload using programmer not supported"));
|
||||
}
|
||||
|
||||
Session session = null;
|
||||
SCP scp = null;
|
||||
try {
|
||||
JSch jSch = new JSch();
|
||||
SSHClientSetupChainRing sshClientSetupChain = new SSHConfigFileSetup(new SSHPwdSetup());
|
||||
session = sshClientSetupChain.setup(port, jSch);
|
||||
|
||||
session.setUserInfo(new NoInteractionUserInfo(PreferencesData.get("runtime.pwd." + port.getAddress())));
|
||||
session.connect(30000);
|
||||
|
||||
scp = new SCP(session);
|
||||
SSH ssh = new SSH(session);
|
||||
|
||||
scpFiles(scp, ssh, sourcePath, buildPath, className, warningsAccumulator);
|
||||
|
||||
return runAVRDude(ssh);
|
||||
} catch (JSchException e) {
|
||||
String message = e.getMessage();
|
||||
if ("Auth cancel".equals(message) || "Auth fail".equals(message)) {
|
||||
return false;
|
||||
}
|
||||
if (e.getMessage().contains("Connection refused")) {
|
||||
throw new RunnerException(I18n.format("Unable to connect to {0}", port.getAddress()));
|
||||
}
|
||||
throw new RunnerException(e);
|
||||
} catch (Exception e) {
|
||||
throw new RunnerException(e);
|
||||
} finally {
|
||||
if (scp != null) {
|
||||
try {
|
||||
scp.close();
|
||||
} catch (IOException e) {
|
||||
throw new RunnerException(e);
|
||||
}
|
||||
}
|
||||
if (session != null) {
|
||||
session.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean runAVRDude(SSH ssh) throws IOException, JSchException {
|
||||
TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
|
||||
PreferencesMap prefs = PreferencesData.getMap();
|
||||
prefs.putAll(BaseNoGui.getBoardPreferences());
|
||||
prefs.putAll(targetPlatform.getTool(prefs.get("upload.tool")));
|
||||
|
||||
String additionalParams = verbose ? prefs.get("upload.params.verbose") : prefs.get("upload.params.quiet");
|
||||
|
||||
boolean success = ssh.execSyncCommand("merge-sketch-with-bootloader.lua /tmp/sketch.hex", System.out, System.err);
|
||||
ssh.execSyncCommand("kill-bridge");
|
||||
success = success && ssh.execSyncCommand("run-avrdude /tmp/sketch.hex '" + additionalParams + "'", System.out, System.err);
|
||||
return success;
|
||||
}
|
||||
|
||||
private void scpFiles(SCP scp, SSH ssh, File sourcePath, String buildPath, String className, List<String> warningsAccumulator) throws JSchException, IOException {
|
||||
try {
|
||||
scp.open();
|
||||
scp.startFolder("tmp");
|
||||
scp.sendFile(new File(buildPath, className + ".hex"), "sketch.hex");
|
||||
scp.endFolder();
|
||||
|
||||
if (canUploadWWWFiles(sourcePath, ssh, warningsAccumulator)) {
|
||||
scp.startFolder("www");
|
||||
scp.startFolder("sd");
|
||||
scp.startFolder(sourcePath.getName());
|
||||
recursiveSCP(new File(sourcePath, "www"), scp);
|
||||
scp.endFolder();
|
||||
scp.endFolder();
|
||||
scp.endFolder();
|
||||
}
|
||||
} finally {
|
||||
scp.close();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canUploadWWWFiles(File sourcePath, SSH ssh, List<String> warningsAccumulator) throws IOException, JSchException {
|
||||
File www = new File(sourcePath, "www");
|
||||
if (!www.exists() || !www.isDirectory()) {
|
||||
return false;
|
||||
}
|
||||
if (!www.canExecute()) {
|
||||
warningsAccumulator.add(_("Problem accessing files in folder ") + www);
|
||||
return false;
|
||||
}
|
||||
if (!ssh.execSyncCommand("special-storage-available")) {
|
||||
warningsAccumulator.add(_("Problem accessing board folder /www/sd"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void recursiveSCP(File from, SCP scp) throws IOException {
|
||||
File[] files = from.listFiles();
|
||||
if (files == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (File file : files) {
|
||||
if (!StringUtils.stringContainsOneOf(file.getName(), FILES_NOT_TO_COPY)) {
|
||||
if (file.isDirectory() && file.canExecute()) {
|
||||
scp.startFolder(file.getName());
|
||||
recursiveSCP(file, scp);
|
||||
scp.endFolder();
|
||||
} else if (file.isFile() && file.canRead()) {
|
||||
scp.sendFile(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean burnBootloader() throws RunnerException {
|
||||
throw new RunnerException("Can't burn bootloader via SSH");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,340 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
BasicUploader - generic command line uploader implementation
|
||||
Part of the Arduino project - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2004-05
|
||||
Hernando Barragan
|
||||
Copyright (c) 2012
|
||||
Cristian Maglie <c.maglie@bug.st>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package cc.arduino.packages.uploaders;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.I18n;
|
||||
import processing.app.PreferencesData;
|
||||
import processing.app.Serial;
|
||||
import processing.app.SerialException;
|
||||
import processing.app.debug.RunnerException;
|
||||
import processing.app.debug.TargetPlatform;
|
||||
import processing.app.helpers.OSUtils;
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
import processing.app.helpers.StringReplacer;
|
||||
import cc.arduino.packages.Uploader;
|
||||
|
||||
public class SerialUploader extends Uploader {
|
||||
|
||||
public SerialUploader()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public SerialUploader(boolean noUploadPort)
|
||||
{
|
||||
super(noUploadPort);
|
||||
}
|
||||
|
||||
public boolean uploadUsingPreferences(File sourcePath, String buildPath, String className, boolean usingProgrammer, List<String> warningsAccumulator) throws Exception {
|
||||
// FIXME: Preferences should be reorganized
|
||||
TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
|
||||
PreferencesMap prefs = PreferencesData.getMap();
|
||||
prefs.putAll(BaseNoGui.getBoardPreferences());
|
||||
String tool = prefs.getOrExcept("upload.tool");
|
||||
if (tool.contains(":")) {
|
||||
String[] split = tool.split(":", 2);
|
||||
targetPlatform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
|
||||
tool = split[1];
|
||||
}
|
||||
prefs.putAll(targetPlatform.getTool(tool));
|
||||
|
||||
// if no protocol is specified for this board, assume it lacks a
|
||||
// bootloader and upload using the selected programmer.
|
||||
if (usingProgrammer || prefs.get("upload.protocol") == null) {
|
||||
return uploadUsingProgrammer(buildPath, className);
|
||||
}
|
||||
|
||||
if (noUploadPort)
|
||||
{
|
||||
prefs.put("build.path", buildPath);
|
||||
prefs.put("build.project_name", className);
|
||||
if (verbose)
|
||||
prefs.put("upload.verbose", prefs.getOrExcept("upload.params.verbose"));
|
||||
else
|
||||
prefs.put("upload.verbose", prefs.getOrExcept("upload.params.quiet"));
|
||||
|
||||
boolean uploadResult;
|
||||
try {
|
||||
String pattern = prefs.getOrExcept("upload.pattern");
|
||||
String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true);
|
||||
uploadResult = executeUploadCommand(cmd);
|
||||
} catch (Exception e) {
|
||||
throw new RunnerException(e);
|
||||
}
|
||||
return uploadResult;
|
||||
}
|
||||
|
||||
// need to do a little dance for Leonardo and derivatives:
|
||||
// open then close the port at the magic baudrate (usually 1200 bps) first
|
||||
// to signal to the sketch that it should reset into bootloader. after doing
|
||||
// this wait a moment for the bootloader to enumerate. On Windows, also must
|
||||
// deal with the fact that the COM port number changes from bootloader to
|
||||
// sketch.
|
||||
String t = prefs.get("upload.use_1200bps_touch");
|
||||
boolean doTouch = t != null && t.equals("true");
|
||||
|
||||
t = prefs.get("upload.wait_for_upload_port");
|
||||
boolean waitForUploadPort = (t != null) && t.equals("true");
|
||||
|
||||
if (doTouch) {
|
||||
String uploadPort = prefs.getOrExcept("serial.port");
|
||||
try {
|
||||
// Toggle 1200 bps on selected serial port to force board reset.
|
||||
List<String> before = Serial.list();
|
||||
if (before.contains(uploadPort)) {
|
||||
if (verbose)
|
||||
System.out.println(_("Forcing reset using 1200bps open/close on port ") + uploadPort);
|
||||
Serial.touchPort(uploadPort, 1200);
|
||||
}
|
||||
Thread.sleep(400);
|
||||
if (waitForUploadPort) {
|
||||
// Scanning for available ports seems to open the port or
|
||||
// otherwise assert DTR, which would cancel the WDT reset if
|
||||
// it happened within 250 ms. So we wait until the reset should
|
||||
// have already occured before we start scanning.
|
||||
uploadPort = waitForUploadPort(uploadPort, before);
|
||||
}
|
||||
} catch (SerialException e) {
|
||||
throw new RunnerException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RunnerException(e.getMessage());
|
||||
}
|
||||
prefs.put("serial.port", uploadPort);
|
||||
if (uploadPort.startsWith("/dev/"))
|
||||
prefs.put("serial.port.file", uploadPort.substring(5));
|
||||
else
|
||||
prefs.put("serial.port.file", uploadPort);
|
||||
}
|
||||
|
||||
prefs.put("build.path", buildPath);
|
||||
prefs.put("build.project_name", className);
|
||||
if (verbose)
|
||||
prefs.put("upload.verbose", prefs.getOrExcept("upload.params.verbose"));
|
||||
else
|
||||
prefs.put("upload.verbose", prefs.getOrExcept("upload.params.quiet"));
|
||||
|
||||
boolean uploadResult;
|
||||
try {
|
||||
// if (prefs.get("upload.disable_flushing") == null
|
||||
// || prefs.get("upload.disable_flushing").toLowerCase().equals("false")) {
|
||||
// flushSerialBuffer();
|
||||
// }
|
||||
|
||||
String pattern = prefs.getOrExcept("upload.pattern");
|
||||
String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true);
|
||||
uploadResult = executeUploadCommand(cmd);
|
||||
} catch (RunnerException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new RunnerException(e);
|
||||
}
|
||||
|
||||
try {
|
||||
if (uploadResult && doTouch) {
|
||||
String uploadPort = PreferencesData.get("serial.port");
|
||||
if (waitForUploadPort) {
|
||||
// For Due/Leonardo wait until the bootloader serial port disconnects and the
|
||||
// sketch serial port reconnects (or timeout after a few seconds if the
|
||||
// sketch port never comes back). Doing this saves users from accidentally
|
||||
// opening Serial Monitor on the soon-to-be-orphaned bootloader port.
|
||||
Thread.sleep(1000);
|
||||
long started = System.currentTimeMillis();
|
||||
while (System.currentTimeMillis() - started < 2000) {
|
||||
List<String> portList = Serial.list();
|
||||
if (portList.contains(uploadPort))
|
||||
break;
|
||||
Thread.sleep(250);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException ex) {
|
||||
// noop
|
||||
}
|
||||
return uploadResult;
|
||||
}
|
||||
|
||||
private String waitForUploadPort(String uploadPort, List<String> before) throws InterruptedException, RunnerException {
|
||||
// Wait for a port to appear on the list
|
||||
int elapsed = 0;
|
||||
while (elapsed < 10000) {
|
||||
List<String> now = Serial.list();
|
||||
List<String> diff = new ArrayList<String>(now);
|
||||
diff.removeAll(before);
|
||||
if (verbose) {
|
||||
System.out.print("PORTS {");
|
||||
for (String p : before)
|
||||
System.out.print(p + ", ");
|
||||
System.out.print("} / {");
|
||||
for (String p : now)
|
||||
System.out.print(p + ", ");
|
||||
System.out.print("} => {");
|
||||
for (String p : diff)
|
||||
System.out.print(p + ", ");
|
||||
System.out.println("}");
|
||||
}
|
||||
if (diff.size() > 0) {
|
||||
String newPort = diff.get(0);
|
||||
if (verbose)
|
||||
System.out.println("Found upload port: " + newPort);
|
||||
return newPort;
|
||||
}
|
||||
|
||||
// Keep track of port that disappears
|
||||
before = now;
|
||||
Thread.sleep(250);
|
||||
elapsed += 250;
|
||||
|
||||
// On Windows, it can take a long time for the port to disappear and
|
||||
// come back, so use a longer time out before assuming that the
|
||||
// selected
|
||||
// port is the bootloader (not the sketch).
|
||||
if (((!OSUtils.isWindows() && elapsed >= 500) || elapsed >= 5000) && now.contains(uploadPort)) {
|
||||
if (verbose)
|
||||
System.out.println("Uploading using selected port: " + uploadPort);
|
||||
return uploadPort;
|
||||
}
|
||||
}
|
||||
|
||||
// Something happened while detecting port
|
||||
throw new RunnerException(_("Couldn't find a Board on the selected port. Check that you have the correct port selected. If it is correct, try pressing the board's reset button after initiating the upload."));
|
||||
}
|
||||
|
||||
public boolean uploadUsingProgrammer(String buildPath, String className) throws Exception {
|
||||
|
||||
TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
|
||||
String programmer = PreferencesData.get("programmer");
|
||||
if (programmer.contains(":")) {
|
||||
String[] split = programmer.split(":", 2);
|
||||
targetPlatform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
|
||||
programmer = split[1];
|
||||
}
|
||||
|
||||
PreferencesMap prefs = PreferencesData.getMap();
|
||||
prefs.putAll(BaseNoGui.getBoardPreferences());
|
||||
PreferencesMap programmerPrefs = targetPlatform.getProgrammer(programmer);
|
||||
if (programmerPrefs == null)
|
||||
throw new RunnerException(
|
||||
_("Please select a programmer from Tools->Programmer menu"));
|
||||
prefs.putAll(programmerPrefs);
|
||||
prefs.putAll(targetPlatform.getTool(prefs.getOrExcept("program.tool")));
|
||||
|
||||
prefs.put("build.path", buildPath);
|
||||
prefs.put("build.project_name", className);
|
||||
|
||||
if (verbose)
|
||||
prefs.put("program.verbose", prefs.getOrExcept("program.params.verbose"));
|
||||
else
|
||||
prefs.put("program.verbose", prefs.getOrExcept("program.params.quiet"));
|
||||
|
||||
try {
|
||||
// if (prefs.get("program.disable_flushing") == null
|
||||
// || prefs.get("program.disable_flushing").toLowerCase().equals("false"))
|
||||
// {
|
||||
// flushSerialBuffer();
|
||||
// }
|
||||
|
||||
String pattern = prefs.getOrExcept("program.pattern");
|
||||
String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true);
|
||||
return executeUploadCommand(cmd);
|
||||
} catch (RunnerException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new RunnerException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean burnBootloader() throws Exception {
|
||||
TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
|
||||
|
||||
// Find preferences for the selected programmer
|
||||
PreferencesMap programmerPrefs;
|
||||
String programmer = PreferencesData.get("programmer");
|
||||
if (programmer.contains(":")) {
|
||||
String[] split = programmer.split(":", 2);
|
||||
TargetPlatform platform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
|
||||
programmer = split[1];
|
||||
programmerPrefs = platform.getProgrammer(programmer);
|
||||
} else {
|
||||
programmerPrefs = targetPlatform.getProgrammer(programmer);
|
||||
}
|
||||
if (programmerPrefs == null)
|
||||
throw new RunnerException(
|
||||
_("Please select a programmer from Tools->Programmer menu"));
|
||||
|
||||
// Build configuration for the current programmer
|
||||
PreferencesMap prefs = PreferencesData.getMap();
|
||||
prefs.putAll(BaseNoGui.getBoardPreferences());
|
||||
prefs.putAll(programmerPrefs);
|
||||
|
||||
// Create configuration for bootloader tool
|
||||
PreferencesMap toolPrefs = new PreferencesMap();
|
||||
String tool = prefs.getOrExcept("bootloader.tool");
|
||||
if (tool.contains(":")) {
|
||||
String[] split = tool.split(":", 2);
|
||||
TargetPlatform platform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
|
||||
tool = split[1];
|
||||
toolPrefs.putAll(platform.getTool(tool));
|
||||
if (toolPrefs.size() == 0)
|
||||
throw new RunnerException(I18n.format(_("Could not find tool {0} from package {1}"), tool, split[0]));
|
||||
}
|
||||
toolPrefs.putAll(targetPlatform.getTool(tool));
|
||||
if (toolPrefs.size() == 0)
|
||||
throw new RunnerException(I18n.format(_("Could not find tool {0}"), tool));
|
||||
|
||||
// Merge tool with global configuration
|
||||
prefs.putAll(toolPrefs);
|
||||
if (verbose) {
|
||||
prefs.put("erase.verbose", prefs.getOrExcept("erase.params.verbose"));
|
||||
prefs.put("bootloader.verbose", prefs.getOrExcept("bootloader.params.verbose"));
|
||||
} else {
|
||||
prefs.put("erase.verbose", prefs.getOrExcept("erase.params.quiet"));
|
||||
prefs.put("bootloader.verbose", prefs.getOrExcept("bootloader.params.quiet"));
|
||||
}
|
||||
|
||||
try {
|
||||
String pattern = prefs.getOrExcept("erase.pattern");
|
||||
String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true);
|
||||
if (!executeUploadCommand(cmd))
|
||||
return false;
|
||||
|
||||
pattern = prefs.getOrExcept("bootloader.pattern");
|
||||
cmd = StringReplacer.formatAndSplit(pattern, prefs, true);
|
||||
return executeUploadCommand(cmd);
|
||||
} catch (RunnerException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new RunnerException(e);
|
||||
}
|
||||
}
|
||||
}
|
977
arduino-core/src/processing/app/BaseNoGui.java
Normal file
977
arduino-core/src/processing/app/BaseNoGui.java
Normal file
@ -0,0 +1,977 @@
|
||||
package processing.app;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apache.commons.logging.impl.LogFactoryImpl;
|
||||
import org.apache.commons.logging.impl.NoOpLog;
|
||||
|
||||
import cc.arduino.packages.DiscoveryManager;
|
||||
import cc.arduino.packages.Uploader;
|
||||
|
||||
import processing.app.debug.Compiler;
|
||||
import processing.app.debug.TargetBoard;
|
||||
import processing.app.debug.TargetPackage;
|
||||
import processing.app.debug.TargetPlatform;
|
||||
import processing.app.debug.TargetPlatformException;
|
||||
import processing.app.helpers.BasicUserNotifier;
|
||||
import processing.app.helpers.CommandlineParser;
|
||||
import processing.app.helpers.OSUtils;
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
import processing.app.helpers.UserNotifier;
|
||||
import processing.app.helpers.filefilters.OnlyDirs;
|
||||
import processing.app.helpers.filefilters.OnlyFilesWithExtension;
|
||||
import processing.app.legacy.PApplet;
|
||||
import processing.app.packages.Library;
|
||||
import processing.app.packages.LibraryList;
|
||||
|
||||
public class BaseNoGui {
|
||||
|
||||
public static final int REVISION = 158;
|
||||
/** This might be replaced by main() if there's a lib/version.txt file. */
|
||||
static String VERSION_NAME = "0158";
|
||||
/** Set true if this a proper release rather than a numbered revision. */
|
||||
static public boolean RELEASE = false;
|
||||
|
||||
static File buildFolder;
|
||||
|
||||
// Current directory to use for relative paths specified on the
|
||||
// commandline
|
||||
static String currentDirectory = System.getProperty("user.dir");
|
||||
|
||||
private static DiscoveryManager discoveryManager = new DiscoveryManager();
|
||||
|
||||
// these are static because they're used by Sketch
|
||||
static private File examplesFolder;
|
||||
static private File toolsFolder;
|
||||
|
||||
// maps #included files to their library folder
|
||||
public static Map<String, Library> importToLibraryTable;
|
||||
|
||||
// maps library name to their library folder
|
||||
static private LibraryList libraries;
|
||||
|
||||
static private List<File> librariesFolders;
|
||||
|
||||
static UserNotifier notifier = new BasicUserNotifier();
|
||||
|
||||
static public Map<String, TargetPackage> packages;
|
||||
|
||||
static Platform platform;
|
||||
|
||||
static File portableFolder = null;
|
||||
|
||||
static final String portableSketchbookFolder = "sketchbook";
|
||||
|
||||
// Returns a File object for the given pathname. If the pathname
|
||||
// is not absolute, it is interpreted relative to the current
|
||||
// directory when starting the IDE (which is not the same as the
|
||||
// current working directory!).
|
||||
static public File absoluteFile(String path) {
|
||||
if (path == null) return null;
|
||||
|
||||
File file = new File(path);
|
||||
if (!file.isAbsolute()) {
|
||||
file = new File(currentDirectory, path);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of lines in a file by counting the number of newline
|
||||
* characters inside a String (and adding 1).
|
||||
*/
|
||||
static public int countLines(String what) {
|
||||
int count = 1;
|
||||
for (char c : what.toCharArray()) {
|
||||
if (c == '\n') count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to the platform's temporary folder, by creating
|
||||
* a temporary temporary file and getting its parent folder.
|
||||
* <br/>
|
||||
* Modified for revision 0094 to actually make the folder randomized
|
||||
* to avoid conflicts in multi-user environments. (Bug 177)
|
||||
*/
|
||||
static public File createTempFolder(String name) {
|
||||
try {
|
||||
File folder = File.createTempFile(name, null);
|
||||
//String tempPath = ignored.getParent();
|
||||
//return new File(tempPath);
|
||||
folder.delete();
|
||||
folder.mkdirs();
|
||||
return folder;
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static public String getAvrBasePath() {
|
||||
String path = getHardwarePath() + File.separator + "tools" +
|
||||
File.separator + "avr" + File.separator + "bin" + File.separator;
|
||||
if (OSUtils.isLinux() && !(new File(path)).exists()) {
|
||||
return ""; // use distribution provided avr tools if bundled tools missing
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
static public File getBuildFolder() {
|
||||
if (buildFolder == null) {
|
||||
String buildPath = PreferencesData.get("build.path");
|
||||
if (buildPath != null) {
|
||||
buildFolder = absoluteFile(buildPath);
|
||||
if (!buildFolder.exists())
|
||||
buildFolder.mkdirs();
|
||||
} else {
|
||||
//File folder = new File(getTempFolder(), "build");
|
||||
//if (!folder.exists()) folder.mkdirs();
|
||||
buildFolder = createTempFolder("build");
|
||||
buildFolder.deleteOnExit();
|
||||
}
|
||||
}
|
||||
return buildFolder;
|
||||
}
|
||||
|
||||
static public PreferencesMap getBoardPreferences() {
|
||||
TargetBoard board = getTargetBoard();
|
||||
|
||||
PreferencesMap prefs = new PreferencesMap(board.getPreferences());
|
||||
for (String menuId : board.getMenuIds()) {
|
||||
String entry = PreferencesData.get("custom_" + menuId);
|
||||
if (board.hasMenu(menuId) && entry != null &&
|
||||
entry.startsWith(board.getId())) {
|
||||
String selectionId = entry.substring(entry.indexOf("_") + 1);
|
||||
prefs.putAll(board.getMenuPreferences(menuId, selectionId));
|
||||
prefs.put("name", prefs.get("name") + ", " +
|
||||
board.getMenuLabel(menuId, selectionId));
|
||||
}
|
||||
}
|
||||
return prefs;
|
||||
}
|
||||
|
||||
static public File getContentFile(String name) {
|
||||
String path = System.getProperty("user.dir");
|
||||
|
||||
// Get a path to somewhere inside the .app folder
|
||||
if (OSUtils.isMacOS()) {
|
||||
// <key>javaroot</key>
|
||||
// <string>$JAVAROOT</string>
|
||||
String javaroot = System.getProperty("javaroot");
|
||||
if (javaroot != null) {
|
||||
path = javaroot;
|
||||
}
|
||||
}
|
||||
File working = new File(path);
|
||||
return new File(working, name);
|
||||
}
|
||||
|
||||
static public TargetPlatform getCurrentTargetPlatformFromPackage(String pack) {
|
||||
return getTargetPlatform(pack, PreferencesData.get("target_platform"));
|
||||
}
|
||||
|
||||
static public File getDefaultSketchbookFolder() {
|
||||
if (getPortableFolder() != null)
|
||||
return new File(getPortableFolder(), getPortableSketchbookFolder());
|
||||
|
||||
File sketchbookFolder = null;
|
||||
try {
|
||||
sketchbookFolder = getPlatform().getDefaultSketchbookFolder();
|
||||
} catch (Exception e) { }
|
||||
|
||||
return sketchbookFolder;
|
||||
}
|
||||
|
||||
public static DiscoveryManager getDiscoveryManager() {
|
||||
return discoveryManager;
|
||||
}
|
||||
|
||||
static public File getExamplesFolder() {
|
||||
return examplesFolder;
|
||||
}
|
||||
|
||||
static public String getExamplesPath() {
|
||||
return examplesFolder.getAbsolutePath();
|
||||
}
|
||||
|
||||
static public File getHardwareFolder() {
|
||||
// calculate on the fly because it's needed by Preferences.init() to find
|
||||
// the boards.txt and programmers.txt preferences files (which happens
|
||||
// before the other folders / paths get cached).
|
||||
return getContentFile("hardware");
|
||||
}
|
||||
|
||||
static public String getHardwarePath() {
|
||||
return getHardwareFolder().getAbsolutePath();
|
||||
}
|
||||
|
||||
static public LibraryList getLibraries() {
|
||||
return libraries;
|
||||
}
|
||||
|
||||
static public List<File> getLibrariesPath() {
|
||||
return librariesFolders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an InputStream for a file inside the Processing lib folder.
|
||||
*/
|
||||
static public InputStream getLibStream(String filename) throws IOException {
|
||||
return new FileInputStream(new File(getContentFile("lib"), filename));
|
||||
}
|
||||
|
||||
static public Platform getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
static public File getPortableFolder() {
|
||||
return portableFolder;
|
||||
}
|
||||
|
||||
static public String getPortableSketchbookFolder() {
|
||||
return portableSketchbookFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to get a File object for the specified filename inside
|
||||
* the settings folder.
|
||||
* For now, only used by Preferences to get the preferences.txt file.
|
||||
* @param filename A file inside the settings folder.
|
||||
* @return filename wrapped as a File object inside the settings folder
|
||||
*/
|
||||
static public File getSettingsFile(String filename) {
|
||||
return new File(getSettingsFolder(), filename);
|
||||
}
|
||||
|
||||
static public File getSettingsFolder() {
|
||||
if (getPortableFolder() != null)
|
||||
return getPortableFolder();
|
||||
|
||||
File settingsFolder = null;
|
||||
|
||||
String preferencesPath = PreferencesData.get("settings.path");
|
||||
if (preferencesPath != null) {
|
||||
settingsFolder = absoluteFile(preferencesPath);
|
||||
|
||||
} else {
|
||||
try {
|
||||
settingsFolder = getPlatform().getSettingsFolder();
|
||||
} catch (Exception e) {
|
||||
showError(_("Problem getting data folder"),
|
||||
_("Error getting the Arduino data folder."), e);
|
||||
}
|
||||
}
|
||||
|
||||
// create the folder if it doesn't exist already
|
||||
if (!settingsFolder.exists()) {
|
||||
if (!settingsFolder.mkdirs()) {
|
||||
showError(_("Settings issues"),
|
||||
_("Arduino cannot run because it could not\n" +
|
||||
"create a folder to store your settings."), null);
|
||||
}
|
||||
}
|
||||
return settingsFolder;
|
||||
}
|
||||
|
||||
static public File getSketchbookFolder() {
|
||||
if (portableFolder != null)
|
||||
return new File(portableFolder, PreferencesData.get("sketchbook.path"));
|
||||
return absoluteFile(PreferencesData.get("sketchbook.path"));
|
||||
}
|
||||
|
||||
static public File getSketchbookHardwareFolder() {
|
||||
return new File(getSketchbookFolder(), "hardware");
|
||||
}
|
||||
|
||||
static public File getSketchbookLibrariesFolder() {
|
||||
File libdir = new File(getSketchbookFolder(), "libraries");
|
||||
if (!libdir.exists()) {
|
||||
try {
|
||||
libdir.mkdirs();
|
||||
File readme = new File(libdir, "readme.txt");
|
||||
FileWriter freadme = new FileWriter(readme);
|
||||
freadme.write(_("For information on installing libraries, see: " +
|
||||
"http://arduino.cc/en/Guide/Libraries\n"));
|
||||
freadme.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return libdir;
|
||||
}
|
||||
|
||||
static public String getSketchbookPath() {
|
||||
// Get the sketchbook path, and make sure it's set properly
|
||||
String sketchbookPath = PreferencesData.get("sketchbook.path");
|
||||
|
||||
// If a value is at least set, first check to see if the folder exists.
|
||||
// If it doesn't, warn the user that the sketchbook folder is being reset.
|
||||
if (sketchbookPath != null) {
|
||||
File sketchbookFolder;
|
||||
if (getPortableFolder() != null)
|
||||
sketchbookFolder = new File(getPortableFolder(), sketchbookPath);
|
||||
else
|
||||
sketchbookFolder = absoluteFile(sketchbookPath);
|
||||
if (!sketchbookFolder.exists()) {
|
||||
showWarning(_("Sketchbook folder disappeared"),
|
||||
_("The sketchbook folder no longer exists.\n" +
|
||||
"Arduino will switch to the default sketchbook\n" +
|
||||
"location, and create a new sketchbook folder if\n" +
|
||||
"necessary. Arduino will then stop talking about\n" +
|
||||
"himself in the third person."), null);
|
||||
sketchbookPath = null;
|
||||
}
|
||||
}
|
||||
|
||||
return sketchbookPath;
|
||||
}
|
||||
|
||||
public static TargetBoard getTargetBoard() {
|
||||
String boardId = PreferencesData.get("board");
|
||||
return getTargetPlatform().getBoard(boardId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specific TargetPackage
|
||||
*
|
||||
* @param packageName
|
||||
* @return
|
||||
*/
|
||||
static public TargetPackage getTargetPackage(String packageName) {
|
||||
return packages.get(packageName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently selected TargetPlatform.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
static public TargetPlatform getTargetPlatform() {
|
||||
String packageName = PreferencesData.get("target_package");
|
||||
String platformName = PreferencesData.get("target_platform");
|
||||
return getTargetPlatform(packageName, platformName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specific TargetPlatform searching Package/Platform
|
||||
*
|
||||
* @param packageName
|
||||
* @param platformName
|
||||
* @return
|
||||
*/
|
||||
static public TargetPlatform getTargetPlatform(String packageName,
|
||||
String platformName) {
|
||||
TargetPackage p = packages.get(packageName);
|
||||
if (p == null)
|
||||
return null;
|
||||
return p.get(platformName);
|
||||
}
|
||||
|
||||
static public File getToolsFolder() {
|
||||
return toolsFolder;
|
||||
}
|
||||
|
||||
static public String getToolsPath() {
|
||||
return toolsFolder.getAbsolutePath();
|
||||
}
|
||||
|
||||
static public LibraryList getUserLibs() {
|
||||
if (libraries == null)
|
||||
return new LibraryList();
|
||||
return libraries.filterLibrariesInSubfolder(getSketchbookFolder());
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a folder, return a list of the header files in that folder (but not
|
||||
* the header files in its sub-folders, as those should be included from
|
||||
* within the header files at the top-level).
|
||||
*/
|
||||
static public String[] headerListFromIncludePath(File path) throws IOException {
|
||||
String[] list = path.list(new OnlyFilesWithExtension(".h"));
|
||||
if (list == null) {
|
||||
throw new IOException();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
static public void init(String[] args) {
|
||||
getPlatform().init();
|
||||
|
||||
String sketchbookPath = getSketchbookPath();
|
||||
|
||||
// If no path is set, get the default sketchbook folder for this platform
|
||||
if (sketchbookPath == null) {
|
||||
if (BaseNoGui.getPortableFolder() != null)
|
||||
PreferencesData.set("sketchbook.path", getPortableSketchbookFolder());
|
||||
else
|
||||
showError(_("No sketchbook"), _("Sketchbook path not defined"), null);
|
||||
}
|
||||
|
||||
BaseNoGui.initPackages();
|
||||
|
||||
// Setup board-dependent variables.
|
||||
onBoardOrPortChange();
|
||||
|
||||
CommandlineParser parser = CommandlineParser.newCommandlineParser(args);
|
||||
|
||||
for (String path: parser.getFilenames()) {
|
||||
// Correctly resolve relative paths
|
||||
File file = absoluteFile(path);
|
||||
|
||||
// Fix a problem with systems that use a non-ASCII languages. Paths are
|
||||
// being passed in with 8.3 syntax, which makes the sketch loader code
|
||||
// unhappy, since the sketch folder naming doesn't match up correctly.
|
||||
// http://dev.processing.org/bugs/show_bug.cgi?id=1089
|
||||
if (OSUtils.isWindows()) {
|
||||
try {
|
||||
file = file.getCanonicalFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (!parser.isVerifyOrUploadMode() && !parser.isGetPrefMode())
|
||||
showError(_("Mode not supported"), _("Only --verify, --upload or --get-pref are supported"), null);
|
||||
|
||||
if (!parser.isForceSavePrefs())
|
||||
PreferencesData.setDoSave(false);
|
||||
if (!file.exists()) {
|
||||
String mess = I18n.format(_("Failed to open sketch: \"{0}\""), path);
|
||||
// Open failure is fatal in upload/verify mode
|
||||
showError(null, mess, 2);
|
||||
}
|
||||
}
|
||||
|
||||
// Save the preferences. For GUI mode, this happens in the quit
|
||||
// handler, but for other modes we should also make sure to save
|
||||
// them.
|
||||
PreferencesData.save();
|
||||
|
||||
if (parser.isVerifyOrUploadMode()) {
|
||||
// Set verbosity for command line build
|
||||
PreferencesData.set("build.verbose", "" + parser.isDoVerboseBuild());
|
||||
PreferencesData.set("upload.verbose", "" + parser.isDoVerboseUpload());
|
||||
|
||||
// Make sure these verbosity preferences are only for the
|
||||
// current session
|
||||
PreferencesData.setDoSave(false);
|
||||
|
||||
if (parser.isUploadMode()) {
|
||||
|
||||
if (parser.getFilenames().size() != 1)
|
||||
{
|
||||
showError(_("Multiple files not supported"), _("The --upload option supports only one file at a time"), null);
|
||||
}
|
||||
|
||||
List<String> warningsAccumulator = new LinkedList<String>();
|
||||
boolean success = false;
|
||||
try {
|
||||
// costruttore di Editor carica lo sketch usando handleOpenInternal() che fa
|
||||
// la new di Sketch che chiama load() nel suo costruttore
|
||||
// In questo punto questo si traduce in:
|
||||
// SketchData data = new SketchData(file);
|
||||
// File tempBuildFolder = getBuildFolder();
|
||||
// data.load();
|
||||
SketchData data = new SketchData(absoluteFile(parser.getFilenames().get(0)));
|
||||
File tempBuildFolder = getBuildFolder();
|
||||
data.load();
|
||||
|
||||
// Sketch.exportApplet()
|
||||
// - chiama Sketch.prepare() che chiama Sketch.ensureExistence()
|
||||
// - chiama Sketch.build(verbose=false) che chiama Sketch.ensureExistence(), imposta il progressListener e chiama Compiler.build()
|
||||
// - chiama Sketch.upload() (cfr. dopo...)
|
||||
if (!data.getFolder().exists()) showError(_("No sketch"), _("Can't find the sketch in the specified path"), null);
|
||||
String suggestedClassName = Compiler.build(data, tempBuildFolder.getAbsolutePath(), tempBuildFolder, null, parser.isDoVerboseBuild());
|
||||
if (suggestedClassName == null) showError(_("Error while verifying"), _("An error occurred while verifying the sketch"), null);
|
||||
showMessage(_("Done compiling"), _("Done compiling"));
|
||||
|
||||
// - chiama Sketch.upload() ... to be continued ...
|
||||
Uploader uploader = Compiler.getUploaderByPreferences(parser.isNoUploadPort());
|
||||
if (uploader.requiresAuthorization() && !PreferencesData.has(uploader.getAuthorizationKey())) showError(_("..."), _("..."), null);
|
||||
try {
|
||||
success = Compiler.upload(data, uploader, tempBuildFolder.getAbsolutePath(), suggestedClassName, parser.isDoUseProgrammer(), parser.isNoUploadPort(), warningsAccumulator);
|
||||
showMessage(_("Done uploading"), _("Done uploading"));
|
||||
} finally {
|
||||
if (uploader.requiresAuthorization() && !success) {
|
||||
PreferencesData.remove(uploader.getAuthorizationKey());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
showError(_("Error while verifying/uploading"), _("An error occurred while verifying/uploading the sketch"), e);
|
||||
}
|
||||
for (String warning : warningsAccumulator) {
|
||||
System.out.print(_("Warning"));
|
||||
System.out.print(": ");
|
||||
System.out.println(warning);
|
||||
}
|
||||
if (!success) showError(_("Error while uploading"), _("An error occurred while uploading the sketch"), null);
|
||||
} else {
|
||||
|
||||
for (String path : parser.getFilenames())
|
||||
{
|
||||
try {
|
||||
// costruttore di Editor carica lo sketch usando handleOpenInternal() che fa
|
||||
// la new di Sketch che chiama load() nel suo costruttore
|
||||
// In questo punto questo si traduce in:
|
||||
// SketchData data = new SketchData(file);
|
||||
// File tempBuildFolder = getBuildFolder();
|
||||
// data.load();
|
||||
SketchData data = new SketchData(absoluteFile(path));
|
||||
File tempBuildFolder = getBuildFolder();
|
||||
data.load();
|
||||
|
||||
// metodo Sketch.prepare() chiama Sketch.ensureExistence()
|
||||
// Sketch.build(verbose) chiama Sketch.ensureExistence() e poi imposta il progressListener e, finalmente, chiama Compiler.build()
|
||||
// In questo punto questo si traduce in:
|
||||
// if (!data.getFolder().exists()) showError(...);
|
||||
// String ... = Compiler.build(data, tempBuildFolder.getAbsolutePath(), tempBuildFolder, null, verbose);
|
||||
if (!data.getFolder().exists()) showError(_("No sketch"), _("Can't find the sketch in the specified path"), null);
|
||||
String suggestedClassName = Compiler.build(data, tempBuildFolder.getAbsolutePath(), tempBuildFolder, null, parser.isDoVerboseBuild());
|
||||
if (suggestedClassName == null) showError(_("Error while verifying"), _("An error occurred while verifying the sketch"), null);
|
||||
showMessage(_("Done compiling"), _("Done compiling"));
|
||||
} catch (Exception e) {
|
||||
showError(_("Error while verifying"), _("An error occurred while verifying the sketch"), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// No errors exit gracefully
|
||||
System.exit(0);
|
||||
}
|
||||
else if (parser.isGetPrefMode()) {
|
||||
String value = PreferencesData.get(parser.getGetPref(), null);
|
||||
if (value != null) {
|
||||
System.out.println(value);
|
||||
System.exit(0);
|
||||
} else {
|
||||
System.exit(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static public void initLogger() {
|
||||
System.setProperty(LogFactoryImpl.LOG_PROPERTY, NoOpLog.class.getCanonicalName());
|
||||
Logger.getLogger("javax.jmdns").setLevel(Level.OFF);
|
||||
}
|
||||
|
||||
static public void initPackages() {
|
||||
packages = new HashMap<String, TargetPackage>();
|
||||
loadHardware(getHardwareFolder());
|
||||
loadHardware(getSketchbookHardwareFolder());
|
||||
if (packages.size() == 0) {
|
||||
System.out.println(_("No valid configured cores found! Exiting..."));
|
||||
System.exit(3);
|
||||
}
|
||||
}
|
||||
|
||||
static protected void initPlatform() {
|
||||
try {
|
||||
Class<?> platformClass = Class.forName("processing.app.Platform");
|
||||
if (OSUtils.isMacOS()) {
|
||||
platformClass = Class.forName("processing.app.macosx.Platform");
|
||||
} else if (OSUtils.isWindows()) {
|
||||
platformClass = Class.forName("processing.app.windows.Platform");
|
||||
} else if (OSUtils.isLinux()) {
|
||||
platformClass = Class.forName("processing.app.linux.Platform");
|
||||
}
|
||||
platform = (Platform) platformClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
showError(_("Problem Setting the Platform"),
|
||||
_("An unknown error occurred while trying to load\n" +
|
||||
"platform-specific code for your machine."), e);
|
||||
}
|
||||
}
|
||||
|
||||
static public void initPortableFolder() {
|
||||
// Portable folder
|
||||
portableFolder = getContentFile("portable");
|
||||
if (!portableFolder.exists())
|
||||
portableFolder = null;
|
||||
}
|
||||
|
||||
static public void initVersion() {
|
||||
try {
|
||||
File versionFile = getContentFile("lib/version.txt");
|
||||
if (versionFile.exists()) {
|
||||
String version = PApplet.loadStrings(versionFile)[0];
|
||||
if (!version.equals(VERSION_NAME) && !version.equals("${version}")) {
|
||||
VERSION_NAME = version;
|
||||
RELEASE = true;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// help 3rd party installers find the correct hardware path
|
||||
PreferencesData.set("last.ide." + VERSION_NAME + ".hardwarepath", getHardwarePath());
|
||||
PreferencesData.set("last.ide." + VERSION_NAME + ".daterun", "" + (new Date()).getTime() / 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the name is valid for a Processing sketch.
|
||||
*/
|
||||
static public boolean isSanitaryName(String name) {
|
||||
return sanitizeName(name).equals(name);
|
||||
}
|
||||
|
||||
static protected void loadHardware(File folder) {
|
||||
if (!folder.isDirectory()) return;
|
||||
|
||||
String list[] = folder.list(new OnlyDirs());
|
||||
|
||||
// if a bad folder or something like that, this might come back null
|
||||
if (list == null) return;
|
||||
|
||||
// alphabetize list, since it's not always alpha order
|
||||
// replaced hella slow bubble sort with this feller for 0093
|
||||
Arrays.sort(list, String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
for (String target : list) {
|
||||
// Skip reserved 'tools' folder.
|
||||
if (target.equals("tools"))
|
||||
continue;
|
||||
File subfolder = new File(folder, target);
|
||||
|
||||
try {
|
||||
packages.put(target, new TargetPackage(target, subfolder));
|
||||
} catch (TargetPlatformException e) {
|
||||
System.out.println("WARNING: Error loading hardware folder " + target);
|
||||
System.out.println(" " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Grab the contents of a file as a string.
|
||||
*/
|
||||
static public String loadFile(File file) throws IOException {
|
||||
String[] contents = PApplet.loadStrings(file);
|
||||
if (contents == null) return null;
|
||||
return PApplet.join(contents, "\n");
|
||||
}
|
||||
|
||||
static public void main(String args[]) throws Exception {
|
||||
if (args.length == 0)
|
||||
showError(_("No parameters"), _("No command line parameters found"), null);
|
||||
|
||||
initPlatform();
|
||||
|
||||
initPortableFolder();
|
||||
|
||||
initParameters(args);
|
||||
|
||||
init(args);
|
||||
}
|
||||
|
||||
static public void onBoardOrPortChange() {
|
||||
TargetPlatform targetPlatform = getTargetPlatform();
|
||||
if (targetPlatform == null)
|
||||
return;
|
||||
|
||||
// Calculate paths for libraries and examples
|
||||
examplesFolder = getContentFile("examples");
|
||||
toolsFolder = getContentFile("tools");
|
||||
|
||||
File platformFolder = targetPlatform.getFolder();
|
||||
librariesFolders = new ArrayList<File>();
|
||||
librariesFolders.add(getContentFile("libraries"));
|
||||
String core = getBoardPreferences().get("build.core");
|
||||
if (core.contains(":")) {
|
||||
String referencedCore = core.split(":")[0];
|
||||
TargetPlatform referencedPlatform = getTargetPlatform(referencedCore, targetPlatform.getId());
|
||||
if (referencedPlatform != null) {
|
||||
File referencedPlatformFolder = referencedPlatform.getFolder();
|
||||
librariesFolders.add(new File(referencedPlatformFolder, "libraries"));
|
||||
}
|
||||
}
|
||||
librariesFolders.add(new File(platformFolder, "libraries"));
|
||||
librariesFolders.add(getSketchbookLibrariesFolder());
|
||||
|
||||
// Scan for libraries in each library folder.
|
||||
// Libraries located in the latest folders on the list can override
|
||||
// other libraries with the same name.
|
||||
try {
|
||||
scanAndUpdateLibraries(librariesFolders);
|
||||
} catch (IOException e) {
|
||||
showWarning(_("Error"), _("Error loading libraries"), e);
|
||||
}
|
||||
|
||||
populateImportToLibraryTable();
|
||||
}
|
||||
|
||||
static public void populateImportToLibraryTable() {
|
||||
// Populate importToLibraryTable
|
||||
importToLibraryTable = new HashMap<String, Library>();
|
||||
for (Library lib : getLibraries()) {
|
||||
try {
|
||||
String headers[] = headerListFromIncludePath(lib.getSrcFolder());
|
||||
for (String header : headers) {
|
||||
Library old = importToLibraryTable.get(header);
|
||||
if (old != null) {
|
||||
// If a library was already found with this header, keep
|
||||
// it if the library's name matches the header name.
|
||||
String name = header.substring(0, header.length() - 2);
|
||||
if (old.getFolder().getPath().endsWith(name))
|
||||
continue;
|
||||
}
|
||||
importToLibraryTable.put(header, lib);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
showWarning(_("Error"), I18n
|
||||
.format("Unable to list header files in {0}", lib.getSrcFolder()), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static public void initParameters(String args[]) {
|
||||
String preferencesFile = null;
|
||||
|
||||
// Do a first pass over the commandline arguments, the rest of them
|
||||
// will be processed by the Base constructor. Note that this loop
|
||||
// does not look at the last element of args, to prevent crashing
|
||||
// when no parameter was specified to an option. Later, Base() will
|
||||
// then show an error for these.
|
||||
for (int i = 0; i < args.length - 1; i++) {
|
||||
if (args[i].equals("--preferences-file")) {
|
||||
++i;
|
||||
preferencesFile = args[i];
|
||||
continue;
|
||||
}
|
||||
if (args[i].equals("--curdir")) {
|
||||
i++;
|
||||
currentDirectory = args[i];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// run static initialization that grabs all the prefs
|
||||
PreferencesData.init(absoluteFile(preferencesFile));
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively remove all files within a directory,
|
||||
* used with removeDir(), or when the contents of a dir
|
||||
* should be removed, but not the directory itself.
|
||||
* (i.e. when cleaning temp files from lib/build)
|
||||
*/
|
||||
static public void removeDescendants(File dir) {
|
||||
if (!dir.exists()) return;
|
||||
|
||||
String files[] = dir.list();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
if (files[i].equals(".") || files[i].equals("..")) continue;
|
||||
File dead = new File(dir, files[i]);
|
||||
if (!dead.isDirectory()) {
|
||||
if (!PreferencesData.getBoolean("compiler.save_build_files")) {
|
||||
if (!dead.delete()) {
|
||||
// temporarily disabled
|
||||
System.err.println(I18n.format(_("Could not delete {0}"), dead));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
removeDir(dead);
|
||||
//dead.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all files in a directory and the directory itself.
|
||||
*/
|
||||
static public void removeDir(File dir) {
|
||||
if (dir.exists()) {
|
||||
removeDescendants(dir);
|
||||
if (!dir.delete()) {
|
||||
System.err.println(I18n.format(_("Could not delete {0}"), dir));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Produce a sanitized name that fits our standards for likely to work.
|
||||
* <p/>
|
||||
* Java classes have a wider range of names that are technically allowed
|
||||
* (supposedly any Unicode name) than what we support. The reason for
|
||||
* going more narrow is to avoid situations with text encodings and
|
||||
* converting during the process of moving files between operating
|
||||
* systems, i.e. uploading from a Windows machine to a Linux server,
|
||||
* or reading a FAT32 partition in OS X and using a thumb drive.
|
||||
* <p/>
|
||||
* This helper function replaces everything but A-Z, a-z, and 0-9 with
|
||||
* underscores. Also disallows starting the sketch name with a digit.
|
||||
*/
|
||||
static public String sanitizeName(String origName) {
|
||||
char c[] = origName.toCharArray();
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
// can't lead with a digit, so start with an underscore
|
||||
if ((c[0] >= '0') && (c[0] <= '9')) {
|
||||
buffer.append('_');
|
||||
}
|
||||
for (int i = 0; i < c.length; i++) {
|
||||
if (((c[i] >= '0') && (c[i] <= '9')) ||
|
||||
((c[i] >= 'a') && (c[i] <= 'z')) ||
|
||||
((c[i] >= 'A') && (c[i] <= 'Z')) ||
|
||||
((i > 0) && (c[i] == '-')) ||
|
||||
((i > 0) && (c[i] == '.'))) {
|
||||
buffer.append(c[i]);
|
||||
} else {
|
||||
buffer.append('_');
|
||||
}
|
||||
}
|
||||
// let's not be ridiculous about the length of filenames.
|
||||
// in fact, Mac OS 9 can handle 255 chars, though it can't really
|
||||
// deal with filenames longer than 31 chars in the Finder.
|
||||
// but limiting to that for sketches would mean setting the
|
||||
// upper-bound on the character limit here to 25 characters
|
||||
// (to handle the base name + ".class")
|
||||
if (buffer.length() > 63) {
|
||||
buffer.setLength(63);
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Spew the contents of a String object out to a file.
|
||||
*/
|
||||
static public void saveFile(String str, File file) throws IOException {
|
||||
File temp = File.createTempFile(file.getName(), null, file.getParentFile());
|
||||
PApplet.saveStrings(temp, new String[] { str });
|
||||
if (file.exists()) {
|
||||
boolean result = file.delete();
|
||||
if (!result) {
|
||||
throw new IOException(
|
||||
I18n.format(
|
||||
_("Could not remove old version of {0}"),
|
||||
file.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
boolean result = temp.renameTo(file);
|
||||
if (!result) {
|
||||
throw new IOException(
|
||||
I18n.format(
|
||||
_("Could not replace {0}"),
|
||||
file.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
|
||||
static public void scanAndUpdateLibraries(List<File> folders) throws IOException {
|
||||
libraries = scanLibraries(folders);
|
||||
}
|
||||
|
||||
static public LibraryList scanLibraries(List<File> folders) throws IOException {
|
||||
LibraryList res = new LibraryList();
|
||||
for (File folder : folders)
|
||||
res.addOrReplaceAll(scanLibraries(folder));
|
||||
return res;
|
||||
}
|
||||
|
||||
static public LibraryList scanLibraries(File folder) throws IOException {
|
||||
LibraryList res = new LibraryList();
|
||||
|
||||
String list[] = folder.list(new OnlyDirs());
|
||||
// if a bad folder or something like that, this might come back null
|
||||
if (list == null)
|
||||
return res;
|
||||
|
||||
for (String libName : list) {
|
||||
File subfolder = new File(folder, libName);
|
||||
if (!isSanitaryName(libName)) {
|
||||
String mess = I18n.format(_("The library \"{0}\" cannot be used.\n"
|
||||
+ "Library names must contain only basic letters and numbers.\n"
|
||||
+ "(ASCII only and no spaces, and it cannot start with a number)"),
|
||||
libName);
|
||||
showMessage(_("Ignoring bad library name"), mess);
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
Library lib = Library.create(subfolder);
|
||||
// (also replace previously found libs with the same name)
|
||||
if (lib != null)
|
||||
res.addOrReplace(lib);
|
||||
} catch (IOException e) {
|
||||
System.out.println(I18n.format(_("Invalid library found in {0}: {1}"),
|
||||
subfolder, e.getMessage()));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static public void selectBoard(TargetBoard targetBoard) {
|
||||
TargetPlatform targetPlatform = targetBoard.getContainerPlatform();
|
||||
TargetPackage targetPackage = targetPlatform.getContainerPackage();
|
||||
|
||||
PreferencesData.set("target_package", targetPackage.getId());
|
||||
PreferencesData.set("target_platform", targetPlatform.getId());
|
||||
PreferencesData.set("board", targetBoard.getId());
|
||||
|
||||
File platformFolder = targetPlatform.getFolder();
|
||||
PreferencesData.set("runtime.platform.path", platformFolder.getAbsolutePath());
|
||||
PreferencesData.set("runtime.hardware.path", platformFolder.getParentFile().getAbsolutePath());
|
||||
}
|
||||
|
||||
public static void selectSerialPort(String port) {
|
||||
PreferencesData.set("serial.port", port);
|
||||
if (port.startsWith("/dev/"))
|
||||
PreferencesData.set("serial.port.file", port.substring(5));
|
||||
else
|
||||
PreferencesData.set("serial.port.file", port);
|
||||
}
|
||||
|
||||
public static void setBuildFolder(File newBuildFolder) {
|
||||
buildFolder = newBuildFolder;
|
||||
}
|
||||
|
||||
static public void showError(String title, String message, int exit_code) {
|
||||
showError(title, message, null, exit_code);
|
||||
}
|
||||
|
||||
static public void showError(String title, String message, Throwable e) {
|
||||
notifier.showError(title, message, e, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show an error message that's actually fatal to the program.
|
||||
* This is an error that can't be recovered. Use showWarning()
|
||||
* for errors that allow P5 to continue running.
|
||||
*/
|
||||
static public void showError(String title, String message, Throwable e, int exit_code) {
|
||||
notifier.showError(title, message, e, exit_code);
|
||||
}
|
||||
|
||||
/**
|
||||
* "No cookie for you" type messages. Nothing fatal or all that
|
||||
* much of a bummer, but something to notify the user about.
|
||||
*/
|
||||
static public void showMessage(String title, String message) {
|
||||
notifier.showMessage(title, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Non-fatal error message with optional stack trace side dish.
|
||||
*/
|
||||
static public void showWarning(String title, String message, Exception e) {
|
||||
notifier.showWarning(title, message, e);
|
||||
}
|
||||
|
||||
}
|
96
arduino-core/src/processing/app/I18n.java
Normal file
96
arduino-core/src/processing/app/I18n.java
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* by Shigeru KANEMOTO at SWITCHSCIENCE.
|
||||
*
|
||||
* Extract strings to be translated by:
|
||||
* % xgettext -L Java --from-code=utf-8 -k_ -d Resources_ja *.java
|
||||
* Extract and merge by:
|
||||
* % xgettext -j -L Java --from-code=utf-8 -k_ -d Resources_ja *.java
|
||||
*
|
||||
* Edit "Resources_ja.po".
|
||||
* Convert to the properties file format by:
|
||||
* % msgcat -p Resources_ja.po > Resources_ja.properties
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class I18n {
|
||||
// start using current locale but still allow using the dropdown list later
|
||||
private static ResourceBundle i18n;
|
||||
|
||||
// prompt text stuff
|
||||
|
||||
static String PROMPT_YES;
|
||||
static String PROMPT_NO;
|
||||
static String PROMPT_CANCEL;
|
||||
static String PROMPT_OK;
|
||||
static String PROMPT_BROWSE;
|
||||
|
||||
static protected void init(String language) throws MissingResourceException {
|
||||
String[] languageParts = language.split("_");
|
||||
Locale locale = Locale.getDefault();
|
||||
// both language and country
|
||||
if (languageParts.length == 2) {
|
||||
locale = new Locale(languageParts[0], languageParts[1]);
|
||||
// just language
|
||||
} else if (languageParts.length == 1 && !"".equals(languageParts[0])) {
|
||||
locale = new Locale(languageParts[0]);
|
||||
}
|
||||
// there might be a null pointer exception ... most likely will never happen but the jvm gets mad
|
||||
Locale.setDefault(locale);
|
||||
i18n = ResourceBundle.getBundle("processing.app.i18n.Resources", Locale.getDefault());
|
||||
PROMPT_YES = _("Yes");
|
||||
PROMPT_NO = _("No");
|
||||
PROMPT_CANCEL = _("Cancel");
|
||||
PROMPT_OK = _("OK");
|
||||
PROMPT_BROWSE = _("Browse");
|
||||
}
|
||||
|
||||
public static String _(String s) {
|
||||
String res;
|
||||
try {
|
||||
if (i18n == null)
|
||||
res = s;
|
||||
else
|
||||
res = i18n.getString(s);
|
||||
} catch (MissingResourceException e) {
|
||||
res = s;
|
||||
}
|
||||
|
||||
// The single % is the arguments selector in .PO files.
|
||||
// We must put double %% inside the translations to avoid
|
||||
// getting .PO processing in the way.
|
||||
res = res.replace("%%", "%");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public static String format(String fmt, Object... args) {
|
||||
// Single quote is used to escape curly bracket arguments.
|
||||
|
||||
// - Prevents strings fixed at translation time to be fixed again
|
||||
fmt = fmt.replace("''", "'");
|
||||
// - Replace ' with the escaped version ''
|
||||
fmt = fmt.replace("'", "''");
|
||||
|
||||
return MessageFormat.format(fmt, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does nothing.
|
||||
* <p/>
|
||||
* This method is an hack to extract words with gettext tool.
|
||||
*/
|
||||
protected static void unusedStrings() {
|
||||
// These phrases are defined in the "platform.txt".
|
||||
_("Arduino AVR Boards");
|
||||
_("Arduino ARM (32-bits) Boards");
|
||||
|
||||
// This word is defined in the "boards.txt".
|
||||
_("Processor");
|
||||
}
|
||||
}
|
220
arduino-core/src/processing/app/Platform.java
Normal file
220
arduino-core/src/processing/app/Platform.java
Normal file
@ -0,0 +1,220 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2008 Ben Fry and Casey Reas
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
import static processing.app.I18n._;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import processing.app.debug.TargetBoard;
|
||||
import processing.app.debug.TargetPackage;
|
||||
import processing.app.debug.TargetPlatform;
|
||||
import processing.app.legacy.PConstants;
|
||||
|
||||
|
||||
/**
|
||||
* Used by Base for platform-specific tweaking, for instance finding the
|
||||
* sketchbook location using the Windows registry, or OS X event handling.
|
||||
*
|
||||
* The methods in this implementation are used by default, and can be
|
||||
* overridden by a subclass, if loaded by Base.main().
|
||||
*
|
||||
* These methods throw vanilla-flavored Exceptions, so that error handling
|
||||
* occurs inside Base.
|
||||
*
|
||||
* There is currently no mechanism for adding new platforms, as the setup is
|
||||
* not automated. We could use getProperty("os.arch") perhaps, but that's
|
||||
* debatable (could be upper/lowercase, have spaces, etc.. basically we don't
|
||||
* know if name is proper Java package syntax.)
|
||||
*/
|
||||
public class Platform {
|
||||
|
||||
|
||||
/**
|
||||
* Set the default L & F. While I enjoy the bounty of the sixteen possible
|
||||
* exception types that this UIManager method might throw, I feel that in
|
||||
* just this one particular case, I'm being spoiled by those engineers
|
||||
* at Sun, those Masters of the Abstractionverse. It leaves me feeling sad
|
||||
* and overweight. So instead, I'll pretend that I'm not offered eleven dozen
|
||||
* ways to report to the user exactly what went wrong, and I'll bundle them
|
||||
* all into a single catch-all "Exception". Because in the end, all I really
|
||||
* care about is whether things worked or not. And even then, I don't care.
|
||||
*
|
||||
* @throws Exception Just like I said.
|
||||
*/
|
||||
public void setLookAndFeel() throws Exception {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
}
|
||||
|
||||
|
||||
public void init() {
|
||||
}
|
||||
|
||||
|
||||
public File getSettingsFolder() throws Exception {
|
||||
// otherwise make a .processing directory int the user's home dir
|
||||
File home = new File(System.getProperty("user.home"));
|
||||
File dataFolder = new File(home, ".arduino15");
|
||||
return dataFolder;
|
||||
|
||||
/*
|
||||
try {
|
||||
Class clazz = Class.forName("processing.app.macosx.ThinkDifferent");
|
||||
Method m = clazz.getMethod("getLibraryFolder", new Class[] { });
|
||||
String libraryPath = (String) m.invoke(null, new Object[] { });
|
||||
//String libraryPath = BaseMacOS.getLibraryFolder();
|
||||
File libraryFolder = new File(libraryPath);
|
||||
dataFolder = new File(libraryFolder, "Processing");
|
||||
|
||||
} catch (Exception e) {
|
||||
showError("Problem getting data folder",
|
||||
"Error getting the Processing data folder.", e);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return null if not overridden, which will cause a prompt to show instead.
|
||||
* @throws Exception
|
||||
*/
|
||||
public File getDefaultSketchbookFolder() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void openURL(String url) throws Exception {
|
||||
String launcher = PreferencesData.get("launcher");
|
||||
if (launcher != null) {
|
||||
Runtime.getRuntime().exec(new String[] { launcher, url });
|
||||
} else {
|
||||
showLauncherWarning();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean openFolderAvailable() {
|
||||
return PreferencesData.get("launcher") != null;
|
||||
}
|
||||
|
||||
|
||||
public void openFolder(File file) throws Exception {
|
||||
String launcher = PreferencesData.get("launcher");
|
||||
if (launcher != null) {
|
||||
String folder = file.getAbsolutePath();
|
||||
Runtime.getRuntime().exec(new String[] { launcher, folder });
|
||||
} else {
|
||||
showLauncherWarning();
|
||||
}
|
||||
}
|
||||
|
||||
public String resolveDeviceAttachedTo(String serial, Map<String, TargetPackage> packages, String devicesListOutput) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String preListAllCandidateDevices() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String resolveDeviceByVendorIdProductId(Map<String, TargetPackage> packages, String readVIDPID) {
|
||||
for (TargetPackage targetPackage : packages.values()) {
|
||||
for (TargetPlatform targetPlatform : targetPackage.getPlatforms().values()) {
|
||||
for (TargetBoard board : targetPlatform.getBoards().values()) {
|
||||
List<String> vids = new LinkedList<String>(board.getPreferences().subTree("vid").values());
|
||||
if (!vids.isEmpty()) {
|
||||
List<String> pids = new LinkedList<String>(board.getPreferences().subTree("pid").values());
|
||||
for (int i = 0; i< vids.size(); i++) {
|
||||
String vidPid = vids.get(i) + "_" + pids.get(i);
|
||||
if (vidPid.toUpperCase().equals(readVIDPID)) {
|
||||
return board.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String resolveDeviceByBoardID(Map<String, TargetPackage> packages, String boardId) {
|
||||
for (TargetPackage targetPackage : packages.values()) {
|
||||
for (TargetPlatform targetPlatform : targetPackage.getPlatforms().values()) {
|
||||
for (TargetBoard board : targetPlatform.getBoards().values()) {
|
||||
if (boardId.equals(board.getId())) {
|
||||
return board.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
public interface CLibrary extends Library {
|
||||
CLibrary INSTANCE = (CLibrary)Native.loadLibrary("c", CLibrary.class);
|
||||
int setenv(String name, String value, int overwrite);
|
||||
String getenv(String name);
|
||||
int unsetenv(String name);
|
||||
int putenv(String string);
|
||||
}
|
||||
|
||||
|
||||
public void setenv(String variable, String value) {
|
||||
CLibrary clib = CLibrary.INSTANCE;
|
||||
clib.setenv(variable, value, 1);
|
||||
}
|
||||
|
||||
|
||||
public String getenv(String variable) {
|
||||
CLibrary clib = CLibrary.INSTANCE;
|
||||
return clib.getenv(variable);
|
||||
}
|
||||
|
||||
|
||||
public int unsetenv(String variable) {
|
||||
CLibrary clib = CLibrary.INSTANCE;
|
||||
return clib.unsetenv(variable);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return PConstants.platformNames[PConstants.OTHER];
|
||||
}
|
||||
|
||||
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
protected void showLauncherWarning() {
|
||||
BaseNoGui.showWarning(_("No launcher available"),
|
||||
_("Unspecified platform, no launcher available.\nTo enable opening URLs or folders, add a \n\"launcher=/path/to/app\" line to preferences.txt"),
|
||||
null);
|
||||
}
|
||||
}
|
214
arduino-core/src/processing/app/PreferencesData.java
Normal file
214
arduino-core/src/processing/app/PreferencesData.java
Normal file
@ -0,0 +1,214 @@
|
||||
package processing.app;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.MissingResourceException;
|
||||
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
import processing.app.legacy.PApplet;
|
||||
import processing.app.legacy.PConstants;
|
||||
|
||||
|
||||
public class PreferencesData {
|
||||
|
||||
static final String PREFS_FILE = "preferences.txt";
|
||||
|
||||
// data model
|
||||
|
||||
static PreferencesMap defaults;
|
||||
static PreferencesMap prefs = new PreferencesMap();
|
||||
static File preferencesFile;
|
||||
static boolean doSave = true;
|
||||
|
||||
|
||||
static public void init(File file) {
|
||||
if (file != null)
|
||||
preferencesFile = file;
|
||||
else
|
||||
preferencesFile = BaseNoGui.getSettingsFile(PREFS_FILE);
|
||||
|
||||
// start by loading the defaults, in case something
|
||||
// important was deleted from the user prefs
|
||||
try {
|
||||
prefs.load(BaseNoGui.getLibStream("preferences.txt"));
|
||||
} catch (IOException e) {
|
||||
BaseNoGui.showError(null, _("Could not read default settings.\n" +
|
||||
"You'll need to reinstall Arduino."), e);
|
||||
}
|
||||
|
||||
// set some runtime constants (not saved on preferences file)
|
||||
File hardwareFolder = BaseNoGui.getHardwareFolder();
|
||||
prefs.put("runtime.ide.path", hardwareFolder.getParentFile().getAbsolutePath());
|
||||
prefs.put("runtime.ide.version", "" + BaseNoGui.REVISION);
|
||||
|
||||
// clone the hash table
|
||||
defaults = new PreferencesMap(prefs);
|
||||
|
||||
if (preferencesFile.exists()) {
|
||||
// load the previous preferences file
|
||||
try {
|
||||
prefs.load(preferencesFile);
|
||||
} catch (IOException ex) {
|
||||
BaseNoGui.showError(_("Error reading preferences"),
|
||||
I18n.format(_("Error reading the preferences file. "
|
||||
+ "Please delete (or move)\n"
|
||||
+ "{0} and restart Arduino."),
|
||||
preferencesFile.getAbsolutePath()), ex);
|
||||
}
|
||||
}
|
||||
|
||||
// load the I18n module for internationalization
|
||||
try {
|
||||
I18n.init(get("editor.languages.current"));
|
||||
} catch (MissingResourceException e) {
|
||||
I18n.init("en");
|
||||
set("editor.languages.current", "en");
|
||||
}
|
||||
|
||||
// set some other runtime constants (not saved on preferences file)
|
||||
set("runtime.os", PConstants.platformNames[PApplet.platform]);
|
||||
|
||||
fixPreferences();
|
||||
}
|
||||
|
||||
private static void fixPreferences() {
|
||||
String baud = get("serial.debug_rate");
|
||||
if ("14400".equals(baud) || "28800".equals(baud) || "38400".equals(baud)) {
|
||||
set("serial.debug_rate", "9600");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static public String[] loadStrings(InputStream input) {
|
||||
try {
|
||||
BufferedReader reader =
|
||||
new BufferedReader(new InputStreamReader(input, "UTF-8"));
|
||||
|
||||
String lines[] = new String[100];
|
||||
int lineCount = 0;
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (lineCount == lines.length) {
|
||||
String temp[] = new String[lineCount << 1];
|
||||
System.arraycopy(lines, 0, temp, 0, lineCount);
|
||||
lines = temp;
|
||||
}
|
||||
lines[lineCount++] = line;
|
||||
}
|
||||
reader.close();
|
||||
|
||||
if (lineCount == lines.length) {
|
||||
return lines;
|
||||
}
|
||||
|
||||
// resize array to appropriate amount for these lines
|
||||
String output[] = new String[lineCount];
|
||||
System.arraycopy(lines, 0, output, 0, lineCount);
|
||||
return output;
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
//throw new RuntimeException("Error inside loadStrings()");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
static protected void save() {
|
||||
if (!doSave)
|
||||
return;
|
||||
|
||||
// on startup, don't worry about it
|
||||
// this is trying to update the prefs for who is open
|
||||
// before Preferences.init() has been called.
|
||||
if (preferencesFile == null) return;
|
||||
|
||||
// Fix for 0163 to properly use Unicode when writing preferences.txt
|
||||
PrintWriter writer = PApplet.createWriter(preferencesFile);
|
||||
|
||||
String[] keys = prefs.keySet().toArray(new String[0]);
|
||||
Arrays.sort(keys);
|
||||
for (String key: keys) {
|
||||
if (key.startsWith("runtime."))
|
||||
continue;
|
||||
writer.println(key + "=" + prefs.get(key));
|
||||
}
|
||||
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
|
||||
|
||||
// .................................................................
|
||||
|
||||
static public String get(String attribute) {
|
||||
return prefs.get(attribute);
|
||||
}
|
||||
|
||||
static public String get(String attribute, String defaultValue) {
|
||||
String value = get(attribute);
|
||||
return (value == null) ? defaultValue : value;
|
||||
}
|
||||
|
||||
public static boolean has(String key) {
|
||||
return prefs.containsKey(key);
|
||||
}
|
||||
|
||||
public static void remove(String key) {
|
||||
prefs.remove(key);
|
||||
}
|
||||
|
||||
static public String getDefault(String attribute) {
|
||||
return defaults.get(attribute);
|
||||
}
|
||||
|
||||
|
||||
static public void set(String attribute, String value) {
|
||||
prefs.put(attribute, value);
|
||||
}
|
||||
|
||||
|
||||
static public void unset(String attribute) {
|
||||
prefs.remove(attribute);
|
||||
}
|
||||
|
||||
|
||||
static public boolean getBoolean(String attribute) {
|
||||
return prefs.getBoolean(attribute);
|
||||
}
|
||||
|
||||
|
||||
static public void setBoolean(String attribute, boolean value) {
|
||||
prefs.putBoolean(attribute, value);
|
||||
}
|
||||
|
||||
|
||||
static public int getInteger(String attribute) {
|
||||
return Integer.parseInt(get(attribute));
|
||||
}
|
||||
|
||||
|
||||
static public void setInteger(String key, int value) {
|
||||
set(key, String.valueOf(value));
|
||||
}
|
||||
|
||||
// get a copy of the Preferences
|
||||
static public PreferencesMap getMap()
|
||||
{
|
||||
return new PreferencesMap(prefs);
|
||||
}
|
||||
|
||||
// Decide wether changed preferences will be saved. When value is
|
||||
// false, Preferences.save becomes a no-op.
|
||||
static public void setDoSave(boolean value)
|
||||
{
|
||||
doSave = value;
|
||||
}
|
||||
}
|
544
arduino-core/src/processing/app/Serial.java
Normal file
544
arduino-core/src/processing/app/Serial.java
Normal file
@ -0,0 +1,544 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
PSerial - class for serial port goodness
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2004 Ben Fry & Casey Reas
|
||||
|
||||
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., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import jssc.SerialPort;
|
||||
import jssc.SerialPortEvent;
|
||||
import jssc.SerialPortEventListener;
|
||||
import jssc.SerialPortException;
|
||||
import processing.app.debug.MessageConsumer;
|
||||
|
||||
|
||||
public class Serial implements SerialPortEventListener {
|
||||
|
||||
//PApplet parent;
|
||||
|
||||
// properties can be passed in for default values
|
||||
// otherwise defaults to 9600 N81
|
||||
|
||||
// these could be made static, which might be a solution
|
||||
// for the classloading problem.. because if code ran again,
|
||||
// the static class would have an object that could be closed
|
||||
|
||||
SerialPort port;
|
||||
|
||||
int rate;
|
||||
int parity;
|
||||
int databits;
|
||||
int stopbits;
|
||||
boolean monitor = false;
|
||||
|
||||
byte buffer[] = new byte[32768];
|
||||
int bufferIndex;
|
||||
int bufferLast;
|
||||
|
||||
MessageConsumer consumer;
|
||||
|
||||
public Serial(boolean monitor) throws SerialException {
|
||||
this(PreferencesData.get("serial.port"),
|
||||
PreferencesData.getInteger("serial.debug_rate"),
|
||||
PreferencesData.get("serial.parity").charAt(0),
|
||||
PreferencesData.getInteger("serial.databits"),
|
||||
new Float(PreferencesData.get("serial.stopbits")).floatValue());
|
||||
this.monitor = monitor;
|
||||
}
|
||||
|
||||
public Serial() throws SerialException {
|
||||
this(PreferencesData.get("serial.port"),
|
||||
PreferencesData.getInteger("serial.debug_rate"),
|
||||
PreferencesData.get("serial.parity").charAt(0),
|
||||
PreferencesData.getInteger("serial.databits"),
|
||||
new Float(PreferencesData.get("serial.stopbits")).floatValue());
|
||||
}
|
||||
|
||||
public Serial(int irate) throws SerialException {
|
||||
this(PreferencesData.get("serial.port"), irate,
|
||||
PreferencesData.get("serial.parity").charAt(0),
|
||||
PreferencesData.getInteger("serial.databits"),
|
||||
new Float(PreferencesData.get("serial.stopbits")).floatValue());
|
||||
}
|
||||
|
||||
public Serial(String iname, int irate) throws SerialException {
|
||||
this(iname, irate, PreferencesData.get("serial.parity").charAt(0),
|
||||
PreferencesData.getInteger("serial.databits"),
|
||||
new Float(PreferencesData.get("serial.stopbits")).floatValue());
|
||||
}
|
||||
|
||||
public Serial(String iname) throws SerialException {
|
||||
this(iname, PreferencesData.getInteger("serial.debug_rate"),
|
||||
PreferencesData.get("serial.parity").charAt(0),
|
||||
PreferencesData.getInteger("serial.databits"),
|
||||
new Float(PreferencesData.get("serial.stopbits")).floatValue());
|
||||
}
|
||||
|
||||
public static boolean touchPort(String iname, int irate) throws SerialException {
|
||||
SerialPort serialPort = new SerialPort(iname);
|
||||
try {
|
||||
serialPort.openPort();
|
||||
serialPort.setParams(irate, 8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
|
||||
serialPort.closePort();
|
||||
return true;
|
||||
} catch (SerialPortException e) {
|
||||
throw new SerialException(I18n.format(_("Error touching serial port ''{0}''."), iname), e);
|
||||
} finally {
|
||||
if (serialPort.isOpened()) {
|
||||
try {
|
||||
serialPort.closePort();
|
||||
} catch (SerialPortException e) {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Serial(String iname, int irate, char iparity, int idatabits, float istopbits) throws SerialException {
|
||||
//if (port != null) port.close();
|
||||
//this.parent = parent;
|
||||
//parent.attach(this);
|
||||
|
||||
this.rate = irate;
|
||||
|
||||
parity = SerialPort.PARITY_NONE;
|
||||
if (iparity == 'E') parity = SerialPort.PARITY_EVEN;
|
||||
if (iparity == 'O') parity = SerialPort.PARITY_ODD;
|
||||
|
||||
this.databits = idatabits;
|
||||
|
||||
stopbits = SerialPort.STOPBITS_1;
|
||||
if (istopbits == 1.5f) stopbits = SerialPort.STOPBITS_1_5;
|
||||
if (istopbits == 2) stopbits = SerialPort.STOPBITS_2;
|
||||
|
||||
try {
|
||||
port = new SerialPort(iname);
|
||||
port.openPort();
|
||||
port.setParams(rate, databits, stopbits, parity, true, true);
|
||||
port.addEventListener(this);
|
||||
} catch (Exception e) {
|
||||
throw new SerialException(I18n.format(_("Error opening serial port ''{0}''."), iname), e);
|
||||
}
|
||||
|
||||
if (port == null) {
|
||||
throw new SerialNotFoundException(I18n.format(_("Serial port ''{0}'' not found. Did you select the right one from the Tools > Serial Port menu?"), iname));
|
||||
}
|
||||
}
|
||||
|
||||
public void setup() {
|
||||
//parent.registerCall(this, DISPOSE);
|
||||
}
|
||||
|
||||
public void dispose() throws IOException {
|
||||
if (port != null) {
|
||||
try {
|
||||
if (port.isOpened()) {
|
||||
port.closePort(); // close the port
|
||||
}
|
||||
} catch (SerialPortException e) {
|
||||
throw new IOException(e);
|
||||
} finally {
|
||||
port = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addListener(MessageConsumer consumer) {
|
||||
this.consumer = consumer;
|
||||
}
|
||||
|
||||
public synchronized void serialEvent(SerialPortEvent serialEvent) {
|
||||
if (serialEvent.isRXCHAR()) {
|
||||
try {
|
||||
byte[] buf = port.readBytes(serialEvent.getEventValue());
|
||||
if (buf.length > 0) {
|
||||
if (bufferLast == buffer.length) {
|
||||
byte temp[] = new byte[bufferLast << 1];
|
||||
System.arraycopy(buffer, 0, temp, 0, bufferLast);
|
||||
buffer = temp;
|
||||
}
|
||||
if (monitor) {
|
||||
System.out.print(new String(buf));
|
||||
}
|
||||
if (this.consumer != null) {
|
||||
this.consumer.message(new String(buf));
|
||||
}
|
||||
}
|
||||
} catch (SerialPortException e) {
|
||||
errorMessage("serialEvent", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of bytes that have been read from serial
|
||||
* and are waiting to be dealt with by the user.
|
||||
*/
|
||||
public synchronized int available() {
|
||||
return (bufferLast - bufferIndex);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ignore all the bytes read so far and empty the buffer.
|
||||
*/
|
||||
public synchronized void clear() {
|
||||
bufferLast = 0;
|
||||
bufferIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a number between 0 and 255 for the next byte that's
|
||||
* waiting in the buffer.
|
||||
* Returns -1 if there was no byte (although the user should
|
||||
* first check available() to see if things are ready to avoid this)
|
||||
*/
|
||||
public synchronized int read() {
|
||||
if (bufferIndex == bufferLast) return -1;
|
||||
|
||||
int outgoing = buffer[bufferIndex++] & 0xff;
|
||||
if (bufferIndex == bufferLast) { // rewind
|
||||
bufferIndex = 0;
|
||||
bufferLast = 0;
|
||||
}
|
||||
return outgoing;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the next byte in the buffer as a char.
|
||||
* Returns -1, or 0xffff, if nothing is there.
|
||||
*/
|
||||
public synchronized char readChar() {
|
||||
if (bufferIndex == bufferLast) return (char) (-1);
|
||||
return (char) read();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a byte array of anything that's in the serial buffer.
|
||||
* Not particularly memory/speed efficient, because it creates
|
||||
* a byte array on each read, but it's easier to use than
|
||||
* readBytes(byte b[]) (see below).
|
||||
*/
|
||||
public synchronized byte[] readBytes() {
|
||||
if (bufferIndex == bufferLast) return null;
|
||||
|
||||
int length = bufferLast - bufferIndex;
|
||||
byte outgoing[] = new byte[length];
|
||||
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
|
||||
|
||||
bufferIndex = 0; // rewind
|
||||
bufferLast = 0;
|
||||
return outgoing;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Grab whatever is in the serial buffer, and stuff it into a
|
||||
* byte buffer passed in by the user. This is more memory/time
|
||||
* efficient than readBytes() returning a byte[] array.
|
||||
* <p/>
|
||||
* Returns an int for how many bytes were read. If more bytes
|
||||
* are available than can fit into the byte array, only those
|
||||
* that will fit are read.
|
||||
*/
|
||||
public synchronized int readBytes(byte outgoing[]) {
|
||||
if (bufferIndex == bufferLast) return 0;
|
||||
|
||||
int length = bufferLast - bufferIndex;
|
||||
if (length > outgoing.length) length = outgoing.length;
|
||||
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
|
||||
|
||||
bufferIndex += length;
|
||||
if (bufferIndex == bufferLast) {
|
||||
bufferIndex = 0; // rewind
|
||||
bufferLast = 0;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads from the serial port into a buffer of bytes up to and
|
||||
* including a particular character. If the character isn't in
|
||||
* the serial buffer, then 'null' is returned.
|
||||
*/
|
||||
public synchronized byte[] readBytesUntil(int interesting) {
|
||||
if (bufferIndex == bufferLast) return null;
|
||||
byte what = (byte) interesting;
|
||||
|
||||
int found = -1;
|
||||
for (int k = bufferIndex; k < bufferLast; k++) {
|
||||
if (buffer[k] == what) {
|
||||
found = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == -1) return null;
|
||||
|
||||
int length = found - bufferIndex + 1;
|
||||
byte outgoing[] = new byte[length];
|
||||
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
|
||||
|
||||
bufferIndex = 0; // rewind
|
||||
bufferLast = 0;
|
||||
return outgoing;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads from the serial port into a buffer of bytes until a
|
||||
* particular character. If the character isn't in the serial
|
||||
* buffer, then 'null' is returned.
|
||||
* <p/>
|
||||
* If outgoing[] is not big enough, then -1 is returned,
|
||||
* and an error message is printed on the console.
|
||||
* If nothing is in the buffer, zero is returned.
|
||||
* If 'interesting' byte is not in the buffer, then 0 is returned.
|
||||
*/
|
||||
public synchronized int readBytesUntil(int interesting, byte outgoing[]) {
|
||||
if (bufferIndex == bufferLast) return 0;
|
||||
byte what = (byte) interesting;
|
||||
|
||||
int found = -1;
|
||||
for (int k = bufferIndex; k < bufferLast; k++) {
|
||||
if (buffer[k] == what) {
|
||||
found = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == -1) return 0;
|
||||
|
||||
int length = found - bufferIndex + 1;
|
||||
if (length > outgoing.length) {
|
||||
System.err.println(
|
||||
I18n.format(
|
||||
_("readBytesUntil() byte buffer is too small for the {0}" +
|
||||
" bytes up to and including char {1}"),
|
||||
length,
|
||||
interesting
|
||||
)
|
||||
);
|
||||
return -1;
|
||||
}
|
||||
//byte outgoing[] = new byte[length];
|
||||
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
|
||||
|
||||
bufferIndex += length;
|
||||
if (bufferIndex == bufferLast) {
|
||||
bufferIndex = 0; // rewind
|
||||
bufferLast = 0;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return whatever has been read from the serial port so far
|
||||
* as a String. It assumes that the incoming characters are ASCII.
|
||||
* <p/>
|
||||
* If you want to move Unicode data, you can first convert the
|
||||
* String to a byte stream in the representation of your choice
|
||||
* (i.e. UTF8 or two-byte Unicode data), and send it as a byte array.
|
||||
*/
|
||||
public synchronized String readString() {
|
||||
if (bufferIndex == bufferLast) return null;
|
||||
return new String(readBytes());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Combination of readBytesUntil and readString. See caveats in
|
||||
* each function. Returns null if it still hasn't found what
|
||||
* you're looking for.
|
||||
* <p/>
|
||||
* If you want to move Unicode data, you can first convert the
|
||||
* String to a byte stream in the representation of your choice
|
||||
* (i.e. UTF8 or two-byte Unicode data), and send it as a byte array.
|
||||
*/
|
||||
public synchronized String readStringUntil(int interesting) {
|
||||
byte b[] = readBytesUntil(interesting);
|
||||
if (b == null) return null;
|
||||
return new String(b);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This will handle both ints, bytes and chars transparently.
|
||||
*/
|
||||
public void write(int what) { // will also cover char
|
||||
try {
|
||||
port.writeInt(what & 0xff);
|
||||
} catch (SerialPortException e) {
|
||||
errorMessage("write", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void write(byte bytes[]) {
|
||||
try {
|
||||
port.writeBytes(bytes);
|
||||
} catch (SerialPortException e) {
|
||||
errorMessage("write", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write a String to the output. Note that this doesn't account
|
||||
* for Unicode (two bytes per char), nor will it send UTF8
|
||||
* characters.. It assumes that you mean to send a byte buffer
|
||||
* (most often the case for networking and serial i/o) and
|
||||
* will only use the bottom 8 bits of each char in the string.
|
||||
* (Meaning that internally it uses String.getBytes)
|
||||
* <p/>
|
||||
* If you want to move Unicode data, you can first convert the
|
||||
* String to a byte stream in the representation of your choice
|
||||
* (i.e. UTF8 or two-byte Unicode data), and send it as a byte array.
|
||||
*/
|
||||
public void write(String what) {
|
||||
write(what.getBytes());
|
||||
}
|
||||
|
||||
public void setDTR(boolean state) {
|
||||
try {
|
||||
port.setDTR(state);
|
||||
} catch (SerialPortException e) {
|
||||
errorMessage("setDTR", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRTS(boolean state) {
|
||||
try {
|
||||
port.setRTS(state);
|
||||
} catch (SerialPortException e) {
|
||||
errorMessage("setRTS", e);
|
||||
}
|
||||
}
|
||||
|
||||
static public List<String> list() {
|
||||
return Arrays.asList(SerialPortList.getPortNames());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* General error reporting, all corraled here just in case
|
||||
* I think of something slightly more intelligent to do.
|
||||
*/
|
||||
static public void errorMessage(String where, Throwable e) {
|
||||
System.err.println(I18n.format(_("Error inside Serial.{0}()"), where));
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
class SerialMenuListener implements ItemListener {
|
||||
//public SerialMenuListener() { }
|
||||
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
int count = serialMenu.getItemCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
((CheckboxMenuItem)serialMenu.getItem(i)).setState(false);
|
||||
}
|
||||
CheckboxMenuItem item = (CheckboxMenuItem)e.getSource();
|
||||
item.setState(true);
|
||||
String name = item.getLabel();
|
||||
//System.out.println(item.getLabel());
|
||||
PdeBase.properties.put("serial.port", name);
|
||||
//System.out.println("set to " + get("serial.port"));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
protected Vector buildPortList() {
|
||||
// get list of names for serial ports
|
||||
// have the default port checked (if present)
|
||||
Vector list = new Vector();
|
||||
|
||||
//SerialMenuListener listener = new SerialMenuListener();
|
||||
boolean problem = false;
|
||||
|
||||
// if this is failing, it may be because
|
||||
// lib/javax.comm.properties is missing.
|
||||
// java is weird about how it searches for java.comm.properties
|
||||
// so it tends to be very fragile. i.e. quotes in the CLASSPATH
|
||||
// environment variable will hose things.
|
||||
try {
|
||||
//System.out.println("building port list");
|
||||
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
|
||||
while (portList.hasMoreElements()) {
|
||||
CommPortIdentifier portId =
|
||||
(CommPortIdentifier) portList.nextElement();
|
||||
//System.out.println(portId);
|
||||
|
||||
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
|
||||
//if (portId.getName().equals(port)) {
|
||||
String name = portId.getName();
|
||||
//CheckboxMenuItem mi =
|
||||
//new CheckboxMenuItem(name, name.equals(defaultName));
|
||||
|
||||
//mi.addItemListener(listener);
|
||||
//serialMenu.add(mi);
|
||||
list.addElement(name);
|
||||
}
|
||||
}
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
e.printStackTrace();
|
||||
problem = true;
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("exception building serial menu");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//if (serialMenu.getItemCount() == 0) {
|
||||
//System.out.println("dimming serial menu");
|
||||
//serialMenu.setEnabled(false);
|
||||
//}
|
||||
|
||||
// only warn them if this is the first time
|
||||
if (problem && PdeBase.firstTime) {
|
||||
JOptionPane.showMessageDialog(this, //frame,
|
||||
"Serial port support not installed.\n" +
|
||||
"Check the readme for instructions\n" +
|
||||
"if you need to use the serial port. ",
|
||||
"Serial Port Warning",
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
42
arduino-core/src/processing/app/SerialException.java
Normal file
42
arduino-core/src/processing/app/SerialException.java
Normal file
@ -0,0 +1,42 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Copyright (c) 2007 David A. Mellis
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class SerialException extends IOException {
|
||||
public SerialException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SerialException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public SerialException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public SerialException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
38
arduino-core/src/processing/app/SerialNotFoundException.java
Normal file
38
arduino-core/src/processing/app/SerialNotFoundException.java
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright (c) 2007 David A. Mellis
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class SerialNotFoundException extends SerialException {
|
||||
public SerialNotFoundException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SerialNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public SerialNotFoundException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public SerialNotFoundException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
355
arduino-core/src/processing/app/SerialPortList.java
Normal file
355
arduino-core/src/processing/app/SerialPortList.java
Normal file
@ -0,0 +1,355 @@
|
||||
/* jSSC (Java Simple Serial Connector) - serial port communication library.
|
||||
* (C) Alexey Sokolov (scream3r), 2010-2014.
|
||||
*
|
||||
* Patched for Arduino by Cristian Maglie.
|
||||
*
|
||||
* This file is part of jSSC.
|
||||
*
|
||||
* jSSC 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* jSSC 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 jSSC. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* If you use jSSC in public project you can inform me about this by e-mail,
|
||||
* of course if you want it.
|
||||
*
|
||||
* e-mail: scream3r.org@gmail.com
|
||||
* web-site: http://scream3r.org | http://code.google.com/p/java-simple-serial-connector/
|
||||
*/
|
||||
package processing.app;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Comparator;
|
||||
import java.util.TreeSet;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import jssc.SerialNativeInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author scream3r
|
||||
*/
|
||||
public class SerialPortList {
|
||||
|
||||
private static SerialNativeInterface serialInterface;
|
||||
private static final Pattern PORTNAMES_REGEXP;
|
||||
private static final String PORTNAMES_PATH;
|
||||
|
||||
static {
|
||||
serialInterface = new SerialNativeInterface();
|
||||
switch (SerialNativeInterface.getOsType()) {
|
||||
case SerialNativeInterface.OS_LINUX: {
|
||||
PORTNAMES_REGEXP = Pattern.compile("(ttyS|ttyUSB|ttyACM|ttyAMA|rfcomm|ttyO)[0-9]{1,3}");
|
||||
PORTNAMES_PATH = "/dev/";
|
||||
break;
|
||||
}
|
||||
case SerialNativeInterface.OS_SOLARIS: {
|
||||
PORTNAMES_REGEXP = Pattern.compile("[0-9]*|[a-z]*");
|
||||
PORTNAMES_PATH = "/dev/term/";
|
||||
break;
|
||||
}
|
||||
case SerialNativeInterface.OS_MAC_OS_X: {
|
||||
PORTNAMES_REGEXP = Pattern.compile("(tty|cu)\\..*");
|
||||
PORTNAMES_PATH = "/dev/";
|
||||
break;
|
||||
}
|
||||
case SerialNativeInterface.OS_WINDOWS: {
|
||||
PORTNAMES_REGEXP = Pattern.compile("");
|
||||
PORTNAMES_PATH = "";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
PORTNAMES_REGEXP = null;
|
||||
PORTNAMES_PATH = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//since 2.1.0 -> Fully rewrited port name comparator
|
||||
private static final Comparator<String> PORTNAMES_COMPARATOR = new Comparator<String>() {
|
||||
|
||||
@Override
|
||||
public int compare(String valueA, String valueB) {
|
||||
|
||||
if(valueA.equalsIgnoreCase(valueB)){
|
||||
return valueA.compareTo(valueB);
|
||||
}
|
||||
|
||||
int minLength = Math.min(valueA.length(), valueB.length());
|
||||
|
||||
int shiftA = 0;
|
||||
int shiftB = 0;
|
||||
|
||||
for(int i = 0; i < minLength; i++){
|
||||
char charA = valueA.charAt(i - shiftA);
|
||||
char charB = valueB.charAt(i - shiftB);
|
||||
if(charA != charB){
|
||||
if(Character.isDigit(charA) && Character.isDigit(charB)){
|
||||
int[] resultsA = getNumberAndLastIndex(valueA, i - shiftA);
|
||||
int[] resultsB = getNumberAndLastIndex(valueB, i - shiftB);
|
||||
|
||||
if(resultsA[0] != resultsB[0]){
|
||||
return resultsA[0] - resultsB[0];
|
||||
}
|
||||
|
||||
if(valueA.length() < valueB.length()){
|
||||
i = resultsA[1];
|
||||
shiftB = resultsA[1] - resultsB[1];
|
||||
}
|
||||
else {
|
||||
i = resultsB[1];
|
||||
shiftA = resultsB[1] - resultsA[1];
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(Character.toLowerCase(charA) - Character.toLowerCase(charB) != 0){
|
||||
return Character.toLowerCase(charA) - Character.toLowerCase(charB);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return valueA.compareToIgnoreCase(valueB);
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate port <b>index/number</b> from <b>startIndex</b> to the number end. For example:
|
||||
* for port name <b>serial-123-FF</b> you should invoke this method with <b>startIndex = 7</b>
|
||||
*
|
||||
* @return If port <b>index/number</b> correctly evaluated it value will be returned<br>
|
||||
* <b>returnArray[0] = index/number</b><br>
|
||||
* <b>returnArray[1] = stopIndex</b><br>
|
||||
*
|
||||
* If incorrect:<br>
|
||||
* <b>returnArray[0] = -1</b><br>
|
||||
* <b>returnArray[1] = startIndex</b><br>
|
||||
*
|
||||
* For this name <b>serial-123-FF</b> result is:
|
||||
* <b>returnArray[0] = 123</b><br>
|
||||
* <b>returnArray[1] = 10</b><br>
|
||||
*/
|
||||
private int[] getNumberAndLastIndex(String str, int startIndex) {
|
||||
String numberValue = "";
|
||||
int[] returnValues = {-1, startIndex};
|
||||
for(int i = startIndex; i < str.length(); i++){
|
||||
returnValues[1] = i;
|
||||
char c = str.charAt(i);
|
||||
if(Character.isDigit(c)){
|
||||
numberValue += c;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
returnValues[0] = Integer.valueOf(numberValue);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
//Do nothing
|
||||
}
|
||||
return returnValues;
|
||||
}
|
||||
};
|
||||
//<-since 2.1.0
|
||||
|
||||
/**
|
||||
* Get sorted array of serial ports in the system using default settings:<br>
|
||||
*
|
||||
* <b>Search path</b><br>
|
||||
* Windows - ""(always ignored)<br>
|
||||
* Linux - "/dev/"<br>
|
||||
* Solaris - "/dev/term/"<br>
|
||||
* MacOSX - "/dev/"<br>
|
||||
*
|
||||
* <b>RegExp</b><br>
|
||||
* Windows - ""<br>
|
||||
* Linux - "(ttyS|ttyUSB|ttyACM|ttyAMA|rfcomm)[0-9]{1,3}"<br>
|
||||
* Solaris - "[0-9]*|[a-z]*"<br>
|
||||
* MacOSX - "tty.(serial|usbserial|usbmodem).*"<br>
|
||||
*
|
||||
* @return String array. If there is no ports in the system String[]
|
||||
* with <b>zero</b> length will be returned (since jSSC-0.8 in previous versions null will be returned)
|
||||
*/
|
||||
public static String[] getPortNames() {
|
||||
return getPortNames(PORTNAMES_PATH, PORTNAMES_REGEXP, PORTNAMES_COMPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sorted array of serial ports in the system located on searchPath
|
||||
*
|
||||
* @param searchPath Path for searching serial ports <b>(not null)</b><br>
|
||||
* The default search paths:<br>
|
||||
* Linux, MacOSX: <b>/dev/</b><br>
|
||||
* Solaris: <b>/dev/term/</b><br>
|
||||
* Windows: <b>this parameter ingored</b>
|
||||
*
|
||||
* @return String array. If there is no ports in the system String[]
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public static String[] getPortNames(String searchPath) {
|
||||
return getPortNames(searchPath, PORTNAMES_REGEXP, PORTNAMES_COMPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sorted array of serial ports in the system matched pattern
|
||||
*
|
||||
* @param pattern RegExp pattern for matching port names <b>(not null)</b>
|
||||
*
|
||||
* @return String array. If there is no ports in the system String[]
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public static String[] getPortNames(Pattern pattern) {
|
||||
return getPortNames(PORTNAMES_PATH, pattern, PORTNAMES_COMPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sorted array of serial ports in the system matched pattern
|
||||
*
|
||||
* @param comparator Comparator for sotring port names <b>(not null)</b>
|
||||
*
|
||||
* @return String array. If there is no ports in the system String[]
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public static String[] getPortNames(Comparator<String> comparator) {
|
||||
return getPortNames(PORTNAMES_PATH, PORTNAMES_REGEXP, comparator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sorted array of serial ports in the system located on searchPath, matched pattern
|
||||
*
|
||||
* @param searchPath Path for searching serial ports <b>(not null)</b><br>
|
||||
* The default search paths:<br>
|
||||
* Linux, MacOSX: <b>/dev/</b><br>
|
||||
* Solaris: <b>/dev/term/</b><br>
|
||||
* Windows: <b>this parameter ingored</b>
|
||||
* @param pattern RegExp pattern for matching port names <b>(not null)</b>
|
||||
*
|
||||
* @return String array. If there is no ports in the system String[]
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public static String[] getPortNames(String searchPath, Pattern pattern) {
|
||||
return getPortNames(searchPath, pattern, PORTNAMES_COMPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sorted array of serial ports in the system located on searchPath and sorted by comparator
|
||||
*
|
||||
* @param searchPath Path for searching serial ports <b>(not null)</b><br>
|
||||
* The default search paths:<br>
|
||||
* Linux, MacOSX: <b>/dev/</b><br>
|
||||
* Solaris: <b>/dev/term/</b><br>
|
||||
* Windows: <b>this parameter ingored</b>
|
||||
* @param comparator Comparator for sotring port names <b>(not null)</b>
|
||||
*
|
||||
* @return String array. If there is no ports in the system String[]
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public static String[] getPortNames(String searchPath, Comparator<String> comparator) {
|
||||
return getPortNames(searchPath, PORTNAMES_REGEXP, comparator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sorted array of serial ports in the system matched pattern and sorted by comparator
|
||||
*
|
||||
* @param pattern RegExp pattern for matching port names <b>(not null)</b>
|
||||
* @param comparator Comparator for sotring port names <b>(not null)</b>
|
||||
*
|
||||
* @return String array. If there is no ports in the system String[]
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public static String[] getPortNames(Pattern pattern, Comparator<String> comparator) {
|
||||
return getPortNames(PORTNAMES_PATH, pattern, comparator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sorted array of serial ports in the system located on searchPath, matched pattern and sorted by comparator
|
||||
*
|
||||
* @param searchPath Path for searching serial ports <b>(not null)</b><br>
|
||||
* The default search paths:<br>
|
||||
* Linux, MacOSX: <b>/dev/</b><br>
|
||||
* Solaris: <b>/dev/term/</b><br>
|
||||
* Windows: <b>this parameter ingored</b>
|
||||
* @param pattern RegExp pattern for matching port names <b>(not null)</b>
|
||||
* @param comparator Comparator for sotring port names <b>(not null)</b>
|
||||
*
|
||||
* @return String array. If there is no ports in the system String[]
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public static String[] getPortNames(String searchPath, Pattern pattern, Comparator<String> comparator) {
|
||||
if(searchPath == null || pattern == null || comparator == null){
|
||||
return new String[]{};
|
||||
}
|
||||
if(SerialNativeInterface.getOsType() == SerialNativeInterface.OS_WINDOWS){
|
||||
return getWindowsPortNames(pattern, comparator);
|
||||
}
|
||||
return getUnixBasedPortNames(searchPath, pattern, comparator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get serial port names in Windows
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
private static String[] getWindowsPortNames(Pattern pattern, Comparator<String> comparator) {
|
||||
String[] portNames = serialInterface.getSerialPortNames();
|
||||
if(portNames == null){
|
||||
return new String[]{};
|
||||
}
|
||||
TreeSet<String> ports = new TreeSet<String>(comparator);
|
||||
for(String portName : portNames){
|
||||
if(pattern.matcher(portName).find()){
|
||||
ports.add(portName);
|
||||
}
|
||||
}
|
||||
return ports.toArray(new String[ports.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Universal method for getting port names of _nix based systems
|
||||
*/
|
||||
private static String[] getUnixBasedPortNames(String searchPath, Pattern pattern, Comparator<String> comparator) {
|
||||
searchPath = (searchPath.equals("") ? searchPath : (searchPath.endsWith("/") ? searchPath : searchPath + "/"));
|
||||
String[] returnArray = new String[]{};
|
||||
File dir = new File(searchPath);
|
||||
if(dir.exists() && dir.isDirectory()){
|
||||
File[] files = dir.listFiles();
|
||||
if(files.length > 0){
|
||||
TreeSet<String> portsTree = new TreeSet<String>(comparator);
|
||||
for(File file : files){
|
||||
String fileName = file.getName();
|
||||
if(!file.isDirectory() && !file.isFile() && pattern.matcher(fileName).find()){
|
||||
String portName = searchPath + fileName;
|
||||
// For linux ttyS0..31 serial ports check existence by opening each of them
|
||||
if (fileName.startsWith("ttyS")) {
|
||||
long portHandle = serialInterface.openPort(portName, false);//Open port without TIOCEXCL
|
||||
if(portHandle < 0 && portHandle != SerialNativeInterface.ERR_PORT_BUSY){
|
||||
continue;
|
||||
}
|
||||
else if(portHandle != SerialNativeInterface.ERR_PORT_BUSY) {
|
||||
serialInterface.closePort(portHandle);
|
||||
}
|
||||
}
|
||||
portsTree.add(portName);
|
||||
}
|
||||
}
|
||||
returnArray = portsTree.toArray(returnArray);
|
||||
}
|
||||
}
|
||||
return returnArray;
|
||||
}
|
||||
}
|
246
arduino-core/src/processing/app/SketchCode.java
Normal file
246
arduino-core/src/processing/app/SketchCode.java
Normal file
@ -0,0 +1,246 @@
|
||||
/*
|
||||
SketchCode - data class for a single file inside a sketch
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2004-08 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import processing.app.helpers.FileUtils;
|
||||
|
||||
/**
|
||||
* Represents a single tab of a sketch.
|
||||
*/
|
||||
public class SketchCode {
|
||||
|
||||
/** Pretty name (no extension), not the full file name */
|
||||
private String prettyName;
|
||||
|
||||
/** File object for where this code is located */
|
||||
private File file;
|
||||
|
||||
/** Text of the program text for this tab */
|
||||
private String program;
|
||||
|
||||
private boolean modified;
|
||||
|
||||
/** where this code starts relative to the concat'd code */
|
||||
private int preprocOffset;
|
||||
|
||||
private Object metadata;
|
||||
|
||||
public SketchCode(File file) {
|
||||
init(file, null);
|
||||
}
|
||||
|
||||
public SketchCode(File file, Object metadata) {
|
||||
init(file, metadata);
|
||||
}
|
||||
|
||||
private void init(File file, Object metadata) {
|
||||
this.file = file;
|
||||
this.metadata = metadata;
|
||||
|
||||
makePrettyName();
|
||||
|
||||
try {
|
||||
load();
|
||||
} catch (IOException e) {
|
||||
System.err.println(
|
||||
I18n.format(_("Error while loading code {0}"), file.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void makePrettyName() {
|
||||
prettyName = file.getName();
|
||||
int dot = prettyName.lastIndexOf('.');
|
||||
prettyName = prettyName.substring(0, dot);
|
||||
}
|
||||
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
protected boolean fileExists() {
|
||||
return file.exists();
|
||||
}
|
||||
|
||||
|
||||
protected boolean fileReadOnly() {
|
||||
return !file.canWrite();
|
||||
}
|
||||
|
||||
|
||||
protected boolean deleteFile(File tempBuildFolder) {
|
||||
if (!file.delete()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
File[] compiledFiles = tempBuildFolder.listFiles(new FileFilter() {
|
||||
public boolean accept(File pathname) {
|
||||
return pathname.getName().startsWith(getFileName());
|
||||
}
|
||||
});
|
||||
for (File compiledFile : compiledFiles) {
|
||||
compiledFile.delete();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected boolean renameTo(File what) {
|
||||
boolean success = file.renameTo(what);
|
||||
if (success) {
|
||||
file = what;
|
||||
makePrettyName();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
protected void copyTo(File dest) throws IOException {
|
||||
BaseNoGui.saveFile(program, dest);
|
||||
}
|
||||
|
||||
|
||||
public String getFileName() {
|
||||
return file.getName();
|
||||
}
|
||||
|
||||
|
||||
public String getPrettyName() {
|
||||
return prettyName;
|
||||
}
|
||||
|
||||
|
||||
public boolean isExtension(String... extensions) {
|
||||
return isExtension(Arrays.asList(extensions));
|
||||
}
|
||||
|
||||
public boolean isExtension(List<String> extensions) {
|
||||
return FileUtils.hasExtension(file, extensions);
|
||||
}
|
||||
|
||||
|
||||
public String getProgram() {
|
||||
return program;
|
||||
}
|
||||
|
||||
|
||||
public void setProgram(String replacement) {
|
||||
program = replacement;
|
||||
}
|
||||
|
||||
|
||||
public int getLineCount() {
|
||||
return BaseNoGui.countLines(program);
|
||||
}
|
||||
|
||||
|
||||
public void setModified(boolean modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
|
||||
|
||||
public boolean isModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
public void setPreprocOffset(int preprocOffset) {
|
||||
this.preprocOffset = preprocOffset;
|
||||
}
|
||||
|
||||
|
||||
public int getPreprocOffset() {
|
||||
return preprocOffset;
|
||||
}
|
||||
|
||||
|
||||
public void addPreprocOffset(int extra) {
|
||||
preprocOffset += extra;
|
||||
}
|
||||
|
||||
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
/**
|
||||
* Load this piece of code from a file.
|
||||
*/
|
||||
public void load() throws IOException {
|
||||
program = BaseNoGui.loadFile(file);
|
||||
|
||||
if (program.indexOf('\uFFFD') != -1) {
|
||||
System.err.println(
|
||||
I18n.format(
|
||||
_("\"{0}\" contains unrecognized characters." +
|
||||
"If this code was created with an older version of Arduino," +
|
||||
"you may need to use Tools -> Fix Encoding & Reload to update" +
|
||||
"the sketch to use UTF-8 encoding. If not, you may need to" +
|
||||
"delete the bad characters to get rid of this warning."),
|
||||
file.getName()
|
||||
)
|
||||
);
|
||||
System.err.println();
|
||||
}
|
||||
|
||||
setModified(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save this piece of code, regardless of whether the modified
|
||||
* flag is set or not.
|
||||
*/
|
||||
public void save() throws IOException {
|
||||
// TODO re-enable history
|
||||
//history.record(s, SketchHistory.SAVE);
|
||||
|
||||
BaseNoGui.saveFile(program, file);
|
||||
setModified(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save this file to another location, used by Sketch.saveAs()
|
||||
*/
|
||||
public void saveAs(File newFile) throws IOException {
|
||||
BaseNoGui.saveFile(program, newFile);
|
||||
}
|
||||
|
||||
|
||||
public Object getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
|
||||
public void setMetadata(Object metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
}
|
266
arduino-core/src/processing/app/SketchData.java
Normal file
266
arduino-core/src/processing/app/SketchData.java
Normal file
@ -0,0 +1,266 @@
|
||||
package processing.app;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class SketchData {
|
||||
|
||||
/** main pde file for this sketch. */
|
||||
private File primaryFile;
|
||||
|
||||
/** folder that contains this sketch */
|
||||
private File folder;
|
||||
|
||||
/** data folder location for this sketch (may not exist yet) */
|
||||
private File dataFolder;
|
||||
|
||||
/** code folder location for this sketch (may not exist yet) */
|
||||
private File codeFolder;
|
||||
|
||||
/**
|
||||
* Name of sketch, which is the name of main file (without .pde or .java
|
||||
* extension)
|
||||
*/
|
||||
private String name;
|
||||
|
||||
private List<SketchCode> codes = new ArrayList<SketchCode>();
|
||||
|
||||
private static final Comparator<SketchCode> CODE_DOCS_COMPARATOR = new Comparator<SketchCode>() {
|
||||
@Override
|
||||
public int compare(SketchCode x, SketchCode y) {
|
||||
return x.getFileName().compareTo(y.getFileName());
|
||||
}
|
||||
};
|
||||
|
||||
SketchData(File file) {
|
||||
primaryFile = file;
|
||||
|
||||
// get the name of the sketch by chopping .pde or .java
|
||||
// off of the main file name
|
||||
String mainFilename = primaryFile.getName();
|
||||
int suffixLength = getDefaultExtension().length() + 1;
|
||||
name = mainFilename.substring(0, mainFilename.length() - suffixLength);
|
||||
|
||||
folder = new File(file.getParent());
|
||||
//System.out.println("sketch dir is " + folder);
|
||||
}
|
||||
|
||||
static public File checkSketchFile(File file) {
|
||||
// check to make sure that this .pde file is
|
||||
// in a folder of the same name
|
||||
String fileName = file.getName();
|
||||
File parent = file.getParentFile();
|
||||
String parentName = parent.getName();
|
||||
String pdeName = parentName + ".pde";
|
||||
File altPdeFile = new File(parent, pdeName);
|
||||
String inoName = parentName + ".ino";
|
||||
File altInoFile = new File(parent, inoName);
|
||||
|
||||
if (pdeName.equals(fileName) || inoName.equals(fileName))
|
||||
return file;
|
||||
|
||||
if (altPdeFile.exists())
|
||||
return altPdeFile;
|
||||
|
||||
if (altInoFile.exists())
|
||||
return altInoFile;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the list of files.
|
||||
* <P>
|
||||
* Generally this is only done once, rather than
|
||||
* each time a change is made, because otherwise it gets to be
|
||||
* a nightmare to keep track of what files went where, because
|
||||
* not all the data will be saved to disk.
|
||||
* <P>
|
||||
* This also gets called when the main sketch file is renamed,
|
||||
* because the sketch has to be reloaded from a different folder.
|
||||
* <P>
|
||||
* Another exception is when an external editor is in use,
|
||||
* in which case the load happens each time "run" is hit.
|
||||
*/
|
||||
protected void load() throws IOException {
|
||||
codeFolder = new File(folder, "code");
|
||||
dataFolder = new File(folder, "data");
|
||||
|
||||
// get list of files in the sketch folder
|
||||
String list[] = folder.list();
|
||||
|
||||
// reset these because load() may be called after an
|
||||
// external editor event. (fix for 0099)
|
||||
// codeDocs = new SketchCodeDoc[list.length];
|
||||
clearCodeDocs();
|
||||
// data.setCodeDocs(codeDocs);
|
||||
|
||||
List<String> extensions = getExtensions();
|
||||
|
||||
for (String filename : list) {
|
||||
// Ignoring the dot prefix files is especially important to avoid files
|
||||
// with the ._ prefix on Mac OS X. (You'll see this with Mac files on
|
||||
// non-HFS drives, i.e. a thumb drive formatted FAT32.)
|
||||
if (filename.startsWith(".")) continue;
|
||||
|
||||
// Don't let some wacko name a directory blah.pde or bling.java.
|
||||
if (new File(folder, filename).isDirectory()) continue;
|
||||
|
||||
// figure out the name without any extension
|
||||
String base = filename;
|
||||
// now strip off the .pde and .java extensions
|
||||
for (String extension : extensions) {
|
||||
if (base.toLowerCase().endsWith("." + extension)) {
|
||||
base = base.substring(0, base.length() - (extension.length() + 1));
|
||||
|
||||
// Don't allow people to use files with invalid names, since on load,
|
||||
// it would be otherwise possible to sneak in nasty filenames. [0116]
|
||||
if (BaseNoGui.isSanitaryName(base)) {
|
||||
addCode(new SketchCode(new File(folder, filename)));
|
||||
} else {
|
||||
System.err.println(I18n.format("File name {0} is invalid: ignored", filename));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getCodeCount() == 0)
|
||||
throw new IOException(_("No valid code files found"));
|
||||
|
||||
// move the main class to the first tab
|
||||
// start at 1, if it's at zero, don't bother
|
||||
for (SketchCode code : getCodes()) {
|
||||
//if (code[i].file.getName().equals(mainFilename)) {
|
||||
if (code.getFile().equals(primaryFile)) {
|
||||
moveCodeToFront(code);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// sort the entries at the top
|
||||
sortCode();
|
||||
}
|
||||
|
||||
public void save() throws IOException {
|
||||
for (SketchCode code : getCodes()) {
|
||||
if (code.isModified())
|
||||
code.save();
|
||||
}
|
||||
}
|
||||
|
||||
public int getCodeCount() {
|
||||
return codes.size();
|
||||
}
|
||||
|
||||
public SketchCode[] getCodes() {
|
||||
return codes.toArray(new SketchCode[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default extension for this editor setup.
|
||||
*/
|
||||
public String getDefaultExtension() {
|
||||
return "ino";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String[] array of proper extensions.
|
||||
*/
|
||||
public List<String> getExtensions() {
|
||||
return Arrays.asList("ino", "pde", "c", "cpp", "h");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a file object for the primary .pde of this sketch.
|
||||
*/
|
||||
public File getPrimaryFile() {
|
||||
return primaryFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns path to the main .pde file for this sketch.
|
||||
*/
|
||||
public String getMainFilePath() {
|
||||
return primaryFile.getAbsolutePath();
|
||||
//return code[0].file.getAbsolutePath();
|
||||
}
|
||||
|
||||
public void addCode(SketchCode sketchCode) {
|
||||
codes.add(sketchCode);
|
||||
}
|
||||
|
||||
public void moveCodeToFront(SketchCode codeDoc) {
|
||||
codes.remove(codeDoc);
|
||||
codes.add(0, codeDoc);
|
||||
}
|
||||
|
||||
protected void replaceCode(SketchCode newCode) {
|
||||
for (SketchCode code : codes) {
|
||||
if (code.getFileName().equals(newCode.getFileName())) {
|
||||
codes.set(codes.indexOf(code), newCode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void sortCode() {
|
||||
if (codes.size() < 2)
|
||||
return;
|
||||
SketchCode first = codes.remove(0);
|
||||
Collections.sort(codes, CODE_DOCS_COMPARATOR);
|
||||
codes.add(0, first);
|
||||
}
|
||||
|
||||
public SketchCode getCode(int i) {
|
||||
return codes.get(i);
|
||||
}
|
||||
|
||||
protected void removeCode(SketchCode which) {
|
||||
for (SketchCode code : codes) {
|
||||
if (code == which) {
|
||||
codes.remove(code);
|
||||
return;
|
||||
}
|
||||
}
|
||||
System.err.println("removeCode: internal error.. could not find code");
|
||||
}
|
||||
|
||||
public int indexOfCode(SketchCode who) {
|
||||
for (SketchCode code : codes) {
|
||||
if (code == who)
|
||||
return codes.indexOf(code);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void clearCodeDocs() {
|
||||
codes.clear();
|
||||
}
|
||||
|
||||
public File getFolder() {
|
||||
return folder;
|
||||
}
|
||||
|
||||
public File getDataFolder() {
|
||||
return dataFolder;
|
||||
}
|
||||
|
||||
public File getCodeFolder() {
|
||||
return codeFolder;
|
||||
}
|
||||
}
|
1254
arduino-core/src/processing/app/debug/Compiler.java
Normal file
1254
arduino-core/src/processing/app/debug/Compiler.java
Normal file
File diff suppressed because it is too large
Load Diff
42
arduino-core/src/processing/app/debug/MessageConsumer.java
Normal file
42
arduino-core/src/processing/app/debug/MessageConsumer.java
Normal file
@ -0,0 +1,42 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2004-06 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app.debug;
|
||||
|
||||
|
||||
/**
|
||||
* Interface for dealing with parser/compiler output.
|
||||
* <P>
|
||||
* Different instances of MessageStream need to do different things with
|
||||
* messages. In particular, a stream instance used for parsing output from
|
||||
* the compiler compiler has to interpret its messages differently than one
|
||||
* parsing output from the runtime.
|
||||
* <P>
|
||||
* Classes which consume messages and do something with them
|
||||
* should implement this interface.
|
||||
*/
|
||||
public interface MessageConsumer {
|
||||
|
||||
public void message(String s);
|
||||
|
||||
}
|
147
arduino-core/src/processing/app/debug/MessageSiphon.java
Normal file
147
arduino-core/src/processing/app/debug/MessageSiphon.java
Normal file
@ -0,0 +1,147 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2004-06 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app.debug;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.net.SocketException;
|
||||
|
||||
/**
|
||||
* Slurps up messages from compiler.
|
||||
*/
|
||||
public class MessageSiphon implements Runnable {
|
||||
|
||||
private final Reader streamReader;
|
||||
private final MessageConsumer consumer;
|
||||
|
||||
private Thread thread;
|
||||
private boolean canRun;
|
||||
// Data is processed line-by-line if possible, but if this is non-zero
|
||||
// then a partial line is also processed if no line end is received
|
||||
// within this many milliseconds.
|
||||
private int lineTimeout;
|
||||
|
||||
public MessageSiphon(InputStream stream, MessageConsumer consumer) {
|
||||
this(stream, consumer, 0);
|
||||
}
|
||||
|
||||
public MessageSiphon(InputStream stream, MessageConsumer consumer, int lineTimeout) {
|
||||
this.streamReader = new InputStreamReader(stream);
|
||||
this.consumer = consumer;
|
||||
this.canRun = true;
|
||||
this.lineTimeout = lineTimeout;
|
||||
|
||||
thread = new Thread(this);
|
||||
// don't set priority too low, otherwise exceptions won't
|
||||
// bubble up in time (i.e. compile errors have a weird delay)
|
||||
//thread.setPriority(Thread.MIN_PRIORITY);
|
||||
thread.setPriority(Thread.MAX_PRIORITY - 1);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
// process data until we hit EOF; this will happily block
|
||||
// (effectively sleeping the thread) until new data comes in.
|
||||
// when the program is finally done, null will come through.
|
||||
//
|
||||
StringBuilder currentLine = new StringBuilder();
|
||||
long lineStartTime = 0;
|
||||
while (canRun) {
|
||||
// First, try to read as many characters as possible. Take care
|
||||
// not to block when:
|
||||
// 1. lineTimeout is nonzero, and
|
||||
// 2. we have some characters buffered already
|
||||
while (lineTimeout == 0 || currentLine.length() == 0 || streamReader.ready()) {
|
||||
int c = streamReader.read();
|
||||
if (c == -1)
|
||||
return; // EOF
|
||||
if (!canRun)
|
||||
return;
|
||||
|
||||
// Keep track of the line start time
|
||||
if (currentLine.length() == 0)
|
||||
lineStartTime = System.nanoTime();
|
||||
|
||||
// Store the character line
|
||||
currentLine.append((char)c);
|
||||
|
||||
if (c == '\n') {
|
||||
// We read a full line, pass it on
|
||||
consumer.message(currentLine.toString());
|
||||
currentLine.setLength(0);
|
||||
}
|
||||
}
|
||||
|
||||
// No more characters available. Wait until lineTimeout
|
||||
// milliseconds have passed since the start of the line and then
|
||||
// try reading again. If the time has already passed, then just
|
||||
// pass on the characters read so far.
|
||||
long passed = (System.nanoTime() - lineStartTime) / 1000;
|
||||
if (passed < this.lineTimeout) {
|
||||
Thread.sleep(this.lineTimeout - passed);
|
||||
continue;
|
||||
}
|
||||
|
||||
consumer.message(currentLine.toString());
|
||||
currentLine.setLength(0);
|
||||
}
|
||||
//EditorConsole.systemOut.println("messaging thread done");
|
||||
} catch (NullPointerException npe) {
|
||||
// Fairly common exception during shutdown
|
||||
} catch (SocketException e) {
|
||||
// socket has been close while we were wainting for data. nothing to see here, move along
|
||||
} catch (Exception e) {
|
||||
// On Linux and sometimes on Mac OS X, a "bad file descriptor"
|
||||
// message comes up when closing an applet that's run externally.
|
||||
// That message just gets supressed here..
|
||||
String mess = e.getMessage();
|
||||
if ((mess != null) &&
|
||||
(mess.indexOf("Bad file descriptor") != -1)) {
|
||||
//if (e.getMessage().indexOf("Bad file descriptor") == -1) {
|
||||
//System.err.println("MessageSiphon err " + e);
|
||||
//e.printStackTrace();
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
thread = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Wait until the MessageSiphon thread is complete.
|
||||
public void join() throws java.lang.InterruptedException {
|
||||
// Grab a temp copy in case another thread nulls the "thread"
|
||||
// member variable
|
||||
Thread t = thread;
|
||||
if (t != null) t.join();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
this.canRun = false;
|
||||
}
|
||||
|
||||
}
|
161
arduino-core/src/processing/app/debug/RunnerException.java
Normal file
161
arduino-core/src/processing/app/debug/RunnerException.java
Normal file
@ -0,0 +1,161 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2004-08 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app.debug;
|
||||
|
||||
|
||||
/**
|
||||
* An exception with a line number attached that occurs
|
||||
* during either compile time or run time.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class RunnerException extends Exception {
|
||||
protected String message;
|
||||
protected int codeIndex;
|
||||
protected int codeLine;
|
||||
protected int codeColumn;
|
||||
protected boolean showStackTrace;
|
||||
|
||||
|
||||
public RunnerException(String message) {
|
||||
this(message, true);
|
||||
}
|
||||
|
||||
public RunnerException(String message, boolean showStackTrace) {
|
||||
this(message, -1, -1, -1, showStackTrace);
|
||||
}
|
||||
|
||||
public RunnerException(String message, int file, int line) {
|
||||
this(message, file, line, -1, true);
|
||||
}
|
||||
|
||||
|
||||
public RunnerException(String message, int file, int line, int column) {
|
||||
this(message, file, line, column, true);
|
||||
}
|
||||
|
||||
|
||||
public RunnerException(String message, int file, int line, int column,
|
||||
boolean showStackTrace) {
|
||||
this.message = message;
|
||||
this.codeIndex = file;
|
||||
this.codeLine = line;
|
||||
this.codeColumn = column;
|
||||
this.showStackTrace = showStackTrace;
|
||||
}
|
||||
|
||||
|
||||
public RunnerException(Exception e) {
|
||||
super(e);
|
||||
this.showStackTrace = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override getMessage() in Throwable, so that I can set
|
||||
* the message text outside the constructor.
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
public int getCodeIndex() {
|
||||
return codeIndex;
|
||||
}
|
||||
|
||||
|
||||
public void setCodeIndex(int index) {
|
||||
codeIndex = index;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasCodeIndex() {
|
||||
return codeIndex != -1;
|
||||
}
|
||||
|
||||
|
||||
public int getCodeLine() {
|
||||
return codeLine;
|
||||
}
|
||||
|
||||
|
||||
public void setCodeLine(int line) {
|
||||
this.codeLine = line;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasCodeLine() {
|
||||
return codeLine != -1;
|
||||
}
|
||||
|
||||
|
||||
public void setCodeColumn(int column) {
|
||||
this.codeColumn = column;
|
||||
}
|
||||
|
||||
|
||||
public int getCodeColumn() {
|
||||
return codeColumn;
|
||||
}
|
||||
|
||||
|
||||
public void showStackTrace() {
|
||||
showStackTrace = true;
|
||||
}
|
||||
|
||||
|
||||
public void hideStackTrace() {
|
||||
showStackTrace = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Nix the java.lang crap out of an exception message
|
||||
* because it scares the children.
|
||||
* <P>
|
||||
* This function must be static to be used with super()
|
||||
* in each of the constructors above.
|
||||
*/
|
||||
/*
|
||||
static public final String massage(String msg) {
|
||||
if (msg.indexOf("java.lang.") == 0) {
|
||||
//int dot = msg.lastIndexOf('.');
|
||||
msg = msg.substring("java.lang.".length());
|
||||
}
|
||||
return msg;
|
||||
//return (dot == -1) ? msg : msg.substring(dot+1);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public void printStackTrace() {
|
||||
if (showStackTrace) {
|
||||
super.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
125
arduino-core/src/processing/app/debug/Sizer.java
Normal file
125
arduino-core/src/processing/app/debug/Sizer.java
Normal file
@ -0,0 +1,125 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Sizer - computes the size of a .hex file
|
||||
Part of the Arduino project - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2006 David A. Mellis
|
||||
Copyright (c) 2011 Cristian Maglie <c.maglie@bug.st>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app.debug;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
import processing.app.helpers.ProcessUtils;
|
||||
import processing.app.helpers.StringReplacer;
|
||||
|
||||
public class Sizer implements MessageConsumer {
|
||||
private long textSize;
|
||||
private long dataSize;
|
||||
private long eepromSize;
|
||||
private RunnerException exception;
|
||||
private PreferencesMap prefs;
|
||||
private String firstLine;
|
||||
private Pattern textPattern;
|
||||
private Pattern dataPattern;
|
||||
private Pattern eepromPattern;
|
||||
|
||||
public Sizer(PreferencesMap _prefs) {
|
||||
prefs = _prefs;
|
||||
textPattern = Pattern.compile(prefs.get("recipe.size.regex"));
|
||||
dataPattern = null;
|
||||
String pref = prefs.get("recipe.size.regex.data");
|
||||
if (pref != null)
|
||||
dataPattern = Pattern.compile(pref);
|
||||
eepromPattern = null;
|
||||
pref = prefs.get("recipe.size.regex.eeprom");
|
||||
if (pref != null)
|
||||
eepromPattern = Pattern.compile(pref);
|
||||
}
|
||||
|
||||
public long[] computeSize() throws RunnerException {
|
||||
|
||||
int r = 0;
|
||||
try {
|
||||
String pattern = prefs.get("recipe.size.pattern");
|
||||
String cmd[] = StringReplacer.formatAndSplit(pattern, prefs, true);
|
||||
|
||||
exception = null;
|
||||
textSize = -1;
|
||||
dataSize = -1;
|
||||
eepromSize = -1;
|
||||
Process process = ProcessUtils.exec(cmd);
|
||||
MessageSiphon in = new MessageSiphon(process.getInputStream(), this);
|
||||
MessageSiphon err = new MessageSiphon(process.getErrorStream(), this);
|
||||
|
||||
boolean running = true;
|
||||
while(running) {
|
||||
try {
|
||||
in.join();
|
||||
err.join();
|
||||
r = process.waitFor();
|
||||
running = false;
|
||||
} catch (InterruptedException intExc) { }
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// The default Throwable.toString() never returns null, but apparently
|
||||
// some sub-class has overridden it to do so, thus we need to check for
|
||||
// it. See: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1166589459
|
||||
exception = new RunnerException(
|
||||
(e.toString() == null) ? e.getClass().getName() + r : e.toString() + r);
|
||||
}
|
||||
|
||||
if (exception != null)
|
||||
throw exception;
|
||||
|
||||
if (textSize == -1)
|
||||
throw new RunnerException(firstLine);
|
||||
|
||||
return new long[] { textSize, dataSize, eepromSize };
|
||||
}
|
||||
|
||||
public void message(String s) {
|
||||
if (firstLine == null)
|
||||
firstLine = s;
|
||||
Matcher textMatcher = textPattern.matcher(s.trim());
|
||||
if (textMatcher.matches()) {
|
||||
if (textSize < 0)
|
||||
textSize = 0;
|
||||
textSize += Long.parseLong(textMatcher.group(1));
|
||||
}
|
||||
if(dataPattern != null) {
|
||||
Matcher dataMatcher = dataPattern.matcher(s.trim());
|
||||
if (dataMatcher.matches()) {
|
||||
if (dataSize < 0)
|
||||
dataSize = 0;
|
||||
dataSize += Long.parseLong(dataMatcher.group(1));
|
||||
}
|
||||
}
|
||||
if(eepromPattern != null) {
|
||||
Matcher eepromMatcher = eepromPattern.matcher(s.trim());
|
||||
if (eepromMatcher.matches()) {
|
||||
if (eepromSize < 0)
|
||||
eepromSize = 0;
|
||||
eepromSize += Long.parseLong(eepromMatcher.group(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
132
arduino-core/src/processing/app/debug/TargetBoard.java
Normal file
132
arduino-core/src/processing/app/debug/TargetBoard.java
Normal file
@ -0,0 +1,132 @@
|
||||
package processing.app.debug;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.format;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
|
||||
public class TargetBoard {
|
||||
|
||||
private String id;
|
||||
private PreferencesMap prefs;
|
||||
private Map<String, PreferencesMap> menuOptions = new LinkedHashMap<String, PreferencesMap>();
|
||||
private TargetPlatform containerPlatform;
|
||||
|
||||
/**
|
||||
* Create a TargetBoard based on preferences passed as argument.
|
||||
*
|
||||
* @param _prefs
|
||||
* @return
|
||||
*/
|
||||
public TargetBoard(String _id, PreferencesMap _prefs, TargetPlatform parent) {
|
||||
containerPlatform = parent;
|
||||
id = _id;
|
||||
prefs = new PreferencesMap(_prefs);
|
||||
|
||||
// Setup sub-menus
|
||||
PreferencesMap menus = prefs.firstLevelMap().get("menu");
|
||||
if (menus != null)
|
||||
menuOptions = menus.firstLevelMap();
|
||||
|
||||
// Auto generate build.board if not set
|
||||
if (!prefs.containsKey("build.board")) {
|
||||
String board = containerPlatform.getId() + "_" + id;
|
||||
board = board.toUpperCase();
|
||||
prefs.put("build.board", board);
|
||||
System.out
|
||||
.println(format(
|
||||
_("Board {0}:{1}:{2} doesn''t define a ''build.board'' preference. Auto-set to: {3}"),
|
||||
containerPlatform.getContainerPackage().getId(),
|
||||
containerPlatform.getId(), id, board));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the board.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName() {
|
||||
return prefs.get("name");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the identifier of the board
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full preferences map of the board with a given identifier
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public PreferencesMap getPreferences() {
|
||||
return prefs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the board has a sub menu.
|
||||
*
|
||||
* @param menuId
|
||||
* The menu ID to check
|
||||
* @return
|
||||
*/
|
||||
public boolean hasMenu(String menuId) {
|
||||
return menuOptions.containsKey(menuId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the options available on a specific menu
|
||||
*
|
||||
* @param menuId
|
||||
* The menu ID
|
||||
* @return
|
||||
*/
|
||||
public PreferencesMap getMenuLabels(String menuId) {
|
||||
return menuOptions.get(menuId).topLevelMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the label of the specified option in the specified menu
|
||||
*
|
||||
* @param menuId
|
||||
* The menu ID
|
||||
* @param selectionId
|
||||
* The option ID
|
||||
* @return
|
||||
*/
|
||||
public String getMenuLabel(String menuId, String selectionId) {
|
||||
return getMenuLabels(menuId).get(selectionId);
|
||||
}
|
||||
|
||||
public Set<String> getMenuIds() {
|
||||
return menuOptions.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration parameters to override (as a PreferenceMap) when
|
||||
* the specified option in the specified menu is selected
|
||||
*
|
||||
* @param menuId
|
||||
* The menu ID
|
||||
* @param selectionId
|
||||
* The option ID
|
||||
* @return
|
||||
*/
|
||||
public PreferencesMap getMenuPreferences(String menuId, String selectionId) {
|
||||
return menuOptions.get(menuId).subTree(selectionId);
|
||||
}
|
||||
|
||||
public TargetPlatform getContainerPlatform() {
|
||||
return containerPlatform;
|
||||
}
|
||||
|
||||
}
|
81
arduino-core/src/processing/app/debug/TargetPackage.java
Normal file
81
arduino-core/src/processing/app/debug/TargetPackage.java
Normal file
@ -0,0 +1,81 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
TargetPackage - Represents a hardware package
|
||||
Part of the Arduino project - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2011 Cristian Maglie
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
package processing.app.debug;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import processing.app.I18n;
|
||||
import processing.app.helpers.filefilters.OnlyDirs;
|
||||
|
||||
public class TargetPackage {
|
||||
|
||||
private String id;
|
||||
|
||||
Map<String, TargetPlatform> platforms = new LinkedHashMap<String, TargetPlatform>();
|
||||
|
||||
public TargetPackage(String _id, File _folder) throws TargetPlatformException {
|
||||
id = _id;
|
||||
|
||||
File[] folders = _folder.listFiles(new OnlyDirs());
|
||||
if (folders == null)
|
||||
return;
|
||||
|
||||
for (File subFolder : folders) {
|
||||
if (!subFolder.exists() || !subFolder.canRead())
|
||||
continue;
|
||||
String arch = subFolder.getName();
|
||||
try {
|
||||
TargetPlatform platform = new TargetPlatform(arch, subFolder, this);
|
||||
platforms.put(arch, platform);
|
||||
} catch (TargetPlatformException e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (platforms.size() == 0) {
|
||||
throw new TargetPlatformException(I18n
|
||||
.format(_("No valid hardware definitions found in folder {0}."),
|
||||
_folder.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, TargetPlatform> getPlatforms() {
|
||||
return platforms;
|
||||
}
|
||||
|
||||
public Collection<TargetPlatform> platforms() {
|
||||
return platforms.values();
|
||||
}
|
||||
|
||||
public TargetPlatform get(String platform) {
|
||||
return platforms.get(platform);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
194
arduino-core/src/processing/app/debug/TargetPlatform.java
Normal file
194
arduino-core/src/processing/app/debug/TargetPlatform.java
Normal file
@ -0,0 +1,194 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
TargetPlatform - Represents a hardware platform
|
||||
Part of the Arduino project - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2009 David A. Mellis
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
package processing.app.debug;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.format;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
|
||||
public class TargetPlatform {
|
||||
|
||||
private String id;
|
||||
private File folder;
|
||||
private TargetPackage containerPackage;
|
||||
|
||||
/**
|
||||
* Contains preferences for every defined board
|
||||
*/
|
||||
private Map<String, TargetBoard> boards = new LinkedHashMap<String, TargetBoard>();
|
||||
private TargetBoard defaultBoard;
|
||||
|
||||
/**
|
||||
* Contains preferences for every defined programmer
|
||||
*/
|
||||
private Map<String, PreferencesMap> programmers = new LinkedHashMap<String, PreferencesMap>();
|
||||
|
||||
/**
|
||||
* Contains preferences for platform
|
||||
*/
|
||||
private PreferencesMap preferences = new PreferencesMap();
|
||||
|
||||
/**
|
||||
* Contains labels for top level menus
|
||||
*/
|
||||
private PreferencesMap customMenus = new PreferencesMap();
|
||||
|
||||
public TargetPlatform(String _name, File _folder, TargetPackage parent)
|
||||
throws TargetPlatformException {
|
||||
|
||||
id = _name;
|
||||
folder = _folder;
|
||||
containerPackage = parent;
|
||||
|
||||
// If there is no boards.txt, this is not a valid 1.5 hardware folder
|
||||
File boardsFile = new File(folder, "boards.txt");
|
||||
if (!boardsFile.exists() || !boardsFile.canRead())
|
||||
throw new TargetPlatformException(
|
||||
format(_("Could not find boards.txt in {0}. Is it pre-1.5?"),
|
||||
folder.getAbsolutePath()));
|
||||
|
||||
// Load boards
|
||||
try {
|
||||
Map<String, PreferencesMap> boardsPreferences = new PreferencesMap(
|
||||
boardsFile).firstLevelMap();
|
||||
|
||||
// Create custom menus for this platform
|
||||
PreferencesMap menus = boardsPreferences.get("menu");
|
||||
if (menus != null)
|
||||
customMenus = menus.topLevelMap();
|
||||
boardsPreferences.remove("menu");
|
||||
|
||||
// Create boards
|
||||
Set<String> boardIDs = boardsPreferences.keySet();
|
||||
for (String id : boardIDs) {
|
||||
PreferencesMap preferences = boardsPreferences.get(id);
|
||||
TargetBoard board = new TargetBoard(id, preferences, this);
|
||||
boards.put(id, board);
|
||||
}
|
||||
if (!boardIDs.isEmpty()) {
|
||||
PreferencesMap preferences = boardsPreferences.get(boardIDs.iterator().next());
|
||||
defaultBoard = new TargetBoard(id, preferences, this);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new TargetPlatformException(format(_("Error loading {0}"),
|
||||
boardsFile.getAbsolutePath()), e);
|
||||
}
|
||||
|
||||
File platformsFile = new File(folder, "platform.txt");
|
||||
try {
|
||||
if (platformsFile.exists() && platformsFile.canRead()) {
|
||||
preferences.load(platformsFile);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new TargetPlatformException(
|
||||
format(_("Error loading {0}"), platformsFile.getAbsolutePath()), e);
|
||||
}
|
||||
|
||||
// Allow overriding values in platform.txt. This allows changing
|
||||
// platform.txt (e.g. to use a system-wide toolchain), without
|
||||
// having to modify platform.txt (which, when running from git,
|
||||
// prevents files being marked as changed).
|
||||
File localPlatformsFile = new File(folder, "platform.local.txt");
|
||||
try {
|
||||
if (localPlatformsFile.exists() && localPlatformsFile.canRead()) {
|
||||
preferences.load(localPlatformsFile);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new TargetPlatformException(
|
||||
format(_("Error loading {0}"), localPlatformsFile.getAbsolutePath()), e);
|
||||
}
|
||||
|
||||
File progFile = new File(folder, "programmers.txt");
|
||||
try {
|
||||
if (progFile.exists() && progFile.canRead()) {
|
||||
PreferencesMap prefs = new PreferencesMap();
|
||||
prefs.load(progFile);
|
||||
programmers = prefs.firstLevelMap();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new TargetPlatformException(format(_("Error loading {0}"), progFile
|
||||
.getAbsolutePath()), e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public File getFolder() {
|
||||
return folder;
|
||||
}
|
||||
|
||||
public Map<String, TargetBoard> getBoards() {
|
||||
return boards;
|
||||
}
|
||||
|
||||
public PreferencesMap getCustomMenus() {
|
||||
return customMenus;
|
||||
}
|
||||
|
||||
public Set<String> getCustomMenuIds() {
|
||||
return customMenus.keySet();
|
||||
}
|
||||
|
||||
public Map<String, PreferencesMap> getProgrammers() {
|
||||
return programmers;
|
||||
}
|
||||
|
||||
public PreferencesMap getProgrammer(String programmer) {
|
||||
return getProgrammers().get(programmer);
|
||||
}
|
||||
|
||||
public PreferencesMap getTool(String tool) {
|
||||
return getPreferences().subTree("tools").subTree(tool);
|
||||
}
|
||||
|
||||
public PreferencesMap getPreferences() {
|
||||
return preferences;
|
||||
}
|
||||
|
||||
public TargetBoard getBoard(String boardId) {
|
||||
if (boards.containsKey(boardId)) {
|
||||
return boards.get(boardId);
|
||||
}
|
||||
return defaultBoard;
|
||||
}
|
||||
|
||||
public TargetPackage getContainerPackage() {
|
||||
return containerPackage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String res = "TargetPlatform: name=" + id + " boards={\n";
|
||||
for (String boardId : boards.keySet())
|
||||
res += " " + boardId + " = " + boards.get(boardId) + "\n";
|
||||
return res + "}";
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package processing.app.debug;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class TargetPlatformException extends Exception {
|
||||
|
||||
public TargetPlatformException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public TargetPlatformException(String arg0, Throwable arg1) {
|
||||
super(arg0, arg1);
|
||||
}
|
||||
|
||||
public TargetPlatformException(String arg0) {
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
public TargetPlatformException(Throwable arg0) {
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package processing.app.helpers;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
public class BasicUserNotifier extends UserNotifier {
|
||||
|
||||
/**
|
||||
* Show an error message that's actually fatal to the program.
|
||||
* This is an error that can't be recovered. Use showWarning()
|
||||
* for errors that allow P5 to continue running.
|
||||
*/
|
||||
public void showError(String title, String message, Throwable e, int exit_code) {
|
||||
if (title == null) title = _("Error");
|
||||
|
||||
System.err.println(title + ": " + message);
|
||||
|
||||
if (e != null) e.printStackTrace();
|
||||
System.exit(exit_code);
|
||||
}
|
||||
|
||||
public void showMessage(String title, String message) {
|
||||
if (title == null) title = _("Message");
|
||||
|
||||
System.out.println(title + ": " + message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Non-fatal error message with optional stack trace side dish.
|
||||
*/
|
||||
public void showWarning(String title, String message, Exception e) {
|
||||
if (title == null) title = _("Warning");
|
||||
|
||||
System.out.println(title + ": " + message);
|
||||
|
||||
if (e != null) e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
283
arduino-core/src/processing/app/helpers/CommandlineParser.java
Normal file
283
arduino-core/src/processing/app/helpers/CommandlineParser.java
Normal file
@ -0,0 +1,283 @@
|
||||
package processing.app.helpers;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.I18n;
|
||||
import processing.app.PreferencesData;
|
||||
import processing.app.debug.TargetBoard;
|
||||
import processing.app.debug.TargetPackage;
|
||||
import processing.app.debug.TargetPlatform;
|
||||
import processing.app.legacy.PApplet;
|
||||
|
||||
public class CommandlineParser {
|
||||
|
||||
protected static enum ACTION { GUI, NOOP, VERIFY, UPLOAD, GET_PREF };
|
||||
|
||||
private ACTION action = ACTION.GUI;
|
||||
private boolean doVerboseBuild = false;
|
||||
private boolean doVerboseUpload = false;
|
||||
private boolean doUseProgrammer = false;
|
||||
private boolean noUploadPort = false;
|
||||
private boolean forceSavePrefs = false;
|
||||
private String getPref = null;
|
||||
private List<String> filenames = new LinkedList<String>();
|
||||
|
||||
public static CommandlineParser newCommandlineParser(String[] args) {
|
||||
return new CommandlineParser(args);
|
||||
}
|
||||
|
||||
private CommandlineParser(String[] args) {
|
||||
parseArguments(args);
|
||||
checkAction();
|
||||
}
|
||||
|
||||
private void parseArguments(String[] args) {
|
||||
// Map of possible actions and corresponding options
|
||||
final Map<String, ACTION> actions = new HashMap<String, ACTION>();
|
||||
actions.put("--verify", ACTION.VERIFY);
|
||||
actions.put("--upload", ACTION.UPLOAD);
|
||||
actions.put("--get-pref", ACTION.GET_PREF);
|
||||
|
||||
// Check if any files were passed in on the command line
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
ACTION a = actions.get(args[i]);
|
||||
if (a != null) {
|
||||
if (action != ACTION.GUI && action != ACTION.NOOP) {
|
||||
String[] valid = actions.keySet().toArray(new String[0]);
|
||||
String mess = I18n.format(_("Can only pass one of: {0}"), PApplet.join(valid, ", "));
|
||||
BaseNoGui.showError(null, mess, 3);
|
||||
}
|
||||
if (a == ACTION.GET_PREF) {
|
||||
i++;
|
||||
if (i >= args.length)
|
||||
BaseNoGui.showError(null, _("Argument required for --get-pref"), 3);
|
||||
getPref = args[i];
|
||||
}
|
||||
action = a;
|
||||
continue;
|
||||
}
|
||||
if (args[i].equals("--verbose") || args[i].equals("-v")) {
|
||||
doVerboseBuild = true;
|
||||
doVerboseUpload = true;
|
||||
if (action == ACTION.GUI)
|
||||
action = ACTION.NOOP;
|
||||
continue;
|
||||
}
|
||||
if (args[i].equals("--verbose-build")) {
|
||||
doVerboseBuild = true;
|
||||
if (action == ACTION.GUI)
|
||||
action = ACTION.NOOP;
|
||||
continue;
|
||||
}
|
||||
if (args[i].equals("--verbose-upload")) {
|
||||
doVerboseUpload = true;
|
||||
if (action == ACTION.GUI)
|
||||
action = ACTION.NOOP;
|
||||
continue;
|
||||
}
|
||||
if (args[i].equals("--useprogrammer")) {
|
||||
doUseProgrammer = true;
|
||||
if (action == ACTION.GUI)
|
||||
action = ACTION.NOOP;
|
||||
continue;
|
||||
}
|
||||
if (args[i].equals("--nouploadport")) {
|
||||
noUploadPort = true;
|
||||
if (action == ACTION.GUI)
|
||||
action = ACTION.NOOP;
|
||||
continue;
|
||||
}
|
||||
if (args[i].equals("--board")) {
|
||||
i++;
|
||||
if (i >= args.length)
|
||||
BaseNoGui.showError(null, _("Argument required for --board"), 3);
|
||||
processBoardArgument(args[i]);
|
||||
if (action == ACTION.GUI)
|
||||
action = ACTION.NOOP;
|
||||
continue;
|
||||
}
|
||||
if (args[i].equals("--port")) {
|
||||
i++;
|
||||
if (i >= args.length)
|
||||
BaseNoGui.showError(null, _("Argument required for --port"), 3);
|
||||
BaseNoGui.selectSerialPort(args[i]);
|
||||
if (action == ACTION.GUI)
|
||||
action = ACTION.NOOP;
|
||||
continue;
|
||||
}
|
||||
if (args[i].equals("--curdir")) {
|
||||
i++;
|
||||
if (i >= args.length)
|
||||
BaseNoGui.showError(null, _("Argument required for --curdir"), 3);
|
||||
// Argument should be already processed by Base.main(...)
|
||||
continue;
|
||||
}
|
||||
if (args[i].equals("--buildpath")) {
|
||||
i++;
|
||||
if (i >= args.length) {
|
||||
BaseNoGui.showError(null, "Argument required for --buildpath", 3);
|
||||
}
|
||||
File buildFolder = new File(args[i]);
|
||||
if (!buildFolder.exists()) {
|
||||
BaseNoGui.showError(null, "The build path doesn't exist", 3);
|
||||
}
|
||||
if (!buildFolder.isDirectory()) {
|
||||
BaseNoGui.showError(null, "The build path is not a folder", 3);
|
||||
}
|
||||
BaseNoGui.setBuildFolder(buildFolder);
|
||||
continue;
|
||||
}
|
||||
if (args[i].equals("--pref")) {
|
||||
i++;
|
||||
if (i >= args.length)
|
||||
BaseNoGui.showError(null, _("Argument required for --pref"), 3);
|
||||
processPrefArgument(args[i]);
|
||||
if (action == ACTION.GUI)
|
||||
action = ACTION.NOOP;
|
||||
continue;
|
||||
}
|
||||
if (args[i].equals("--save-prefs")) {
|
||||
forceSavePrefs = true;
|
||||
continue;
|
||||
}
|
||||
if (args[i].equals("--preferences-file")) {
|
||||
i++;
|
||||
if (i >= args.length)
|
||||
BaseNoGui.showError(null, _("Argument required for --preferences-file"), 3);
|
||||
// Argument should be already processed by Base.main(...)
|
||||
continue;
|
||||
}
|
||||
if (args[i].startsWith("--"))
|
||||
BaseNoGui.showError(null, I18n.format(_("unknown option: {0}"), args[i]), 3);
|
||||
|
||||
filenames.add(args[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAction() {
|
||||
if ((action == ACTION.UPLOAD || action == ACTION.VERIFY) && filenames.size() != 1)
|
||||
BaseNoGui.showError(null, _("Must specify exactly one sketch file"), 3);
|
||||
|
||||
if ((action == ACTION.NOOP || action == ACTION.GET_PREF) && filenames.size() != 0)
|
||||
BaseNoGui.showError(null, _("Cannot specify any sketch files"), 3);
|
||||
|
||||
if ((action != ACTION.UPLOAD && action != ACTION.VERIFY) && (doVerboseBuild || doVerboseUpload))
|
||||
BaseNoGui.showError(null, _("--verbose, --verbose-upload and --verbose-build can only be used together with --verify or --upload"), 3);
|
||||
}
|
||||
|
||||
private void processBoardArgument(String selectBoard) {
|
||||
// No board selected? Nothing to do
|
||||
if (selectBoard == null)
|
||||
return;
|
||||
|
||||
String[] split = selectBoard.split(":", 4);
|
||||
|
||||
if (split.length < 3) {
|
||||
BaseNoGui.showError(null, I18n.format(_("{0}: Invalid board name, it should be of the form \"package:arch:board\" or \"package:arch:board:options\""), selectBoard), 3);
|
||||
}
|
||||
|
||||
TargetPackage targetPackage = BaseNoGui.getTargetPackage(split[0]);
|
||||
if (targetPackage == null) {
|
||||
BaseNoGui.showError(null, I18n.format(_("{0}: Unknown package"), split[0]), 3);
|
||||
}
|
||||
|
||||
TargetPlatform targetPlatform = targetPackage.get(split[1]);
|
||||
if (targetPlatform == null) {
|
||||
BaseNoGui.showError(null, I18n.format(_("{0}: Unknown architecture"), split[1]), 3);
|
||||
}
|
||||
|
||||
TargetBoard targetBoard = targetPlatform.getBoard(split[2]);
|
||||
if (targetBoard == null) {
|
||||
BaseNoGui.showError(null, I18n.format(_("{0}: Unknown board"), split[2]), 3);
|
||||
}
|
||||
|
||||
BaseNoGui.selectBoard(targetBoard);
|
||||
|
||||
if (split.length > 3) {
|
||||
String[] options = split[3].split(",");
|
||||
for (String option : options) {
|
||||
String[] keyValue = option.split("=", 2);
|
||||
|
||||
if (keyValue.length != 2)
|
||||
BaseNoGui.showError(null, I18n.format(_("{0}: Invalid option, should be of the form \"name=value\""), option, targetBoard.getId()), 3);
|
||||
String key = keyValue[0].trim();
|
||||
String value = keyValue[1].trim();
|
||||
|
||||
if (!targetBoard.hasMenu(key))
|
||||
BaseNoGui.showError(null, I18n.format(_("{0}: Invalid option for board \"{1}\""), key, targetBoard.getId()), 3);
|
||||
if (targetBoard.getMenuLabel(key, value) == null)
|
||||
BaseNoGui.showError(null, I18n.format(_("{0}: Invalid option for \"{1}\" option for board \"{2}\""), value, key, targetBoard.getId()), 3);
|
||||
|
||||
PreferencesData.set("custom_" + key, targetBoard.getId() + "_" + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processPrefArgument(String arg) {
|
||||
String[] split = arg.split("=", 2);
|
||||
if (split.length != 2 || split[0].isEmpty())
|
||||
BaseNoGui.showError(null, I18n.format(_("{0}: Invalid argument to --pref, should be of the form \"pref=value\""), arg), 3);
|
||||
|
||||
PreferencesData.set(split[0], split[1]);
|
||||
}
|
||||
|
||||
public boolean isDoVerboseBuild() {
|
||||
return doVerboseBuild;
|
||||
}
|
||||
|
||||
public boolean isDoVerboseUpload() {
|
||||
return doVerboseUpload;
|
||||
}
|
||||
|
||||
public boolean isForceSavePrefs() {
|
||||
return forceSavePrefs;
|
||||
}
|
||||
|
||||
public String getGetPref() {
|
||||
return getPref;
|
||||
}
|
||||
|
||||
public List<String> getFilenames() {
|
||||
return filenames;
|
||||
}
|
||||
|
||||
public boolean isGetPrefMode() {
|
||||
return action == ACTION.GET_PREF;
|
||||
}
|
||||
|
||||
public boolean isGuiMode() {
|
||||
return action == ACTION.GUI;
|
||||
}
|
||||
|
||||
public boolean isNoOpMode() {
|
||||
return action == ACTION.NOOP;
|
||||
}
|
||||
|
||||
public boolean isUploadMode() {
|
||||
return action == ACTION.UPLOAD;
|
||||
}
|
||||
|
||||
public boolean isVerifyMode() {
|
||||
return action == ACTION.VERIFY;
|
||||
}
|
||||
|
||||
public boolean isVerifyOrUploadMode() {
|
||||
return isVerifyMode() || isUploadMode();
|
||||
}
|
||||
|
||||
public boolean isDoUseProgrammer() {
|
||||
return doUseProgrammer;
|
||||
}
|
||||
|
||||
public boolean isNoUploadPort() {
|
||||
return noUploadPort;
|
||||
}
|
||||
|
||||
}
|
259
arduino-core/src/processing/app/helpers/FileUtils.java
Normal file
259
arduino-core/src/processing/app/helpers/FileUtils.java
Normal file
@ -0,0 +1,259 @@
|
||||
package processing.app.helpers;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class FileUtils {
|
||||
|
||||
private static final List<String> SOURCE_CONTROL_FOLDERS = Arrays.asList("CVS", "RCS", ".git", ".svn", ".hg", ".bzr");
|
||||
private static final Pattern BACKSLASH = Pattern.compile("\\\\");
|
||||
|
||||
/**
|
||||
* Checks, whether the child directory is a subdirectory of the base directory.
|
||||
*
|
||||
* @param base the base directory.
|
||||
* @param child the suspected child directory.
|
||||
* @return true, if the child is a subdirectory of the base directory.
|
||||
*/
|
||||
public static boolean isSubDirectory(File base, File child) {
|
||||
try {
|
||||
base = base.getCanonicalFile();
|
||||
child = child.getCanonicalFile();
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
File parentFile = child;
|
||||
while (parentFile != null) {
|
||||
if (base.equals(parentFile)) {
|
||||
return true;
|
||||
}
|
||||
parentFile = parentFile.getParentFile();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void copyFile(File source, File dest) throws IOException {
|
||||
FileInputStream fis = null;
|
||||
FileOutputStream fos = null;
|
||||
try {
|
||||
fis = new FileInputStream(source);
|
||||
fos = new FileOutputStream(dest);
|
||||
byte[] buf = new byte[4096];
|
||||
int readBytes = -1;
|
||||
while ((readBytes = fis.read(buf, 0, buf.length)) != -1) {
|
||||
fos.write(buf, 0, readBytes);
|
||||
}
|
||||
} finally {
|
||||
if (fis != null) {
|
||||
fis.close();
|
||||
}
|
||||
if (fos != null) {
|
||||
fos.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void copy(File sourceFolder, File destFolder) throws IOException {
|
||||
for (File file : sourceFolder.listFiles()) {
|
||||
File destFile = new File(destFolder, file.getName());
|
||||
if (file.isDirectory()) {
|
||||
if (!destFile.mkdir()) {
|
||||
throw new IOException("Unable to create folder: " + destFile);
|
||||
}
|
||||
copy(file, destFile);
|
||||
} else {
|
||||
copyFile(file, destFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void recursiveDelete(File file) {
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
if (file.isDirectory()) {
|
||||
for (File current : file.listFiles()) {
|
||||
if (current.isDirectory()) {
|
||||
recursiveDelete(current);
|
||||
} else {
|
||||
current.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
file.delete();
|
||||
}
|
||||
|
||||
public static File createTempFolder() throws IOException {
|
||||
File tmpFolder = new File(System.getProperty("java.io.tmpdir"), "arduino_" + new Random().nextInt(1000000));
|
||||
if (!tmpFolder.mkdir()) {
|
||||
throw new IOException("Unable to create temp folder " + tmpFolder);
|
||||
}
|
||||
return tmpFolder;
|
||||
}
|
||||
|
||||
//
|
||||
// Compute relative path to "target" from a directory "origin".
|
||||
//
|
||||
// If "origin" is not absolute, it is relative from the current directory.
|
||||
// If "target" is not absolute, it is relative from "origin".
|
||||
//
|
||||
// by Shigeru KANEMOTO at SWITCHSCIENCE.
|
||||
//
|
||||
public static String relativePath(String origin, String target) {
|
||||
try {
|
||||
origin = (new File(origin)).getCanonicalPath();
|
||||
File targetFile = new File(target);
|
||||
if (targetFile.isAbsolute())
|
||||
target = targetFile.getCanonicalPath();
|
||||
else
|
||||
target = (new File(origin, target)).getCanonicalPath();
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (origin.equals(target)) {
|
||||
// origin and target is identical.
|
||||
return ".";
|
||||
}
|
||||
|
||||
if (origin.equals(File.separator)) {
|
||||
// origin is root.
|
||||
return "." + target;
|
||||
}
|
||||
|
||||
String prefix = "";
|
||||
String root = File.separator;
|
||||
|
||||
if (System.getProperty("os.name").indexOf("Windows") != -1) {
|
||||
if (origin.startsWith("\\\\") || target.startsWith("\\\\")) {
|
||||
// Windows UNC path not supported.
|
||||
return null;
|
||||
}
|
||||
|
||||
char originLetter = origin.charAt(0);
|
||||
char targetLetter = target.charAt(0);
|
||||
if (Character.isLetter(originLetter) && Character.isLetter(targetLetter)) {
|
||||
// Windows only
|
||||
if (originLetter != targetLetter) {
|
||||
// Drive letters differ
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
prefix = "" + originLetter + ':';
|
||||
root = prefix + File.separator;
|
||||
}
|
||||
|
||||
String relative = "";
|
||||
while (!target.startsWith(origin + File.separator)) {
|
||||
origin = (new File(origin)).getParent();
|
||||
if (origin.equals(root))
|
||||
origin = prefix;
|
||||
relative += "..";
|
||||
relative += File.separator;
|
||||
}
|
||||
|
||||
return relative + target.substring(origin.length() + 1);
|
||||
}
|
||||
|
||||
public static String getLinuxPathFrom(File file) {
|
||||
return BACKSLASH.matcher(file.getAbsolutePath()).replaceAll("/");
|
||||
}
|
||||
|
||||
public static boolean isSCCSOrHiddenFile(File file) {
|
||||
return file.isHidden() || file.getName().charAt(0) == '.' || (file.isDirectory() && SOURCE_CONTROL_FOLDERS.contains(file.getName()));
|
||||
}
|
||||
|
||||
public static String readFileToString(File file) throws IOException {
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
sb.append(line).append("\n");
|
||||
}
|
||||
return sb.toString();
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given file has any of the given extensions.
|
||||
* @param file
|
||||
* File whose name to look at
|
||||
* @param extensions
|
||||
* Extensions to consider (just the extension, without the
|
||||
* dot). Should all be lowercase, case insensitive matching
|
||||
* is used.
|
||||
*/
|
||||
public static boolean hasExtension(File file, String... extensions) {
|
||||
return hasExtension(file, Arrays.asList(extensions));
|
||||
}
|
||||
|
||||
public static boolean hasExtension(File file, List<String> extensions) {
|
||||
String pieces[] = file.getName().split("\\.");
|
||||
if (pieces.length < 2)
|
||||
return false;
|
||||
|
||||
String extension = pieces[pieces.length - 1];
|
||||
|
||||
return extensions.contains(extension.toLowerCase());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively find all files in a folder with the specified
|
||||
* extension. Excludes hidden files and folders and
|
||||
* source control folders.
|
||||
*
|
||||
* @param folder
|
||||
* Folder to look into
|
||||
* @param recursive
|
||||
* <b>true</b> will recursively find all files in sub-folders
|
||||
* @param extensions
|
||||
* A list of file extensions to search (just the extension,
|
||||
* without the dot). Should all be lowercase, case
|
||||
* insensitive matching is used. If no extensions are
|
||||
* passed, all files are returned.
|
||||
* @return
|
||||
*/
|
||||
public static List<File> listFiles(File folder, boolean recursive,
|
||||
String... extensions) {
|
||||
return listFiles(folder, recursive, Arrays.asList(extensions));
|
||||
}
|
||||
|
||||
public static List<File> listFiles(File folder, boolean recursive,
|
||||
List<String> extensions) {
|
||||
List<File> result = new ArrayList<File>();
|
||||
|
||||
for (File file : folder.listFiles()) {
|
||||
if (isSCCSOrHiddenFile(file))
|
||||
continue;
|
||||
|
||||
if (file.isDirectory()) {
|
||||
if (recursive)
|
||||
result.addAll(listFiles(file, true, extensions));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (extensions.isEmpty() || hasExtension(file, extensions))
|
||||
result.add(file);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
28
arduino-core/src/processing/app/helpers/NetUtils.java
Normal file
28
arduino-core/src/processing/app/helpers/NetUtils.java
Normal file
@ -0,0 +1,28 @@
|
||||
package processing.app.helpers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
|
||||
public abstract class NetUtils {
|
||||
|
||||
public static boolean isReachable(InetAddress address, int port) {
|
||||
Socket socket = null;
|
||||
try {
|
||||
socket = new Socket();
|
||||
socket.connect(new InetSocketAddress(address, port), 100);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
} finally {
|
||||
if (socket != null) {
|
||||
try {
|
||||
socket.close();
|
||||
} catch (IOException e) {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29
arduino-core/src/processing/app/helpers/OSUtils.java
Normal file
29
arduino-core/src/processing/app/helpers/OSUtils.java
Normal file
@ -0,0 +1,29 @@
|
||||
package processing.app.helpers;
|
||||
|
||||
public class OSUtils {
|
||||
|
||||
/**
|
||||
* returns true if running on windows.
|
||||
*/
|
||||
static public boolean isWindows() {
|
||||
//return PApplet.platform == PConstants.WINDOWS;
|
||||
return System.getProperty("os.name").indexOf("Windows") != -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* true if running on linux.
|
||||
*/
|
||||
static public boolean isLinux() {
|
||||
//return PApplet.platform == PConstants.LINUX;
|
||||
return System.getProperty("os.name").indexOf("Linux") != -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true if Processing is running on a Mac OS X machine.
|
||||
*/
|
||||
static public boolean isMacOS() {
|
||||
//return PApplet.platform == PConstants.MACOSX;
|
||||
return System.getProperty("os.name").indexOf("Mac") != -1;
|
||||
}
|
||||
|
||||
}
|
103
arduino-core/src/processing/app/helpers/PreferencesHelper.java
Normal file
103
arduino-core/src/processing/app/helpers/PreferencesHelper.java
Normal file
@ -0,0 +1,103 @@
|
||||
package processing.app.helpers;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
|
||||
public abstract class PreferencesHelper {
|
||||
|
||||
// /**
|
||||
// * Create a Color with the value of the specified key. The format of the color
|
||||
// * should be an hexadecimal number of 6 digit, eventually prefixed with a '#'.
|
||||
// *
|
||||
// * @param name
|
||||
// * @return A Color object or <b>null</b> if the key is not found or the format
|
||||
// * is wrong
|
||||
// */
|
||||
// static public Color getColor(PreferencesMap prefs, String name) {
|
||||
// Color parsed = parseColor(prefs.get(name));
|
||||
// if (parsed != null)
|
||||
// return parsed;
|
||||
// return Color.GRAY; // set a default
|
||||
// }
|
||||
//
|
||||
//
|
||||
// static public void setColor(PreferencesMap prefs, String attr, Color what) {
|
||||
// putColor(prefs, attr, what);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// static public Font getFontWithDefault(PreferencesMap prefs, PreferencesMap defaults, String attr) {
|
||||
// Font font = getFont(prefs, attr);
|
||||
// if (font == null) {
|
||||
// String value = defaults.get(attr);
|
||||
// prefs.put(attr, value);
|
||||
// font = getFont(prefs, attr);
|
||||
// }
|
||||
// return font;
|
||||
// }
|
||||
//
|
||||
// static public SyntaxStyle getStyle(PreferencesMap prefs, String what) {
|
||||
// String str = prefs.get("editor." + what + ".style");
|
||||
//
|
||||
// StringTokenizer st = new StringTokenizer(str, ",");
|
||||
//
|
||||
// String s = st.nextToken();
|
||||
// if (s.indexOf("#") == 0) s = s.substring(1);
|
||||
// Color color = Color.DARK_GRAY;
|
||||
// try {
|
||||
// color = new Color(Integer.parseInt(s, 16));
|
||||
// } catch (Exception e) { }
|
||||
//
|
||||
// s = st.nextToken();
|
||||
// boolean bold = (s.indexOf("bold") != -1);
|
||||
// boolean italic = (s.indexOf("italic") != -1);
|
||||
// boolean underlined = (s.indexOf("underlined") != -1);
|
||||
//
|
||||
// return new SyntaxStyle(color, italic, bold, underlined);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Set the value of the specified key based on the Color passed as parameter.
|
||||
*
|
||||
* @param attr
|
||||
* @param color
|
||||
*/
|
||||
public static void putColor(PreferencesMap prefs, String attr, Color color) {
|
||||
prefs.put(attr, "#" + String.format("%06x", color.getRGB() & 0xffffff));
|
||||
}
|
||||
|
||||
public static Color parseColor(String v) {
|
||||
try {
|
||||
if (v.indexOf("#") == 0)
|
||||
v = v.substring(1);
|
||||
return new Color(Integer.parseInt(v, 16));
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Font getFont(PreferencesMap prefs, String key) {
|
||||
String value = prefs.get(key);
|
||||
if (value == null)
|
||||
return null;
|
||||
String[] split = value.split(",");
|
||||
if (split.length != 3)
|
||||
return null;
|
||||
|
||||
String name = split[0];
|
||||
int style = Font.PLAIN;
|
||||
if (split[1].contains("bold"))
|
||||
style |= Font.BOLD;
|
||||
if (split[1].contains("italic"))
|
||||
style |= Font.ITALIC;
|
||||
int size;
|
||||
try {
|
||||
// ParseDouble handle numbers with decimals too
|
||||
size = (int) Double.parseDouble(split[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
// for wrong formatted size pick the default
|
||||
size = 12;
|
||||
}
|
||||
return new Font(name, style, size);
|
||||
}
|
||||
}
|
322
arduino-core/src/processing/app/helpers/PreferencesMap.java
Normal file
322
arduino-core/src/processing/app/helpers/PreferencesMap.java
Normal file
@ -0,0 +1,322 @@
|
||||
/*
|
||||
PreferencesMap - A Map<String, String> with some useful features
|
||||
to handle preferences.
|
||||
Part of the Arduino project - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2014 Cristian Maglie
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
package processing.app.helpers;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import processing.app.legacy.PApplet;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class PreferencesMap extends LinkedHashMap<String, String> {
|
||||
|
||||
public PreferencesMap(Map<String, String> table) {
|
||||
super(table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a PreferencesMap and load the content of the file passed as
|
||||
* argument.
|
||||
*
|
||||
* Is equivalent to:
|
||||
*
|
||||
* <pre>
|
||||
* PreferencesMap map = new PreferencesMap();
|
||||
* map.load(file);
|
||||
* </pre>
|
||||
*
|
||||
* @param file
|
||||
* @throws IOException
|
||||
*/
|
||||
public PreferencesMap(File file) throws IOException {
|
||||
super();
|
||||
load(file);
|
||||
}
|
||||
|
||||
public PreferencesMap() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a property list file and put kev/value pairs into the Map
|
||||
*
|
||||
* @param file
|
||||
* @throws FileNotFoundException
|
||||
* @throws IOException
|
||||
*/
|
||||
public void load(File file) throws IOException {
|
||||
load(new FileInputStream(file));
|
||||
}
|
||||
|
||||
protected String processPlatformSuffix(String key, String suffix, boolean isCurrentPlatform) {
|
||||
if (key == null)
|
||||
return null;
|
||||
// Key does not end with the given suffix? Process as normal
|
||||
if (!key.endsWith(suffix))
|
||||
return key;
|
||||
// Not the current platform? Ignore this key
|
||||
if (!isCurrentPlatform)
|
||||
return null;
|
||||
// Strip the suffix from the key
|
||||
return key.substring(0, key.length() - suffix.length());
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a property list stream and put key/value pairs into the Map
|
||||
*
|
||||
* @param input
|
||||
* @throws IOException
|
||||
*/
|
||||
public void load(InputStream input) throws IOException {
|
||||
String[] lines = PApplet.loadStrings(input);
|
||||
for (String line : lines) {
|
||||
if (line.length() == 0 || line.charAt(0) == '#')
|
||||
continue;
|
||||
|
||||
int equals = line.indexOf('=');
|
||||
if (equals != -1) {
|
||||
String key = line.substring(0, equals).trim();
|
||||
String value = line.substring(equals + 1).trim();
|
||||
|
||||
key = processPlatformSuffix(key, ".linux", OSUtils.isLinux());
|
||||
key = processPlatformSuffix(key, ".windows", OSUtils.isWindows());
|
||||
key = processPlatformSuffix(key, ".macosx", OSUtils.isMacOS());
|
||||
|
||||
if (key != null)
|
||||
put(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new PreferenceMap that contains all the top level pairs of the
|
||||
* current mapping. E.g. the folowing mapping:<br />
|
||||
*
|
||||
* <pre>
|
||||
* Map (
|
||||
* alpha = Alpha
|
||||
* alpha.some.keys = v1
|
||||
* alpha.other.keys = v2
|
||||
* beta = Beta
|
||||
* beta.some.keys = v3
|
||||
* )
|
||||
* </pre>
|
||||
*
|
||||
* will generate the following result:
|
||||
*
|
||||
* <pre>
|
||||
* Map (
|
||||
* alpha = Alpha
|
||||
* beta = Beta
|
||||
* )
|
||||
* </pre>
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public PreferencesMap topLevelMap() {
|
||||
PreferencesMap res = new PreferencesMap();
|
||||
for (String key : keySet()) {
|
||||
if (key.contains("."))
|
||||
continue;
|
||||
res.put(key, get(key));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Map<String, PreferenceMap> where keys are the first level of
|
||||
* the current mapping. Top level pairs are discarded. E.g. the folowing
|
||||
* mapping:<br />
|
||||
*
|
||||
* <pre>
|
||||
* Map (
|
||||
* alpha = Alpha
|
||||
* alpha.some.keys = v1
|
||||
* alpha.other.keys = v2
|
||||
* beta = Beta
|
||||
* beta.some.keys = v3
|
||||
* )
|
||||
* </pre>
|
||||
*
|
||||
* will generate the following result:
|
||||
*
|
||||
* <pre>
|
||||
* alpha = Map(
|
||||
* some.keys = v1
|
||||
* other.keys = v2
|
||||
* )
|
||||
* beta = Map(
|
||||
* some.keys = v3
|
||||
* )
|
||||
* </pre>
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, PreferencesMap> firstLevelMap() {
|
||||
Map<String, PreferencesMap> res = new LinkedHashMap<String, PreferencesMap>();
|
||||
for (String key : keySet()) {
|
||||
int dot = key.indexOf('.');
|
||||
if (dot == -1)
|
||||
continue;
|
||||
|
||||
String parent = key.substring(0, dot);
|
||||
String child = key.substring(dot + 1);
|
||||
|
||||
if (!res.containsKey(parent))
|
||||
res.put(parent, new PreferencesMap());
|
||||
res.get(parent).put(child, get(key));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new PreferenceMap using a subtree of the current mapping. Top
|
||||
* level pairs are ignored. E.g. with the following mapping:<br />
|
||||
*
|
||||
* <pre>
|
||||
* Map (
|
||||
* alpha = Alpha
|
||||
* alpha.some.keys = v1
|
||||
* alpha.other.keys = v2
|
||||
* beta = Beta
|
||||
* beta.some.keys = v3
|
||||
* )
|
||||
* </pre>
|
||||
*
|
||||
* a call to createSubTree("alpha") will generate the following result:
|
||||
*
|
||||
* <pre>
|
||||
* Map(
|
||||
* some.keys = v1
|
||||
* other.keys = v2
|
||||
* )
|
||||
* </pre>
|
||||
*
|
||||
* @param parent
|
||||
* @return
|
||||
*/
|
||||
public PreferencesMap subTree(String parent) {
|
||||
PreferencesMap res = new PreferencesMap();
|
||||
parent += ".";
|
||||
int parentLen = parent.length();
|
||||
for (String key : keySet()) {
|
||||
if (key.startsWith(parent))
|
||||
res.put(key.substring(parentLen), get(key));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public String toString(String indent) {
|
||||
String res = indent + "{\n";
|
||||
SortedSet<String> treeSet = new TreeSet<String>(keySet());
|
||||
for (String k : treeSet)
|
||||
res += indent + k + " = " + get(k) + "\n";
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value to which the specified key is mapped, or throws a
|
||||
* PreferencesMapException if not found
|
||||
*
|
||||
* @param k
|
||||
* the key whose associated value is to be returned
|
||||
* @return the value to which the specified key is mapped
|
||||
* @throws PreferencesMapException
|
||||
*/
|
||||
public String getOrExcept(String k) throws PreferencesMapException {
|
||||
String r = get(k);
|
||||
if (r == null)
|
||||
throw new PreferencesMapException(k);
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toString("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new File instance by converting the value of the key into an
|
||||
* abstract pathname. If the the given key doesn't exists or his value is the
|
||||
* empty string, the result is <b>null</b>.
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public File getFile(String key) {
|
||||
if (!containsKey(key))
|
||||
return null;
|
||||
String path = get(key).trim();
|
||||
if (path.length() == 0)
|
||||
return null;
|
||||
return new File(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new File instance by converting the value of the key into an
|
||||
* abstract pathname with the specified sub folder. If the the given key
|
||||
* doesn't exists or his value is the empty string, the result is <b>null</b>.
|
||||
*
|
||||
* @param key
|
||||
* @param subFolder
|
||||
* @return
|
||||
*/
|
||||
public File getFile(String key, String subFolder) {
|
||||
File file = getFile(key);
|
||||
if (file == null)
|
||||
return null;
|
||||
return new File(file, subFolder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of the specified key as boolean.
|
||||
*
|
||||
* @param key
|
||||
* @return <b>true</b> if the value of the key is the string "true" (case
|
||||
* insensitive compared), <b>false</b> in any other case
|
||||
*/
|
||||
public boolean getBoolean(String key) {
|
||||
return new Boolean(get(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the specified key to the string <b>"true"</b> or
|
||||
* <b>"false"</b> based on value of the boolean parameter
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return <b>true</b> if the previous value of the key was the string "true"
|
||||
* (case insensitive compared), <b>false</b> in any other case
|
||||
*/
|
||||
public boolean putBoolean(String key, boolean value) {
|
||||
String prev = put(key, value ? "true" : "false");
|
||||
return new Boolean(prev);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package processing.app.helpers;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class PreferencesMapException extends Exception {
|
||||
|
||||
public PreferencesMapException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
28
arduino-core/src/processing/app/helpers/ProcessUtils.java
Normal file
28
arduino-core/src/processing/app/helpers/ProcessUtils.java
Normal file
@ -0,0 +1,28 @@
|
||||
package processing.app.helpers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
public class ProcessUtils {
|
||||
|
||||
public static Process exec(String[] command) throws IOException {
|
||||
// No problems on linux and mac
|
||||
if (!OSUtils.isWindows()) {
|
||||
return Runtime.getRuntime().exec(command);
|
||||
}
|
||||
|
||||
// Brutal hack to workaround windows command line parsing.
|
||||
// http://stackoverflow.com/questions/5969724/java-runtime-exec-fails-to-escape-characters-properly
|
||||
// http://msdn.microsoft.com/en-us/library/a1y7w461.aspx
|
||||
// http://bugs.sun.com/view_bug.do?bug_id=6468220
|
||||
// http://bugs.sun.com/view_bug.do?bug_id=6518827
|
||||
String[] cmdLine = new String[command.length];
|
||||
for (int i = 0; i < command.length; i++)
|
||||
cmdLine[i] = command[i].replace("\"", "\\\"");
|
||||
|
||||
ProcessBuilder pb = new ProcessBuilder(cmdLine);
|
||||
Map<String, String> env = pb.environment();
|
||||
env.put("CYGWIN", "nodosfilewarning");
|
||||
return pb.start();
|
||||
}
|
||||
}
|
102
arduino-core/src/processing/app/helpers/StringReplacer.java
Normal file
102
arduino-core/src/processing/app/helpers/StringReplacer.java
Normal file
@ -0,0 +1,102 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
StringReplacer - Utility class for expression formatting
|
||||
Part of the Arduino project - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2011 Cristian Maglie
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
package processing.app.helpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class StringReplacer {
|
||||
|
||||
public static String[] formatAndSplit(String src, Map<String, String> dict,
|
||||
boolean recursive) throws Exception {
|
||||
String res;
|
||||
|
||||
// Recursive replace with a max depth of 10 levels.
|
||||
for (int i = 0; i < 10; i++) {
|
||||
// Do a replace with dictionary
|
||||
res = StringReplacer.replaceFromMapping(src, dict);
|
||||
if (!recursive)
|
||||
break;
|
||||
if (res.equals(src))
|
||||
break;
|
||||
src = res;
|
||||
}
|
||||
|
||||
// Split the resulting string in arguments
|
||||
return quotedSplit(src, "\"'", false);
|
||||
}
|
||||
|
||||
public static String[] quotedSplit(String src, String quoteChars,
|
||||
boolean acceptEmptyArguments)
|
||||
throws Exception {
|
||||
List<String> res = new ArrayList<String>();
|
||||
String escapedArg = null;
|
||||
String escapingChar = null;
|
||||
for (String i : src.split(" ")) {
|
||||
if (escapingChar == null) {
|
||||
// If the first char is not an escape char..
|
||||
String first = null;
|
||||
if (i.length() > 0)
|
||||
first = i.substring(0, 1);
|
||||
if (first == null || !quoteChars.contains(first)) {
|
||||
if (i.trim().length() != 0 || acceptEmptyArguments)
|
||||
res.add(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
escapingChar = first;
|
||||
i = i.substring(1);
|
||||
escapedArg = "";
|
||||
}
|
||||
|
||||
if (!i.endsWith(escapingChar)) {
|
||||
escapedArg += i + " ";
|
||||
continue;
|
||||
}
|
||||
|
||||
escapedArg += i.substring(0, i.length() - 1);
|
||||
if (escapedArg.trim().length() != 0 || acceptEmptyArguments)
|
||||
res.add(escapedArg);
|
||||
escapingChar = null;
|
||||
}
|
||||
if (escapingChar != null)
|
||||
throw new Exception("Invalid quoting: no closing [" + escapingChar +
|
||||
"] char found.");
|
||||
return res.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public static String replaceFromMapping(String src, Map<String, String> map) {
|
||||
return replaceFromMapping(src, map, "{", "}");
|
||||
}
|
||||
|
||||
public static String replaceFromMapping(String src, Map<String, String> map,
|
||||
String leftDelimiter,
|
||||
String rightDelimiter) {
|
||||
for (String k : map.keySet()) {
|
||||
String keyword = leftDelimiter + k + rightDelimiter;
|
||||
src = src.replace(keyword, map.get(k));
|
||||
}
|
||||
return src;
|
||||
}
|
||||
|
||||
}
|
29
arduino-core/src/processing/app/helpers/StringUtils.java
Normal file
29
arduino-core/src/processing/app/helpers/StringUtils.java
Normal file
@ -0,0 +1,29 @@
|
||||
package processing.app.helpers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class StringUtils {
|
||||
|
||||
public static boolean stringContainsOneOf(String input, List<String> listOfStrings) {
|
||||
for (String string : listOfStrings) {
|
||||
if (input.contains(string)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to match <b>input</b> with <b>pattern</b>. The pattern can use the
|
||||
* "*" and "?" globs to match any-char-sequence and any-char respectively.
|
||||
*
|
||||
* @param input The string to be checked
|
||||
* @param pattern The pattern to match
|
||||
* @return <b>true</b> if the <b>input</b> matches the <b>pattern</b>,
|
||||
* <b>false</b> otherwise.
|
||||
*/
|
||||
public static boolean wildcardMatch(String input, String pattern) {
|
||||
String regex = pattern.replace("?", ".?").replace("*", ".*?");
|
||||
return input.matches(regex);
|
||||
}
|
||||
}
|
19
arduino-core/src/processing/app/helpers/UserNotifier.java
Normal file
19
arduino-core/src/processing/app/helpers/UserNotifier.java
Normal file
@ -0,0 +1,19 @@
|
||||
package processing.app.helpers;
|
||||
|
||||
public abstract class UserNotifier {
|
||||
|
||||
public void showError(String title, String message, int exit_code) {
|
||||
showError(title, message, null, exit_code);
|
||||
}
|
||||
|
||||
public void showError(String title, String message, Throwable e) {
|
||||
showError(title, message, e, 1);
|
||||
}
|
||||
|
||||
public abstract void showError(String title, String message, Throwable e, int exit_code);
|
||||
|
||||
public abstract void showMessage(String title, String message);
|
||||
|
||||
public abstract void showWarning(String title, String message, Exception e);
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
OnlyDirs - FilenameFilter that accepts only directories (CVS, .svn,
|
||||
.DS_Store files are excluded as well)
|
||||
Part of the Arduino project - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2011 Cristian Maglie
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
package processing.app.helpers.filefilters;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
|
||||
/**
|
||||
* This filter accepts only directories (excluding .DS_Store files, .svn
|
||||
* folders, etc)
|
||||
*
|
||||
* @author Cristian Maglie
|
||||
*/
|
||||
public class OnlyDirs implements FilenameFilter {
|
||||
|
||||
public boolean accept(File dir, String name) {
|
||||
if (name.charAt(0) == '.')
|
||||
return false;
|
||||
if (name.equals("CVS"))
|
||||
return false;
|
||||
return new File(dir, name).isDirectory();
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
OnlyFilesWithExtension - FilenameFilter that accepts only files with a
|
||||
specific extension.
|
||||
Part of the Arduino project - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2011 Cristian Maglie
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
package processing.app.helpers.filefilters;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
|
||||
public class OnlyFilesWithExtension implements FilenameFilter {
|
||||
|
||||
String extensions[];
|
||||
|
||||
public OnlyFilesWithExtension(String... ext) {
|
||||
extensions = ext;
|
||||
}
|
||||
|
||||
public boolean accept(File dir, String name) {
|
||||
for (String ext : extensions)
|
||||
if (name.endsWith(ext))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
49
arduino-core/src/processing/app/i18n/README.md
Normal file
49
arduino-core/src/processing/app/i18n/README.md
Normal file
@ -0,0 +1,49 @@
|
||||
# Internationalization Tools
|
||||
|
||||
by @sgk at SwitchScience.
|
||||
|
||||
## Reflect the source code change
|
||||
|
||||
Sometimes, the developers add/delete/modify the strings which should be translated. You have to reflect the source code change to your translation. This can be done as below given your language code `xx`.
|
||||
|
||||
% ./update.sh xx
|
||||
|
||||
This will extract the up-to-date set of strings from the source code, set the translated strings from the current "`Resources_xx.po`" file, and then write back to "`Resources_xx.po`" file. If the developers delete/modify the strings, corresponding translated strings disappear from the file. You may want to do like this.
|
||||
|
||||
% git commit
|
||||
% ./update.sh xx
|
||||
% git diff Resrouces_xx.po
|
||||
% git add Resources_xx.po Resources_xx.properties
|
||||
% git commit
|
||||
|
||||
## Get the translated catalog from Transifex
|
||||
|
||||
You may want to retrieve the translation contribution from Transifex. This can be done as below given your language code `xx`.
|
||||
|
||||
% ./pull.sh xx
|
||||
|
||||
Translation strings for only strings already in "`Resources_xx.po`" file will be updated. If Transifex has translated strings which are not in "`Resources_xx.po`" file, the strings will not appear in the file.
|
||||
|
||||
If you want to retrieve the newly translated language which is not in the Git repository, you will want to do like this.
|
||||
|
||||
% cp Resources_en.po Resources_xx.po
|
||||
% ./pull.sh xx
|
||||
% more Resources_xx.po
|
||||
% git add Resources_xx.po Resources_xx.properties
|
||||
% git commit
|
||||
|
||||
## Send the translated catalog to Transifex
|
||||
|
||||
You can send the translated catalog file "`Resources_xx.po`" to Transifex using the following command line where `xx` is the language code.
|
||||
|
||||
% ./push.sh xx
|
||||
|
||||
Be aware that this will overwrite the current result on Transifex. You may want to do "./update.sh" and "./pull.sh" before doing "./push.sh".
|
||||
|
||||
## Select "all" languages
|
||||
|
||||
**For the comitter only.** For all above scripts, you can select all languages by specifying "-a" instead of language codes like this.
|
||||
|
||||
% ./update.sh -a
|
||||
|
||||
The "all" means all the languages currently in your working directory. This does not mean the languages on Transifex.
|
1875
arduino-core/src/processing/app/i18n/Resources_an.po
Normal file
1875
arduino-core/src/processing/app/i18n/Resources_an.po
Normal file
File diff suppressed because it is too large
Load Diff
1299
arduino-core/src/processing/app/i18n/Resources_an.properties
Normal file
1299
arduino-core/src/processing/app/i18n/Resources_an.properties
Normal file
File diff suppressed because it is too large
Load Diff
1878
arduino-core/src/processing/app/i18n/Resources_ar.po
Normal file
1878
arduino-core/src/processing/app/i18n/Resources_ar.po
Normal file
File diff suppressed because it is too large
Load Diff
1302
arduino-core/src/processing/app/i18n/Resources_ar.properties
Normal file
1302
arduino-core/src/processing/app/i18n/Resources_ar.properties
Normal file
File diff suppressed because it is too large
Load Diff
1875
arduino-core/src/processing/app/i18n/Resources_ast.po
Normal file
1875
arduino-core/src/processing/app/i18n/Resources_ast.po
Normal file
File diff suppressed because it is too large
Load Diff
1299
arduino-core/src/processing/app/i18n/Resources_ast.properties
Normal file
1299
arduino-core/src/processing/app/i18n/Resources_ast.properties
Normal file
File diff suppressed because it is too large
Load Diff
1875
arduino-core/src/processing/app/i18n/Resources_be.po
Normal file
1875
arduino-core/src/processing/app/i18n/Resources_be.po
Normal file
File diff suppressed because it is too large
Load Diff
1299
arduino-core/src/processing/app/i18n/Resources_be.properties
Normal file
1299
arduino-core/src/processing/app/i18n/Resources_be.properties
Normal file
File diff suppressed because it is too large
Load Diff
1876
arduino-core/src/processing/app/i18n/Resources_bg.po
Normal file
1876
arduino-core/src/processing/app/i18n/Resources_bg.po
Normal file
File diff suppressed because it is too large
Load Diff
1300
arduino-core/src/processing/app/i18n/Resources_bg.properties
Normal file
1300
arduino-core/src/processing/app/i18n/Resources_bg.properties
Normal file
File diff suppressed because it is too large
Load Diff
1875
arduino-core/src/processing/app/i18n/Resources_bs.po
Normal file
1875
arduino-core/src/processing/app/i18n/Resources_bs.po
Normal file
File diff suppressed because it is too large
Load Diff
1299
arduino-core/src/processing/app/i18n/Resources_bs.properties
Normal file
1299
arduino-core/src/processing/app/i18n/Resources_bs.properties
Normal file
File diff suppressed because it is too large
Load Diff
1876
arduino-core/src/processing/app/i18n/Resources_ca.po
Normal file
1876
arduino-core/src/processing/app/i18n/Resources_ca.po
Normal file
File diff suppressed because it is too large
Load Diff
1300
arduino-core/src/processing/app/i18n/Resources_ca.properties
Normal file
1300
arduino-core/src/processing/app/i18n/Resources_ca.properties
Normal file
File diff suppressed because it is too large
Load Diff
1878
arduino-core/src/processing/app/i18n/Resources_cs_CZ.po
Normal file
1878
arduino-core/src/processing/app/i18n/Resources_cs_CZ.po
Normal file
File diff suppressed because it is too large
Load Diff
1302
arduino-core/src/processing/app/i18n/Resources_cs_CZ.properties
Normal file
1302
arduino-core/src/processing/app/i18n/Resources_cs_CZ.properties
Normal file
File diff suppressed because it is too large
Load Diff
1875
arduino-core/src/processing/app/i18n/Resources_da_DK.po
Normal file
1875
arduino-core/src/processing/app/i18n/Resources_da_DK.po
Normal file
File diff suppressed because it is too large
Load Diff
1299
arduino-core/src/processing/app/i18n/Resources_da_DK.properties
Normal file
1299
arduino-core/src/processing/app/i18n/Resources_da_DK.properties
Normal file
File diff suppressed because it is too large
Load Diff
1876
arduino-core/src/processing/app/i18n/Resources_de_DE.po
Normal file
1876
arduino-core/src/processing/app/i18n/Resources_de_DE.po
Normal file
File diff suppressed because it is too large
Load Diff
1300
arduino-core/src/processing/app/i18n/Resources_de_DE.properties
Normal file
1300
arduino-core/src/processing/app/i18n/Resources_de_DE.properties
Normal file
File diff suppressed because it is too large
Load Diff
1876
arduino-core/src/processing/app/i18n/Resources_el_GR.po
Normal file
1876
arduino-core/src/processing/app/i18n/Resources_el_GR.po
Normal file
File diff suppressed because it is too large
Load Diff
1300
arduino-core/src/processing/app/i18n/Resources_el_GR.properties
Normal file
1300
arduino-core/src/processing/app/i18n/Resources_el_GR.properties
Normal file
File diff suppressed because it is too large
Load Diff
1996
arduino-core/src/processing/app/i18n/Resources_en.po
Normal file
1996
arduino-core/src/processing/app/i18n/Resources_en.po
Normal file
File diff suppressed because it is too large
Load Diff
1389
arduino-core/src/processing/app/i18n/Resources_en.properties
Normal file
1389
arduino-core/src/processing/app/i18n/Resources_en.properties
Normal file
File diff suppressed because it is too large
Load Diff
1875
arduino-core/src/processing/app/i18n/Resources_en_GB.po
Normal file
1875
arduino-core/src/processing/app/i18n/Resources_en_GB.po
Normal file
File diff suppressed because it is too large
Load Diff
1299
arduino-core/src/processing/app/i18n/Resources_en_GB.properties
Normal file
1299
arduino-core/src/processing/app/i18n/Resources_en_GB.properties
Normal file
File diff suppressed because it is too large
Load Diff
1877
arduino-core/src/processing/app/i18n/Resources_es.po
Normal file
1877
arduino-core/src/processing/app/i18n/Resources_es.po
Normal file
File diff suppressed because it is too large
Load Diff
1301
arduino-core/src/processing/app/i18n/Resources_es.properties
Normal file
1301
arduino-core/src/processing/app/i18n/Resources_es.properties
Normal file
File diff suppressed because it is too large
Load Diff
1874
arduino-core/src/processing/app/i18n/Resources_et.po
Normal file
1874
arduino-core/src/processing/app/i18n/Resources_et.po
Normal file
File diff suppressed because it is too large
Load Diff
1298
arduino-core/src/processing/app/i18n/Resources_et.properties
Normal file
1298
arduino-core/src/processing/app/i18n/Resources_et.properties
Normal file
File diff suppressed because it is too large
Load Diff
1875
arduino-core/src/processing/app/i18n/Resources_et_EE.po
Normal file
1875
arduino-core/src/processing/app/i18n/Resources_et_EE.po
Normal file
File diff suppressed because it is too large
Load Diff
1299
arduino-core/src/processing/app/i18n/Resources_et_EE.properties
Normal file
1299
arduino-core/src/processing/app/i18n/Resources_et_EE.properties
Normal file
File diff suppressed because it is too large
Load Diff
1875
arduino-core/src/processing/app/i18n/Resources_fa.po
Normal file
1875
arduino-core/src/processing/app/i18n/Resources_fa.po
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user