inicio repo JARduino

This commit is contained in:
jp.av.dev 2020-08-01 01:34:35 -04:00
commit 4241ee525d
13 changed files with 3160 additions and 0 deletions

8
README.md Normal file
View File

@ -0,0 +1,8 @@
## JARduino
Aplicación realizada con el fin de establecer comunicación Serial con Arduino.
De forma rápida, sin necesidad de cargar programas "pesados" o un IDE,
para realizar una simple lectura del puerto, o testear alguna respuesta del microcontrolador, etc.
`Solo funciona en Windows`
`

73
build.xml Executable file
View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="JARduino" default="default" basedir=".">
<description>Builds, tests, and runs the project JARduino.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar: JAR building
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="JARduino-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>

BIN
lib/PanamaHitek_Arduino-3.0.0.jar Executable file

Binary file not shown.

3
manifest.mf Executable file
View File

@ -0,0 +1,3 @@
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build

1768
nbproject/build-impl.xml Executable file

File diff suppressed because it is too large Load Diff

8
nbproject/genfiles.properties Executable file
View File

@ -0,0 +1,8 @@
build.xml.data.CRC32=33a6ce64
build.xml.script.CRC32=b9a6910e
build.xml.stylesheet.CRC32=f85dc8f2@1.90.1.48
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=33a6ce64
nbproject/build-impl.xml.script.CRC32=335fc85e
nbproject/build-impl.xml.stylesheet.CRC32=3a2fa800@1.90.1.48

View File

View File

@ -0,0 +1,8 @@
compile.on.save=true
do.depend=false
do.jar=true
do.jlink=false
javac.debug=true
javadoc.preview=true
jlink.strip=false
user.properties.file=/home/fuzantoko/.netbeans/10.0/build.properties

9
nbproject/private/private.xml Executable file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/media/fuzan/Biblioteca/CODE/Java/Aplicaciones_GIT/JARduino/src/javarduino/Jarduino.java</file>
</group>
</open-files>
</project-private>

93
nbproject/project.properties Executable file
View File

@ -0,0 +1,93 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=JARduino
application.vendor=fuzantoko
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.modulepath=\
${run.modulepath}
debug.test.classpath=\
${run.test.classpath}
debug.test.modulepath=\
${run.test.modulepath}
# Files in build.classes.dir which should be excluded from distribution jar
dist.archive.excludes=
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/JARduino.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.PanamaHitek_Arduino-3.0.0.jar=/home/fuzantoko/CODE/Java/Aplicaciones_GIT/JARduino/lib/PanamaHitek_Arduino-3.0.0.jar
includes=**
jar.compress=false
javac.classpath=\
${file.reference.PanamaHitek_Arduino-3.0.0.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.external.vm=true
javac.modulepath=
javac.processormodulepath=
javac.processorpath=\
${javac.classpath}
javac.source=1.8
javac.target=1.8
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.modulepath=\
${javac.modulepath}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.html5=false
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
jlink.launcher=false
jlink.launcher.name=JARduino
main.class=javarduino.Jarduino
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project.
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=
run.modulepath=\
${javac.modulepath}
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
run.test.modulepath=\
${javac.test.modulepath}
source.encoding=UTF-8
src.dir=src
test.src.dir=test

15
nbproject/project.xml Executable file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>JARduino</name>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
</test-roots>
</data>
</configuration>
</project>

452
src/javarduino/Jarduino.form Executable file
View File

@ -0,0 +1,452 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<NonVisualComponents>
<Component class="javax.swing.ButtonGroup" name="rBotones">
</Component>
<Component class="javax.swing.JComboBox" name="jComboBox1">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Menu class="javax.swing.JMenuBar" name="jMenuBar1">
<SubComponents>
<Menu class="javax.swing.JMenu" name="jMenu1">
<Properties>
<Property name="text" type="java.lang.String" value="Baudio"/>
</Properties>
<SubComponents>
<Menu class="javax.swing.JMenu" name="jMenu3">
<Properties>
<Property name="text" type="java.lang.String" value="Tasa(Rate)"/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem3">
<Properties>
<Property name="text" type="java.lang.String" value="300"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem3ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem4">
<Properties>
<Property name="text" type="java.lang.String" value="1200"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem4ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem5">
<Properties>
<Property name="text" type="java.lang.String" value="2400"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem5ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem6">
<Properties>
<Property name="text" type="java.lang.String" value="4800"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem6ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem7">
<Properties>
<Property name="text" type="java.lang.String" value="9600"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem7ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem8">
<Properties>
<Property name="text" type="java.lang.String" value="19200"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem8ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem9">
<Properties>
<Property name="text" type="java.lang.String" value="38400"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem9ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem10">
<Properties>
<Property name="text" type="java.lang.String" value="57600"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem10ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem11">
<Properties>
<Property name="text" type="java.lang.String" value="74880"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem11ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem12">
<Properties>
<Property name="text" type="java.lang.String" value="115200"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem12ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem13">
<Properties>
<Property name="text" type="java.lang.String" value="230400"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem13ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem14">
<Properties>
<Property name="text" type="java.lang.String" value="250000"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem14ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem15">
<Properties>
<Property name="text" type="java.lang.String" value="500000"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem15ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem16">
<Properties>
<Property name="text" type="java.lang.String" value="1000000"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem16ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem17">
<Properties>
<Property name="text" type="java.lang.String" value="2000000"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem17ActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Menu>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem18">
<Properties>
<Property name="text" type="java.lang.String" value="Especificar"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem18ActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Menu>
<Menu class="javax.swing.JMenu" name="jMenu2">
<Properties>
<Property name="text" type="java.lang.String" value="Ayuda"/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem1">
<Properties>
<Property name="text" type="java.lang.String" value="Ayuda"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem1ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem2">
<Properties>
<Property name="text" type="java.lang.String" value="Info"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem2ActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Menu>
</SubComponents>
</Menu>
</NonVisualComponents>
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
<Property name="title" type="java.lang.String" value="JARduino v1.0"/>
<Property name="location" type="java.awt.Point" editor="org.netbeans.beaninfo.editors.PointEditor">
<Point value="[500, 150]"/>
</Property>
<Property name="resizable" type="boolean" value="false"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="txtTX" max="32767" attributes="0"/>
<Component id="jSeparator2" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="btnConectar" min="-2" pref="126" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="btnDesconectar" min="-2" pref="127" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="cbPuertos" min="-2" pref="148" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="btnActualizar" min="-2" pref="83" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="rRX" min="-2" max="-2" attributes="0"/>
<Component id="rRXTX" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="rTX" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="jSeparator1" alignment="1" max="32767" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jScrollPane2" min="-2" pref="442" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel2" min="-2" pref="160" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="btnLimpRX" min="-2" pref="83" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="82" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="btnTX" min="-2" pref="79" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="86" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" pref="24" max="-2" attributes="0"/>
<Component id="cbPuertos" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnConectar" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnDesconectar" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="rRX" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="rTX" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="rRXTX" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="btnActualizar" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Component id="jSeparator1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnLimpRX" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jSeparator2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnTX" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="txtTX" min="-2" pref="60" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="21" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Seleciona un Puerto :"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="cbPuertos">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="modelPuertos" type="code"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="btnConectar">
<Properties>
<Property name="text" type="java.lang.String" value="Conectar"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnConectarActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnDesconectar">
<Properties>
<Property name="text" type="java.lang.String" value="Desconectar"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnDesconectarActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnActualizar">
<Properties>
<Property name="text" type="java.lang.String" value="Actualizar"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnActualizarActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JSeparator" name="jSeparator1">
</Component>
<Component class="javax.swing.JRadioButton" name="rTX">
<Properties>
<Property name="text" type="java.lang.String" value="TX"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rTXActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JRadioButton" name="rRX">
<Properties>
<Property name="text" type="java.lang.String" value="RX"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rRXActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JRadioButton" name="rRXTX">
<Properties>
<Property name="text" type="java.lang.String" value="RXTX"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rRXTXActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="Conexi&#xf3;n RX (Escuchar)"/>
</Properties>
</Component>
<Component class="javax.swing.JSeparator" name="jSeparator2">
</Component>
<Component class="javax.swing.JButton" name="btnLimpRX">
<Properties>
<Property name="text" type="java.lang.String" value="Limpiar"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnLimpRXActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" value="Conexi&#xf3;n TX (Transmitir)"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtTX">
<Properties>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtTXKeyPressed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnTX">
<Properties>
<Property name="text" type="java.lang.String" value="Enviar"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnTXActionPerformed"/>
</Events>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
<Properties>
<Property name="autoscrolls" type="boolean" value="true"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Cursor Por defecto"/>
</Property>
<Property name="debugGraphicsOptions" type="int" value="-1"/>
</Properties>
<AccessibilityProperties>
<Property name="AccessibleContext.accessibleName" type="java.lang.String" value=""/>
</AccessibilityProperties>
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTextArea" name="txtRX">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="columns" type="int" value="35"/>
<Property name="rows" type="int" value="5"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

723
src/javarduino/Jarduino.java Executable file
View File

@ -0,0 +1,723 @@
package javarduino; /** @author jp.av.dev@gmail.com */
import com.panamahitek.ArduinoException;
import javax.swing.DefaultComboBoxModel;
import com.panamahitek.PanamaHitek_Arduino;
import java.util.List;
import javax.swing.JOptionPane;
import javax.swing.text.DefaultCaret;
import jssc.SerialPortEvent;
import jssc.SerialPortEventListener;
import jssc.SerialPortException;
public class Jarduino extends javax.swing.JFrame {
private DefaultComboBoxModel modelPuertos;
private final PanamaHitek_Arduino ino = new PanamaHitek_Arduino();
String PuertoCOM;
String TipoConexion;
int baudio;
SerialPortEventListener arduinoListener;
public Jarduino() {
this.arduinoListener = (SerialPortEvent spe) -> {
try {
if (ino.isMessageAvailable()) {
txtRX.setText(txtRX.getText()+"\n"+ino.printMessage());
}
} catch (SerialPortException | ArduinoException ex) {
JOptionPane.showMessageDialog(rootPane, "Error de comunicación", "Error", 0);
}
};
setBaudio(9600);
actualizarPuertos();
initComponents();
super.setLocationRelativeTo(null);
rBotones.add(rRX);
rBotones.add(rTX);
rBotones.add(rRXTX);
rRX.setSelected(true);
TipoConexion = "RX";
// Para activar el seguimiento del texto con AutoScroll
DefaultCaret caret = (DefaultCaret) txtRX.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
}
public int getBaudio() {
return baudio;
}
private void setBaudio(int baudio) {
this.baudio = baudio;
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents//GEN-BEGIN:initComponents
private void initComponents() {
rBotones = new javax.swing.ButtonGroup();
jComboBox1 = new javax.swing.JComboBox<>();
jLabel1 = new javax.swing.JLabel();
cbPuertos = new javax.swing.JComboBox<>();
btnConectar = new javax.swing.JButton();
btnDesconectar = new javax.swing.JButton();
btnActualizar = new javax.swing.JButton();
jSeparator1 = new javax.swing.JSeparator();
rTX = new javax.swing.JRadioButton();
rRX = new javax.swing.JRadioButton();
rRXTX = new javax.swing.JRadioButton();
jLabel2 = new javax.swing.JLabel();
jSeparator2 = new javax.swing.JSeparator();
btnLimpRX = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
txtTX = new javax.swing.JTextField();
btnTX = new javax.swing.JButton();
jScrollPane2 = new javax.swing.JScrollPane();
txtRX = new javax.swing.JTextArea();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenu3 = new javax.swing.JMenu();
jMenuItem3 = new javax.swing.JMenuItem();
jMenuItem4 = new javax.swing.JMenuItem();
jMenuItem5 = new javax.swing.JMenuItem();
jMenuItem6 = new javax.swing.JMenuItem();
jMenuItem7 = new javax.swing.JMenuItem();
jMenuItem8 = new javax.swing.JMenuItem();
jMenuItem9 = new javax.swing.JMenuItem();
jMenuItem10 = new javax.swing.JMenuItem();
jMenuItem11 = new javax.swing.JMenuItem();
jMenuItem12 = new javax.swing.JMenuItem();
jMenuItem13 = new javax.swing.JMenuItem();
jMenuItem14 = new javax.swing.JMenuItem();
jMenuItem15 = new javax.swing.JMenuItem();
jMenuItem16 = new javax.swing.JMenuItem();
jMenuItem17 = new javax.swing.JMenuItem();
jMenuItem18 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("JARduino v1.0");
setLocation(new java.awt.Point(500, 150));
setResizable(false);
jLabel1.setText("Seleciona un Puerto :");
cbPuertos.setModel(modelPuertos);
btnConectar.setText("Conectar");
btnConectar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnConectarActionPerformed(evt);
}
});
btnDesconectar.setText("Desconectar");
btnDesconectar.setEnabled(false);
btnDesconectar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDesconectarActionPerformed(evt);
}
});
btnActualizar.setText("Actualizar");
btnActualizar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnActualizarActionPerformed(evt);
}
});
rTX.setText("TX");
rTX.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rTXActionPerformed(evt);
}
});
rRX.setText("RX");
rRX.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rRXActionPerformed(evt);
}
});
rRXTX.setText("RXTX");
rRXTX.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rRXTXActionPerformed(evt);
}
});
jLabel2.setText("Conexión RX (Escuchar)");
btnLimpRX.setText("Limpiar");
btnLimpRX.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnLimpRXActionPerformed(evt);
}
});
jLabel3.setText("Conexión TX (Transmitir)");
txtTX.setEnabled(false);
txtTX.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
txtTXKeyPressed(evt);
}
});
btnTX.setText("Enviar");
btnTX.setEnabled(false);
btnTX.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnTXActionPerformed(evt);
}
});
jScrollPane2.setAutoscrolls(true);
jScrollPane2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
jScrollPane2.setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION);
txtRX.setEditable(false);
txtRX.setColumns(35);
txtRX.setRows(5);
jScrollPane2.setViewportView(txtRX);
jMenu1.setText("Baudio");
jMenu3.setText("Tasa(Rate)");
jMenuItem3.setText("300");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem3);
jMenuItem4.setText("1200");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem4);
jMenuItem5.setText("2400");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem5);
jMenuItem6.setText("4800");
jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem6ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem6);
jMenuItem7.setText("9600");
jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem7ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem7);
jMenuItem8.setText("19200");
jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem8ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem8);
jMenuItem9.setText("38400");
jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem9ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem9);
jMenuItem10.setText("57600");
jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem10ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem10);
jMenuItem11.setText("74880");
jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem11ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem11);
jMenuItem12.setText("115200");
jMenuItem12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem12ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem12);
jMenuItem13.setText("230400");
jMenuItem13.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem13ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem13);
jMenuItem14.setText("250000");
jMenuItem14.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem14ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem14);
jMenuItem15.setText("500000");
jMenuItem15.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem15ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem15);
jMenuItem16.setText("1000000");
jMenuItem16.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem16ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem16);
jMenuItem17.setText("2000000");
jMenuItem17.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem17ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem17);
jMenu1.add(jMenu3);
jMenuItem18.setText("Especificar");
jMenuItem18.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem18ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem18);
jMenuBar1.add(jMenu1);
jMenu2.setText("Ayuda");
jMenuItem1.setText("Ayuda");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem1);
jMenuItem2.setText("Info");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem2);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(txtTX)
.addComponent(jSeparator2)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(btnConectar, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(btnDesconectar, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(cbPuertos, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addComponent(btnActualizar, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(rRX)
.addComponent(rRXTX)
.addComponent(rTX)))
.addComponent(jSeparator1))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 442, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnLimpRX, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(82, 82, 82))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnTX, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(86, 86, 86))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbPuertos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnConectar)
.addComponent(btnDesconectar)))
.addGroup(layout.createSequentialGroup()
.addComponent(rRX)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(rTX)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(rRXTX))
.addComponent(btnActualizar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnLimpRX)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnTX)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtTX, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(21, 21, 21))
);
jScrollPane2.getAccessibleContext().setAccessibleName("");
pack();
}// </editor-fold>//GEN-END:initComponents
private void btnConectarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConectarActionPerformed
try {
PuertoCOM = cbPuertos.getSelectedItem().toString();
conectar(TipoConexion);
super.setTitle("JARduino v1.0 ("+baudio+")");
} catch (Exception e){
JOptionPane.showMessageDialog(rootPane, "Debes seleccionar un puerto", "Puerto COM?", JOptionPane.INFORMATION_MESSAGE);
}
}//GEN-LAST:event_btnConectarActionPerformed//GEN-LAST:event_btnConectarActionPerformed
private void btnDesconectarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDesconectarActionPerformed
try {
ino.killArduinoConnection();
btnDesconectar.setEnabled(false);
btnConectar.setEnabled(true);
rRX.setEnabled(true);
rTX.setEnabled(true);
rRXTX.setEnabled(true);
cbPuertos.setEnabled(true);
//rBotones.clearSelection();
txtTX.setText("");
txtTX.setEnabled(false);
btnTX.setEnabled(false);
btnActualizar.setEnabled(true);
super.setTitle("JARduino v1.0");
} catch (ArduinoException ex) {
JOptionPane.showMessageDialog(rootPane, "Error al intentar desconectar\n¿Existen conexiones activas?", "Error", 0);
}
}//GEN-LAST:event_btnDesconectarActionPerformed
private void btnActualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnActualizarActionPerformed
actualizarPuertos();
cbPuertos.setModel(modelPuertos);
}//GEN-LAST:event_btnActualizarActionPerformed
private void rRXActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rRXActionPerformed
TipoConexion = "RX";
}//GEN-LAST:event_rRXActionPerformed
private void rTXActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rTXActionPerformed
TipoConexion = "TX";
}//GEN-LAST:event_rTXActionPerformed
private void rRXTXActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rRXTXActionPerformed
TipoConexion = "RXTX";
}//GEN-LAST:event_rRXTXActionPerformed
private void btnLimpRXActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimpRXActionPerformed
txtRX.setText("");
}//GEN-LAST:event_btnLimpRXActionPerformed
private void btnTXActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTXActionPerformed
enviar();
txtTX.requestFocus();
}//GEN-LAST:event_btnTXActionPerformed
private void txtTXKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtTXKeyPressed
if (evt.getKeyCode() == 10 ) {
enviar();
}
}//GEN-LAST:event_txtTXKeyPressed
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
JOptionPane.showMessageDialog(rootPane, "App Comunicación Serial (jp.av.dev@gmail.com)","Acerca de JARduino v1.0", -1);
}//GEN-LAST:event_jMenuItem2ActionPerformed
private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
setBaudio(2400);
}//GEN-LAST:event_jMenuItem5ActionPerformed
private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
setBaudio(9600);
}//GEN-LAST:event_jMenuItem7ActionPerformed
private void jMenuItem18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem18ActionPerformed
String baudioQ = JOptionPane.showInputDialog("Ingresar valor (Rate Baudio)");
if (baudioQ != null) {
try {
int baudioP = Integer.parseInt(baudioQ);
setBaudio(baudioP);
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(rootPane, "Debes ingresar solo números", "Error", 0);
}
}
}//GEN-LAST:event_jMenuItem18ActionPerformed
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
setBaudio(1200);
}//GEN-LAST:event_jMenuItem4ActionPerformed
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
setBaudio(300);
}//GEN-LAST:event_jMenuItem3ActionPerformed
private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
setBaudio(4800);
}//GEN-LAST:event_jMenuItem6ActionPerformed
private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
setBaudio(19200);
}//GEN-LAST:event_jMenuItem8ActionPerformed
private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
setBaudio(38400);
}//GEN-LAST:event_jMenuItem9ActionPerformed
private void jMenuItem10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem10ActionPerformed
setBaudio(57600);
}//GEN-LAST:event_jMenuItem10ActionPerformed
private void jMenuItem11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem11ActionPerformed
setBaudio(74880);
}//GEN-LAST:event_jMenuItem11ActionPerformed
private void jMenuItem12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem12ActionPerformed
setBaudio(115200);
}//GEN-LAST:event_jMenuItem12ActionPerformed
private void jMenuItem13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem13ActionPerformed
setBaudio(230400);
}//GEN-LAST:event_jMenuItem13ActionPerformed
private void jMenuItem14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem14ActionPerformed
setBaudio(250000);
}//GEN-LAST:event_jMenuItem14ActionPerformed
private void jMenuItem15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem15ActionPerformed
setBaudio(500000);
}//GEN-LAST:event_jMenuItem15ActionPerformed
private void jMenuItem16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem16ActionPerformed
setBaudio(1000000);
}//GEN-LAST:event_jMenuItem16ActionPerformed
private void jMenuItem17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem17ActionPerformed
setBaudio(2000000);
}//GEN-LAST:event_jMenuItem17ActionPerformed
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
JOptionPane.showMessageDialog(rootPane, "Para utilizar esta aplicación, debes conectar\nel microcontrolador, presionar actualizar\n y seleccionar el puerto COM correspondiente.\nSeleccionar el tipo de conexión:\nRX, para Lectura. TX, para transmisión.\nRXTX para ambas opciones.\n\nLa configuración por defecto es a 9600 baudio\nPuedes modificar el valor en el menú \"Baudio\".\nLa tasa selecionada se muestra en el título\nal iniciar la conexión.","Ayuda JARduino", JOptionPane.INFORMATION_MESSAGE);
}//GEN-LAST:event_jMenuItem1ActionPerformed
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Jarduino.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
java.awt.EventQueue.invokeLater(() -> {
new Jarduino().setVisible(true);
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables//GEN-BEGIN:variables
private javax.swing.JButton btnActualizar;
private javax.swing.JButton btnConectar;
private javax.swing.JButton btnDesconectar;
private javax.swing.JButton btnLimpRX;
private javax.swing.JButton btnTX;
private javax.swing.JComboBox<String> cbPuertos;
private javax.swing.JComboBox<String> jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem10;
private javax.swing.JMenuItem jMenuItem11;
private javax.swing.JMenuItem jMenuItem12;
private javax.swing.JMenuItem jMenuItem13;
private javax.swing.JMenuItem jMenuItem14;
private javax.swing.JMenuItem jMenuItem15;
private javax.swing.JMenuItem jMenuItem16;
private javax.swing.JMenuItem jMenuItem17;
private javax.swing.JMenuItem jMenuItem18;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JMenuItem jMenuItem6;
private javax.swing.JMenuItem jMenuItem7;
private javax.swing.JMenuItem jMenuItem8;
private javax.swing.JMenuItem jMenuItem9;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.ButtonGroup rBotones;
private javax.swing.JRadioButton rRX;
private javax.swing.JRadioButton rRXTX;
private javax.swing.JRadioButton rTX;
private javax.swing.JTextArea txtRX;
private javax.swing.JTextField txtTX;
// End of variables declaration//GEN-END:variables//GEN-END:variables
private void actualizarPuertos() {
// Creación ComboModel y carga de puertos disponibles.
modelPuertos = new DefaultComboBoxModel();
List<String> puertos = ino.getSerialPorts();
for (int i = 0; i < puertos.size(); i++) {
modelPuertos.addElement(puertos.get(i));
}
}
private void conectar(String TipoConexion) {
switch (TipoConexion) {
case "RX":
try {
ino.arduinoRX(PuertoCOM, baudio, arduinoListener);
btnDesconectar.setEnabled(true);
btnConectar.setEnabled(false);
rRX.setEnabled(false);
rTX.setEnabled(false);
rRXTX.setEnabled(false);
cbPuertos.setEnabled(false);
btnLimpRX.setEnabled(true);
txtRX.setEnabled(true);
txtRX.setText("");
btnTX.setEnabled(false);
txtTX.setEnabled(false);
btnActualizar.setEnabled(false);
} catch (ArduinoException | SerialPortException ex) {
JOptionPane.showMessageDialog(rootPane, "Error al iniciar la conexión\nPuerto: "+PuertoCOM+"\nBaudio : "+baudio);
}
break;
case "TX":
try {
ino.arduinoTX(PuertoCOM, baudio);
btnDesconectar.setEnabled(true);
btnConectar.setEnabled(false);
rRX.setEnabled(false);
rTX.setEnabled(false);
rRXTX.setEnabled(false);
cbPuertos.setEnabled(false);
btnLimpRX.setEnabled(false);
txtRX.setEnabled(false);
txtRX.setText("");
btnTX.setEnabled(true);
txtTX.setEnabled(true);
txtTX.setText("");
btnActualizar.setEnabled(false);
} catch (ArduinoException ex) {
JOptionPane.showMessageDialog(rootPane, "Error al iniciar la conexión\nPuerto: "+PuertoCOM+"\nBaudio : "+baudio);
}
break;
case "RXTX":
try {
ino.arduinoRXTX(PuertoCOM, baudio, arduinoListener);
btnDesconectar.setEnabled(true);
btnConectar.setEnabled(false);
rRX.setEnabled(false);
rTX.setEnabled(false);
rRXTX.setEnabled(false);
cbPuertos.setEnabled(false);
btnLimpRX.setEnabled(true);
txtRX.setEnabled(true);
txtRX.setText("");
btnTX.setEnabled(true);
txtTX.setEnabled(true);
txtTX.setText("");
btnActualizar.setEnabled(false);
} catch (ArduinoException ex) {
JOptionPane.showMessageDialog(rootPane, "Error al iniciar la conexión\nPuerto: "+PuertoCOM+"\nBaudio : "+baudio);
}
break;
default:
JOptionPane.showMessageDialog(rootPane, "Error al seleccionar tipo de conexión", "Error", 0);
}
}
void enviar() {
try {
ino.sendData(txtTX.getText());
txtTX.setText("");
} catch (ArduinoException | SerialPortException ex) {
JOptionPane.showMessageDialog(rootPane, "Error! No es posible conectar con Arduino", "Sin Conexión", 0);
}
}
}