Two way communcation with the serial port

From Rxtx

(Difference between revisions)
Jump to: navigation, search
(revert spam)
Line 1: Line 1:
-
[http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=99 jazz ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=84 cheap diethylpropion] [http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=23 phentermine online] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=185 hydrocodone online] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=238 free sharp ringtones] [http://library.cshl.edu/wp/vb/member.php?u=1385 sony ericsson ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=173 free cool ringtones] [http://www.aswsu-ddp.wsu.edu/toast/forums.asp?sub=show&action=posts&fid=3&tid=810 order flexeril] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=176 didrex online] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30335 free nextel ringtones] [http://students.hsc.unt.edu/housing/item.cfm?type=2896 buy zyban] [http://www.aswsu-ddp.wsu.edu/toast/forums.asp?sub=show&action=posts&fid=3&tid=841 ericsson ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=91 hoodia online] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3720 tracfone ringtones] [http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=91 cool ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=199 free music ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=172 clonazepam] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3750 cheap didrex] [http://www.aswsu-ddp.wsu.edu/toast/forums.asp?sub=show&action=posts&fid=3&tid=789 ultracet] [http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=57 cheap celexa] [http://wc1.worldcrossing.com/WebX/.1de60a1e order flexeril] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/sagemringtones_756.htm sagem ringtones] [http://students.hsc.unt.edu/housing/item.cfm?type=2899 free tracfone ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=148 cheap zyban] [http://students.hsc.unt.edu/housing/item.cfm?type=2888 lortab online] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3749 cheap ultracet] [http://wc1.worldcrossing.com/WebX/.1de609f0 cheap lorazepam] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3753 zoloft online] [http://www.aswsu-ddp.wsu.edu/toast/forums.asp?sub=show&action=posts&fid=3&tid=788 nexium online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=145 cheap xenical] [http://students.hsc.unt.edu/housing/item.cfm?type=2897 free nokia ringtones] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/monoringtones_7654.htm mono ringtones] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/nextelringtones_3485.htm free nextel ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3723 free motorola ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=192 cheap lortab] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/diazepam_558.htm diazepam online] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=218 qwest ringtones] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/tramadol_3245.htm tramadol online] [http://www4.nau.edu/fera/index.asp?sub=show&action=posts&fid=4&tid=49 cheap levitra] [http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=52 clomid online] [http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=39 buy levitra] [http://www.aswsu-ddp.wsu.edu/toast/forums.asp?sub=show&action=posts&fid=3&tid=823 sprint ringtones] [http://wc1.worldcrossing.com/WebX/.1de609fd punk ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3709 order prozac] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3707 cheap nexium] [http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=61 lortab online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=87 online flexeril] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=72 ambien online] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3762 free funny ringtones] [http://students.hsc.unt.edu/housing/item.cfm?type=2893 hgh online] [http://kc.vanderbilt.edu/forums/toast.asp?sub=show&action=posts&fid=5&tid=110 free polyphonic ringtones] [http://students.hsc.unt.edu/housing/item.cfm?type=2891 diethylpropion online] [http://www.aswsu-ddp.wsu.edu/toast/forums.asp?sub=show&action=posts&fid=3&tid=775 adipex online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=128 sony ericsson ringtones] [http://www4.nau.edu/fera/index.asp?sub=show&action=posts&fid=4&tid=40 buy ativan] [http://students.hsc.unt.edu/housing/item.cfm?type=2912 free sagem ringtones] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/meridia_7674.htm cheap meridia] [http://www4.nau.edu/fera/index.asp?sub=show&action=posts&fid=4&tid=77 flexeril] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=79 clonazepam online] [http://students.hsc.unt.edu/housing/item.cfm?type=2894 flexeril online] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/ultracet_2738.htm ultracet online] [http://www4.nau.edu/fera/index.asp?sub=show&action=posts&fid=4&tid=74 buy diethylpropion] [http://kc.vanderbilt.edu/forums/toast.asp?sub=show&action=posts&fid=5&tid=125 free mtv ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=220 free real ringtones] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30297 cheap albuterol] [http://wc1.worldcrossing.com/WebX/.1de60a2e xanax online] [http://wc1.worldcrossing.com/WebX/.1de60a1f lisinopril online] [http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=27 ultram online] [http://www.aswsu-ddp.wsu.edu/toast/forums.asp?sub=show&action=posts&fid=3&tid=778 buy alprazolam] [http://kc.vanderbilt.edu/forums/toast.asp?sub=show&action=posts&fid=5&tid=126 free jazz ringtones] [http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=80 sprint ringtones] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30242 fioricet online] [http://kc.vanderbilt.edu/forums/toast.asp?sub=show&action=posts&fid=5&tid=116 free alltel ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3763 nextel ringtones] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30294 cheap prozac] [http://www.aswsu-ddp.wsu.edu/toast/forums.asp?sub=show&action=posts&fid=3&tid=812 zyban] [http://www.aswsu-ddp.wsu.edu/toast/forums.asp?sub=show&action=posts&fid=3&tid=782 hydrocodone online] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3747 online xenical] [http://library.cshl.edu/wp/vb/member.php?u=1353 vicodin online] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/soma_9880.htm cheap soma] [http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=58 buy tenuate] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/motorolaringtones_6710.htm motorola ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=116 polyphonic ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=112 cheap ortho] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3752 albuterol online] [http://www4.nau.edu/fera/index.asp?sub=show&action=posts&fid=4&tid=59 cheap prozac] [http://kc.vanderbilt.edu/forums/toast.asp?sub=show&action=posts&fid=5&tid=64 but clonazepam] [http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=73 free funny ringtones] [http://www4.nau.edu/fera/index.asp?sub=show&action=posts&fid=4&tid=85 free nextel ringtones] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/samsungringtones_6859.htm free samsung ringtones] [http://www.aswsu-ddp.wsu.edu/toast/forums.asp?sub=show&action=posts&fid=3&tid=815 tracfone ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=183 cheap hgh] [http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=43 xenical online] [http://library.cshl.edu/wp/vb/member.php?u=1388 cheap fioricet] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=223 cheap wellbutrin] [http://students.hsc.unt.edu/housing/item.cfm?type=2883 lipitor online] [http://library.cshl.edu/wp/vb/member.php?u=1349 cheap viagra] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/valium_6454.htm valium online] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3757 zanaflex online] [http://www4.nau.edu/fera/index.asp?sub=show&action=posts&fid=4&tid=90 sprint ringtones] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/nokiaringtones_9955.htm free nokia ringtones] [http://www4.nau.edu/fera/index.asp?sub=show&action=posts&fid=4&tid=93 polyphonic ringtones] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30330 free nokia ringtones] [http://students.hsc.unt.edu/housing/item.cfm?type=2922 free kyocera ringtones] [http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=49 didrex] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3727 cingular ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a2d cheap valium] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30336 free qwest ringtones] [http://library.cshl.edu/wp/vb/member.php?u=1343 carisoprodol online] [http://kc.vanderbilt.edu/forums/toast.asp?sub=show&action=posts&fid=5&tid=107 sprint ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=125 sharp ringtones] [http://www4.nau.edu/fera/index.asp?sub=show&action=posts&fid=4&tid=55 cyclobenzaprine online] [http://students.hsc.unt.edu/housing/item.cfm?type=2885 tenuate online] [http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=64 order diethylpropion] [http://kc.vanderbilt.edu/forums/toast.asp?sub=show&action=posts&fid=5&tid=92 cheap rivotril] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=224 free sagem ringtones] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/ultram_4782.htm ultram online] [http://www.aswsu-ddp.wsu.edu/toast/forums.asp?sub=show&action=posts&fid=3&tid=832 mono ringtones] [http://www4.nau.edu/fera/index.asp?sub=show&action=posts&fid=4&tid=68 buy tenuate] [http://www4.nau.edu/fera/index.asp?sub=show&action=posts&fid=4&tid=89 free samsung ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3758 rivotril online] [http://library.cshl.edu/wp/vb/member.php?u=1373 free nextel ringtones] [http://students.hsc.unt.edu/housing/item.cfm?type=2879 clomid online] [http://kc.vanderbilt.edu/forums/toast.asp?sub=show&action=posts&fid=5&tid=57 ativan online] [http://students.hsc.unt.edu/housing/item.cfm?type=2847 tramadol online] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/didrex_2512.htm cheap didrex] [http://wc1.worldcrossing.com/WebX/.1de60a05 free sprint ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a2b but ultracet] [http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=20 cheap tramadol] [http://library.cshl.edu/wp/vb/member.php?u=1366 propecia online] [http://kc.vanderbilt.edu/forums/toast.asp?sub=show&action=posts&fid=5&tid=119 sharp ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=235 tenuate online] [http://www4.nau.edu/fera/index.asp?sub=show&action=posts&fid=4&tid=30 tramadol online] [http://www4.nau.edu/fera/index.asp?sub=show&action=posts&fid=4&tid=87 free real ringtones] [http://library.cshl.edu/wp/vb/member.php?u=1368 nokia ringtones] [http://students.hsc.unt.edu/housing/item.cfm?type=2856 cheap cialis] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/ativan_9901.htm cheap ativan] [http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=84 cingular ringtones] [http://kc.vanderbilt.edu/forums/toast.asp?sub=show&action=posts&fid=5&tid=54 buy ultram] [http://students.hsc.unt.edu/housing/item.cfm?type=2858 cheap viagra] [http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=37 clonazepam online] [http://kc.vanderbilt.edu/forums/toast.asp?sub=show&action=posts&fid=5&tid=58 viagra online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=131 sprint ringtones] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30307 zoloft online] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30317 zanaflex online] [http://www4.nau.edu/fera/index.asp?sub=show&action=posts&fid=4&tid=34 buy carisoprodol] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=202 nokia ringtones] [http://students.hsc.unt.edu/housing/item.cfm?type=2914 free sony ericsson ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=135 cheap ultracet] [http://wc1.worldcrossing.com/WebX/.1de60a25 samsung ringtones] [http://www.aswsu-ddp.wsu.edu/toast/forums.asp?sub=show&action=posts&fid=3&tid=797 zoloft online] [http://www.aswsu-ddp.wsu.edu/toast/forums.asp?sub=show&action=posts&fid=3&tid=772 ativan online] [http://wc1.worldcrossing.com/WebX/.1de60a16 levitra] [http://www.aswsu-ddp.wsu.edu/toast/forums.asp?sub=show&action=posts&fid=3&tid=819 free qwest ringtones] [http://www.aswsu-ddp.wsu.edu/toast/forums.asp?sub=show&action=posts&fid=3&tid=817 mp3 ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=124 free samsung ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3764 free real ringtones] [http://wc1.worldcrossing.com/WebX/.1de609f1 lortab online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=70 alltel ringtones] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30324 hoodia] [http://wc1.worldcrossing.com/WebX/.1de60a36 zyban online] [http://students.hsc.unt.edu/housing/item.cfm?type=2863 buy alprazolam] [http://kc.vanderbilt.edu/forums/toast.asp?sub=show&action=posts&fid=5&tid=71 cheap wellbutrin] [http://wc1.worldcrossing.com/WebX/.1de60a10 didrex online] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3768 free sagem ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=108 cheap nexium] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=191 lorazepam online] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30260 cheap clonazepam] [http://kc.vanderbilt.edu/forums/toast.asp?sub=show&action=posts&fid=5&tid=59 meridia online] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30349 free cingular ringtones] [http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=93 free midi ringtones] [http://www4.nau.edu/fera/index.asp?sub=show&action=posts&fid=4&tid=42 meridia online] [http://wc1.worldcrossing.com/WebX/.1de60a0e celexa online] [http://kc.vanderbilt.edu/forums/toast.asp?sub=show&action=posts&fid=5&tid=81 lisinopril online] [http://wc1.worldcrossing.com/WebX/.1de60a27 cheap sildenafil] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=103 mono ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3772 free midi ringtones] [http://kc.vanderbilt.edu/forums/toast.asp?sub=show&action=posts&fid=5&tid=73 nexium online] [http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=70 free nokia ringtones] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30241 buy xanax] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30283 buy didrex] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=231 rivotril online] [http://library.cshl.edu/wp/vb/member.php?u=1377 samsung ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3713 tenuate online] [http://www4.nau.edu/fera/index.asp?sub=show&action=posts&fid=4&tid=38 diazepam online] [http://kc.vanderbilt.edu/forums/toast.asp?sub=show&action=posts&fid=5&tid=91 diethylpropion] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=147 cheap zoloft] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=102 free midi ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=207 xanax online] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/propecia_2137.htm cheap propecia] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3748 cheap cyclobenzaprine] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=225 free wwe ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3722 qwest ringtones] [http://www4.nau.edu/fera/index.asp?sub=show&action=posts&fid=4&tid=91 music ringtones] [http://students.hsc.unt.edu/housing/item.cfm?type=2874 ultracet online] [http://ae.siam.edu/forums/toast.asp?sub=show&action=posts&fid=2&tid=86 sonyericsson ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3718 hoodia online] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3728 sonyericsson ringtones] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30331 free free ringtones] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30252 meridia online] Below is a simple program that shows how to open a connection to a serial device and then interact with it (receiving data and sending data). One thing to note is that the package gnu.io is used instead of javax.comm, though other than the change in package name the API follows the [http://java.sun.com/products/javacomm/ Java Communication API]. To find the names of the available ports, see the [[Discovering comm ports]] example.
+
Below is a simple program that shows how to open a connection to a serial device and then interact with it (receiving data and sending data). One thing to note is that the package gnu.io is used instead of javax.comm, though other than the change in package name the API follows the [http://java.sun.com/products/javacomm/ Java Communication API]. To find the names of the available ports, see the [[Discovering comm ports]] example.
<pre>
<pre>

Revision as of 21:30, 22 July 2007

Below is a simple program that shows how to open a connection to a serial device and then interact with it (receiving data and sending data). One thing to note is that the package gnu.io is used instead of javax.comm, though other than the change in package name the API follows the Java Communication API. To find the names of the available ports, see the Discovering comm ports example.

import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;

import java.io.FileDescriptor;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class TwoWaySerialComm
{
    public TwoWaySerialComm()
    {
        super();
    }
    
    void connect ( String portName ) throws Exception
    {
        CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName);
        if ( portIdentifier.isCurrentlyOwned() )
        {
            System.out.println("Error: Port is currently in use");
        }
        else
        {
            CommPort commPort = portIdentifier.open(this.getClass().getName(),2000);
            
            if ( commPort instanceof SerialPort )
            {
                SerialPort serialPort = (SerialPort) commPort;
                serialPort.setSerialPortParams(57600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
                
                InputStream in = serialPort.getInputStream();
                OutputStream out = serialPort.getOutputStream();
                
                (new Thread(new SerialReader(in))).start();
                (new Thread(new SerialWriter(out))).start();

            }
            else
            {
                System.out.println("Error: Only serial ports are handled by this example.");
            }
        }     
    }
    
    /** */
    public static class SerialReader implements Runnable 
    {
        InputStream in;
        
        public SerialReader ( InputStream in )
        {
            this.in = in;
        }
        
        public void run ()
        {
            byte[] buffer = new byte[1024];
            int len = -1;
            try
            {
                while ( ( len = this.in.read(buffer)) > -1 )
                {
                    System.out.print(new String(buffer,0,len));
                }
            }
            catch ( IOException e )
            {
                e.printStackTrace();
            }            
        }
    }

    /** */
    public static class SerialWriter implements Runnable 
    {
        OutputStream out;
        
        public SerialWriter ( OutputStream out )
        {
            this.out = out;
        }
        
        public void run ()
        {
            try
            {                
                int c = 0;
                while ( ( c = System.in.read()) > -1 )
                {
                    this.out.write(c);
                }                
            }
            catch ( IOException e )
            {
                e.printStackTrace();
            }            
        }
    }
    
    public static void main ( String[] args )
    {
        try
        {
            (new TwoWaySerialComm()).connect("COM3");
        }
        catch ( Exception e )
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
Personal tools