~ubuntu-branches/ubuntu/edgy/rxtx/edgy-201105201527

« back to all changes in this revision

Viewing changes to src/RXTXCommDriver.java

  • Committer: Bazaar Package Importer
  • Author(s): Mario Joussen
  • Date: 2006-03-01 18:56:52 UTC
  • mfrom: (1.1.2 upstream) (2.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20060301185652-ri9941gi01goklvz
Tags: 2.1.7-2
Fixed stupid bug in clean target.
(closes: Bug#354859)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*-------------------------------------------------------------------------
2
2
|   A wrapper to convert RXTX into Linux Java Comm
3
3
|   Copyright 1998 Kevin Hester, kevinh@acm.org
4
 
|   Copyright 2000-2002 Trent Jarvi, taj@www.linux.org.uk
 
4
|   Copyright 2000-2006 Trent Jarvi, taj@www.linux.org.uk
5
5
|
6
6
|   This library is free software; you can redistribute it and/or
7
7
|   modify it under the terms of the GNU Library General Public
25
25
 
26
26
package gnu.io;
27
27
 
 
28
import java.lang.*;
28
29
import java.util.*;
29
30
import java.io.*;
30
31
import java.util.StringTokenizer;
36
37
{
37
38
 
38
39
        private final static boolean debug = false;
 
40
        private final static boolean devel = true;
39
41
 
40
42
        static
41
43
        {
53
55
                   the Library.
54
56
                */
55
57
                String JarVersion = RXTXVersion.getVersion();
56
 
                String LibVersion = nativeGetVersion();
 
58
                String LibVersion;
 
59
                try {
 
60
                        LibVersion = RXTXVersion.nativeGetVersion();
 
61
                } catch ( Error UnsatisfiedLinkError )
 
62
                {
 
63
                        // for rxtx prior to 2.1.7
 
64
                        LibVersion = nativeGetVersion();
 
65
                }
 
66
                if ( devel )
 
67
                {
 
68
                        System.out.println("Stable Library");
 
69
                        System.out.println("=========================================");
 
70
                        System.out.println("Native lib Version = " + LibVersion );
 
71
                        System.out.println("Java lib Version   = " + JarVersion );
 
72
                }
 
73
 
57
74
                if ( ! JarVersion.equals( LibVersion ) )
58
75
                {
59
76
                        System.out.println( "WARNING:  RXTX Version mismatch\n\tJar version = " + JarVersion + "\n\tnative lib Version = " + LibVersion );
67
84
        /** Get the Serial port prefixes for the running OS */
68
85
        private String deviceDirectory;
69
86
        private String osName;
70
 
        private static native String nativeGetVersion();
71
87
        private native boolean registerKnownPorts(int PortType);
72
88
        private native boolean isPortPrefixValid(String dev);
73
89
        private native boolean testRead(String dev, int type);
74
90
        private native String getDeviceDirectory();
 
91
        // for rxtx prior to 2.1.7
 
92
        public static native String nativeGetVersion();
75
93
 
76
94
        private final String[] getValidPortPrefixes(String CandidatePortPrefixes[])
77
95
        {
212
230
                                        {
213
231
                                                continue;
214
232
                                        }
215
 
                                        String PortName =
 
233
                                        String PortName;
 
234
                                        if(osName.toLowerCase().indexOf("windows") == -1 )
 
235
                                        {
 
236
                                                PortName =
216
237
                                                new String(deviceDirectory +
217
238
                                                        C );
 
239
                                        }
 
240
                                        else
 
241
                                        {
 
242
                                                PortName =
 
243
                                                new String( C );
 
244
                                        }
218
245
                                        if (debug)
219
246
                                        {
220
247
                                                System.out.println( C +
330
357
 
331
358
                     String ext_dir=System.getProperty("java.ext.dirs")+System.getProperty("file.separator");
332
359
                     FileInputStream rxtx_prop=new FileInputStream(ext_dir+"gnu.io.rxtx.properties");
333
 
                     Properties p=new Properties(System.getProperties());
 
360
                     Properties p=new Properties();
334
361
                     p.load(rxtx_prop);
335
362
                     System.setProperties(p);
 
363
                     for (Iterator it = p.keySet().iterator(); it.hasNext();) {
 
364
                          String key = (String) it.next();
 
365
                          System.setProperty(key, p.getProperty(key));
 
366
                     }
336
367
                    }catch(Exception e){
337
368
                        if (debug){
338
369
                            System.out.println("The file: gnu.io.rxtx.properties doesn't exists.");
386
417
                }
387
418
                else if(osName.toLowerCase().indexOf("windows") != -1 )
388
419
                {
389
 
                        /* //./name is supposed to work for port numbers > 8 */
 
420
                        String[] temp = new String[259];
 
421
                        for( int i = 1; i <= 256; i++ )
 
422
                        {
 
423
                                temp[i - 1] = new String( "COM" + i );
 
424
                        }
 
425
                        for( int i = 1; i <= 3; i++ )
 
426
                        {
 
427
                                temp[i + 255] = new String( "LPT" + i );
 
428
                        }
 
429
                        CandidateDeviceNames=temp;
 
430
                        }
 
431
                        else if ( osName.equals("Solaris") || osName.equals("SunOS"))
 
432
                        {
 
433
                        /* Solaris uses a few different ways to identify ports.
 
434
                           They could be /dev/term/a /dev/term0 /dev/cua/a /dev/cuaa
 
435
                           the /dev/???/a appears to be on more systems.
 
436
 
 
437
                           The uucp lock files should not cause problems.
 
438
                        */
 
439
        /*
 
440
                                File dev = new File( "/dev/term" );
 
441
                                String deva[] = dev.list();
 
442
                                dev = new File( "/dev/cua" );
 
443
                                String devb[] = dev.list();
 
444
                                String[] temp = new String[ deva.length + devb.length ];
 
445
                                for(int j =0;j<deva.length;j++)
 
446
                                        deva[j] = "term/" + deva[j];
 
447
                                for(int j =0;j<devb.length;j++)
 
448
                                        devb[j] = "cua/" + devb[j];
 
449
                                System.arraycopy( deva, 0, temp, 0, deva.length );
 
450
                                System.arraycopy( devb, 0, temp,
 
451
                                                deva.length, devb.length );
 
452
                                if( debug ) {
 
453
                                        for( int j = 0; j< temp.length;j++)
 
454
                                                System.out.println( temp[j] );
 
455
                                }
 
456
                                CandidateDeviceNames=temp;
 
457
        */
 
458
 
390
459
                        /*
391
 
                                        { "//./COM1", "//./COM2", "//./COM3",
392
 
                                        "//./COM4", "//./COM5", "//./COM6",
393
 
                                        "//./COM7", "//./COM8" };
 
460
 
 
461
                                ok..  Look the the dirctories representing the port
 
462
                                kernel driver interface.
 
463
 
 
464
                                If there are entries there are possibly ports we can
 
465
                                use and need to enumerate.
394
466
                        */
395
 
                        String[] temp =
396
 
                        { "COM1", "COM2","COM3","COM4",
397
 
                        "COM5", "COM6", "COM7", "COM8" };
398
 
                        CandidateDeviceNames=temp;
399
 
                }
400
 
                else if ( osName.equals("Solaris") || osName.equals("SunOS"))
401
 
                {
402
 
                /* Solaris uses a few different ways to identify ports.
403
 
                   They could be /dev/term/a /dev/term0 /dev/cua/a /dev/cuaa
404
 
                   the /dev/???/a appears to be on more systems.
405
 
 
406
 
                   The uucp lock files should not cause problems.
407
 
                */
408
 
/*
409
 
                        File dev = new File( "/dev/term" );
410
 
                        String deva[] = dev.list();
411
 
                        dev = new File( "/dev/cua" );
412
 
                        String devb[] = dev.list();
413
 
                        String[] temp = new String[ deva.length + devb.length ];
414
 
                        for(int j =0;j<deva.length;j++)
415
 
                                deva[j] = "term/" + deva[j];
416
 
                        for(int j =0;j<devb.length;j++)
417
 
                                devb[j] = "cua/" + devb[j];
418
 
                        System.arraycopy( deva, 0, temp, 0, deva.length );
419
 
                        System.arraycopy( devb, 0, temp,
420
 
                                        deva.length, devb.length );
421
 
                        if( debug ) {
422
 
                                for( int j = 0; j< temp.length;j++)
423
 
                                        System.out.println( temp[j] );
424
 
                        }
425
 
                        CandidateDeviceNames=temp;
426
 
*/
427
 
 
428
 
                /*
429
 
 
430
 
                        ok..  Look the the dirctories representing the port
431
 
                        kernel driver interface.
432
 
 
433
 
                        If there are entries there are possibly ports we can
434
 
                        use and need to enumerate.
435
 
                */
436
 
 
437
 
                        String term[] = new String[2];
438
 
                        int l = 0;
439
 
                        File dev = null;
440
 
 
441
 
                        dev = new File( "/dev/term" );
442
 
                        if( dev.list().length > 0 );
443
 
                                term[l++] = new String( "term/" );
444
 
/*
445
 
                        dev = new File( "/dev/cua0" );
446
 
                        if( dev.list().length > 0 );
447
 
                                term[l++] = new String( "cua/" );
448
 
*/
449
 
                        String[] temp = new String[l];
450
 
                        for(l--;l >= 0;l--)
451
 
                                temp[l] = term[l];
452
 
                        CandidateDeviceNames=temp;
453
 
                }
454
 
                else
455
 
                {
456
 
                        File dev = new File( deviceDirectory );
457
 
                        String[] temp = dev.list();
458
 
                        CandidateDeviceNames=temp;
459
 
                }
460
 
                if (CandidateDeviceNames==null)
461
 
                {
462
 
                        if (debug)
463
 
                                System.out.println("RXTXCommDriver:registerScannedPorts() no Device files to check ");
464
 
                        return;
465
 
                }
466
 
 
467
 
                String CandidatePortPrefixes[] = {};
468
 
                switch (PortType) {
469
 
                        case CommPortIdentifier.PORT_SERIAL:
 
467
 
 
468
                                String term[] = new String[2];
 
469
                                int l = 0;
 
470
                                File dev = null;
 
471
 
 
472
                                dev = new File( "/dev/term" );
 
473
                                if( dev.list().length > 0 );
 
474
                                        term[l++] = new String( "term/" );
 
475
        /*
 
476
                                dev = new File( "/dev/cua0" );
 
477
                                if( dev.list().length > 0 );
 
478
                                        term[l++] = new String( "cua/" );
 
479
        */
 
480
                                String[] temp = new String[l];
 
481
                                for(l--;l >= 0;l--)
 
482
                                        temp[l] = term[l];
 
483
                                CandidateDeviceNames=temp;
 
484
                        }
 
485
                        else
 
486
                        {
 
487
                                File dev = new File( deviceDirectory );
 
488
                                String[] temp = dev.list();
 
489
                                CandidateDeviceNames=temp;
 
490
                        }
 
491
                        if (CandidateDeviceNames==null)
 
492
                        {
470
493
                                if (debug)
471
 
                                        System.out.println("scanning for serial ports for os "+osName);
472
 
                                if(osName.equals("Linux"))
473
 
                                {
474
 
                                        String[] Temp = {
475
 
                                        "ttyS", // linux Serial Ports
476
 
                                        "ttySA" // for the IPAQs
477
 
                                        };
478
 
                                        CandidatePortPrefixes=Temp;
479
 
                                }
480
 
                                else if(osName.equals("Linux-all-ports"))
481
 
                                {
482
 
                                /* if you want to enumerate all ports ~5000
483
 
                                   possible, then replace the above with this
484
 
                                */
485
 
                                        String[] Temp = {
486
 
                                        "comx",      // linux COMMX synchronous serial card
487
 
                                        "holter",    // custom card for heart monitoring
488
 
                                        "modem",     // linux symbolic link to modem.
489
 
                                        "ttyircomm", // linux IrCommdevices (IrDA serial emu)
490
 
                                        "ttycosa0c", // linux COSA/SRP synchronous serial card
491
 
                                        "ttycosa1c", // linux COSA/SRP synchronous serial card
492
 
                                        "ttyC", // linux cyclades cards
493
 
                                        "ttyCH",// linux Chase Research AT/PCI-Fast serial card
494
 
                                        "ttyD", // linux Digiboard serial card
495
 
                                        "ttyE", // linux Stallion serial card
496
 
                                        "ttyF", // linux Computone IntelliPort serial card
497
 
                                        "ttyH", // linux Chase serial card
498
 
                                        "ttyI", // linux virtual modems
499
 
                                        "ttyL", // linux SDL RISCom serial card
500
 
                                        "ttyM", // linux PAM Software's multimodem boards
501
 
                                                // linux ISI serial card
502
 
                                        "ttyMX",// linux Moxa Smart IO cards
503
 
                                        "ttyP", // linux Hayes ESP serial card
504
 
                                        "ttyR", // linux comtrol cards
505
 
                                                // linux Specialix RIO serial card
506
 
                                        "ttyS", // linux Serial Ports
507
 
                                        "ttySI",// linux SmartIO serial card
508
 
                                        "ttySR",// linux Specialix RIO serial card 257+
509
 
                                        "ttyT", // linux Technology Concepts serial card
510
 
                                        "ttyUSB",//linux USB serial converters
511
 
                                        "ttyV", // linux Comtrol VS-1000 serial controller
512
 
                                        "ttyW", // linux specialix cards
513
 
                                        "ttyX"  // linux SpecialX serial card
514
 
                                        };
515
 
                                        CandidatePortPrefixes=Temp;
516
 
                                }
517
 
                                else if(osName.toLowerCase().indexOf("qnx") != -1 )
518
 
                                {
519
 
                                        String[] Temp = {
520
 
                                                "ser"
521
 
                                        };
522
 
                                        CandidatePortPrefixes=Temp;
523
 
                                }
524
 
                                else if(osName.equals("Irix"))
525
 
                                {
526
 
                                        String[] Temp = {
527
 
                                                "ttyc", // irix raw character devices
528
 
                                                "ttyd", // irix basic serial ports
529
 
                                                "ttyf", // irix serial ports with hardware flow
530
 
                                                "ttym", // irix modems
531
 
                                                "ttyq", // irix pseudo ttys
532
 
                                                "tty4d",// irix RS422
533
 
                                                "tty4f",// irix RS422 with HSKo/HSki
534
 
                                                "midi", // irix serial midi
535
 
                                                "us"    // irix mapped interface
536
 
                                        };
537
 
                                        CandidatePortPrefixes=Temp;
538
 
                                }
539
 
                                else if(osName.equals("FreeBSD")) //FIXME this is probably wrong
540
 
                                {
541
 
                                        String[] Temp = {
542
 
                                                "ttyd",    //general purpose serial ports
543
 
                                                "cuaa",    //dialout serial ports
544
 
                                                "ttyA",    //Specialix SI/XIO dialin ports
545
 
                                                "cuaA",    //Specialix SI/XIO dialout ports
546
 
                                                "ttyD",    //Digiboard - 16 dialin ports
547
 
                                                "cuaD",    //Digiboard - 16 dialout ports
548
 
                                                "ttyE",    //Stallion EasyIO (stl) dialin ports
549
 
                                                "cuaE",    //Stallion EasyIO (stl) dialout ports
550
 
                                                "ttyF",    //Stallion Brumby (stli) dialin ports
551
 
                                                "cuaF",    //Stallion Brumby (stli) dialout ports
552
 
                                                "ttyR",    //Rocketport dialin ports
553
 
                                                "cuaR",    //Rocketport dialout ports
554
 
                                                "stl"      //Stallion EasyIO board or Brumby N 
555
 
                                        };
556
 
                                        CandidatePortPrefixes=Temp;
557
 
                                }
558
 
                                else if(osName.equals("NetBSD")) // FIXME this is probably wrong
559
 
                                {
560
 
                                        String[] Temp = {
561
 
                                                "tty0"  // netbsd serial ports
562
 
                                        };
563
 
                                        CandidatePortPrefixes=Temp;
564
 
                                }
565
 
                                else if ( osName.equals("Solaris")
566
 
                                                || osName.equals("SunOS"))
567
 
                                {
568
 
                                        String[] Temp = {
569
 
                                                "term/",
570
 
                                                "cua/"
571
 
                                        };
572
 
                                        CandidatePortPrefixes=Temp;
573
 
                                }
574
 
                                else if(osName.equals("HP-UX"))
575
 
                                {
576
 
                                        String[] Temp = {
577
 
                                                "tty0p",// HP-UX serial ports
578
 
                                                "tty1p" // HP-UX serial ports
579
 
                                        };
580
 
                                        CandidatePortPrefixes=Temp;
581
 
                                }
582
 
 
583
 
                                else if(osName.equals("UnixWare") ||
584
 
                                                osName.equals("OpenUNIX"))
585
 
                                {
586
 
                                        String[] Temp = {
587
 
                                                "tty00s", // UW7/OU8 serial ports
588
 
                                                "tty01s",
589
 
                                                "tty02s",
590
 
                                                "tty03s"
591
 
                                        };
592
 
                                        CandidatePortPrefixes=Temp;
593
 
                                }
594
 
 
595
 
                        else if (osName.equals("OpenServer"))
596
 
                                {
597
 
                                        String[] Temp = {
598
 
                                                "tty1A",  // OSR5 serial ports
599
 
                                                "tty2A",
600
 
                                                "tty3A",
601
 
                                                "tty4A",
602
 
                                                "tty5A",
603
 
                                                "tty6A",
604
 
                                                "tty7A",
605
 
                                                "tty8A",
606
 
                                                "tty9A",
607
 
                                                "tty10A",
608
 
                                                "tty11A",
609
 
                                                "tty12A",
610
 
                                                "tty13A",
611
 
                                                "tty14A",
612
 
                                                "tty15A",
613
 
                                                "tty16A",
614
 
                                                "ttyu1A", // OSR5 USB-serial ports
615
 
                                                "ttyu2A",
616
 
                                                "ttyu3A",
617
 
                                                "ttyu4A",
618
 
                                                "ttyu5A",
619
 
                                                "ttyu6A",
620
 
                                                "ttyu7A",
621
 
                                                "ttyu8A",
622
 
                                                "ttyu9A",
623
 
                                                "ttyu10A",
624
 
                                                "ttyu11A",
625
 
                                                "ttyu12A",
626
 
                                                "ttyu13A",
627
 
                                                "ttyu14A",
628
 
                                                "ttyu15A",
629
 
                                                "ttyu16A"
630
 
                                        };
631
 
                                        CandidatePortPrefixes=Temp;
632
 
                                }
633
 
                                else if (osName.equals("Compaq's Digital UNIX") || osName.equals("OSF1"))
634
 
                                {
635
 
                                        String[] Temp = {
636
 
                                                "tty0"  //  Digital Unix serial ports
637
 
                                        };
638
 
                                        CandidatePortPrefixes=Temp;
639
 
                                }
640
 
 
641
 
                                else if(osName.equals("BeOS"))
642
 
                                {
643
 
                                        String[] Temp = {
644
 
                                                "serial" // BeOS serial ports
645
 
                                        };
646
 
                                        CandidatePortPrefixes=Temp;
647
 
                                }
648
 
                                else if(osName.equals("Mac OS X"))
649
 
                                {
650
 
                                        String[] Temp = {
651
 
                                        // Keyspan USA-28X adapter, USB port 1
652
 
                                                "cu.KeyUSA28X191.",
653
 
                                        // Keyspan USA-28X adapter, USB port 1
654
 
                                                "tty.KeyUSA28X191.",
655
 
                                        // Keyspan USA-28X adapter, USB port 2
656
 
                                                "cu.KeyUSA28X181.",
657
 
                                        // Keyspan USA-28X adapter, USB port 2
658
 
                                                "tty.KeyUSA28X181.",
659
 
                                        // Keyspan USA-19 adapter
660
 
                                                "cu.KeyUSA19181.",
661
 
                                        // Keyspan USA-19 adapter
662
 
                                                "tty.KeyUSA19181."
663
 
                                        };
664
 
                                        CandidatePortPrefixes=Temp;
665
 
                                }
666
 
                                else if(osName.toLowerCase().indexOf("windows") != -1 )
667
 
                                {
668
 
                                        String[] Temp = {
669
 
                                                "COM"    // win32 serial ports
 
494
                                        System.out.println("RXTXCommDriver:registerScannedPorts() no Device files to check ");
 
495
                                return;
 
496
                        }
 
497
 
 
498
                        String CandidatePortPrefixes[] = {};
 
499
                        switch (PortType) {
 
500
                                case CommPortIdentifier.PORT_SERIAL:
 
501
                                        if (debug)
 
502
                                                System.out.println("scanning for serial ports for os "+osName);
 
503
 
 
504
 
 
505
                        /*  There are _many_ possible ports that can be used
 
506
                            on Linux.  See below in the fake Linux-all-ports  
 
507
                            case for a list.  You may add additional ports
 
508
                            here but be warned that too many will significantly
 
509
                            slow down port enumeration.  Linux 2.6 has udev
 
510
                            support which should be faster as only ports the
 
511
                            kernel finds should be exposed in /dev
 
512
 
 
513
                            See also how to override port enumeration and
 
514
                            specifying port in INSTALL.
 
515
 
 
516
                            taj
 
517
                        */
 
518
 
 
519
                                        if(osName.equals("Linux"))
 
520
                                        {
 
521
                                                String[] Temp = {
 
522
                                                "ttyS", // linux Serial Ports
 
523
                                                "ttySA", // for the IPAQs
 
524
                                                "ttyUSB" // for USB frobs
 
525
                                                };
 
526
                                                CandidatePortPrefixes=Temp;
 
527
                                        }
 
528
                                        else if(osName.equals("Linux-all-ports"))
 
529
                                        {
 
530
                                        /* if you want to enumerate all ports ~5000
 
531
                                           possible, then replace the above with this
 
532
                                        */
 
533
                                                String[] Temp = {
 
534
                                                "comx",      // linux COMMX synchronous serial card
 
535
                                                "holter",    // custom card for heart monitoring
 
536
                                                "modem",     // linux symbolic link to modem.
 
537
                                                "rfcomm",       // bluetooth serial device
 
538
                                                "ttyircomm", // linux IrCommdevices (IrDA serial emu)
 
539
                                                "ttycosa0c", // linux COSA/SRP synchronous serial card
 
540
                                                "ttycosa1c", // linux COSA/SRP synchronous serial card
 
541
                                                "ttyC", // linux cyclades cards
 
542
                                                "ttyCH",// linux Chase Research AT/PCI-Fast serial card
 
543
                                                "ttyD", // linux Digiboard serial card
 
544
                                                "ttyE", // linux Stallion serial card
 
545
                                                "ttyF", // linux Computone IntelliPort serial card
 
546
                                                "ttyH", // linux Chase serial card
 
547
                                                "ttyI", // linux virtual modems
 
548
                                                "ttyL", // linux SDL RISCom serial card
 
549
                                                "ttyM", // linux PAM Software's multimodem boards
 
550
                                                        // linux ISI serial card
 
551
                                                "ttyMX",// linux Moxa Smart IO cards
 
552
                                                "ttyP", // linux Hayes ESP serial card
 
553
                                                "ttyR", // linux comtrol cards
 
554
                                                        // linux Specialix RIO serial card
 
555
                                                "ttyS", // linux Serial Ports
 
556
                                                "ttySI",// linux SmartIO serial card
 
557
                                                "ttySR",// linux Specialix RIO serial card 257+
 
558
                                                "ttyT", // linux Technology Concepts serial card
 
559
                                                "ttyUSB",//linux USB serial converters
 
560
                                                "ttyV", // linux Comtrol VS-1000 serial controller
 
561
                                                "ttyW", // linux specialix cards
 
562
                                                "ttyX"  // linux SpecialX serial card
 
563
                                                };
 
564
                                                CandidatePortPrefixes=Temp;
 
565
                                        }
 
566
                                        else if(osName.toLowerCase().indexOf("qnx") != -1 )
 
567
                                        {
 
568
                                                String[] Temp = {
 
569
                                                        "ser"
 
570
                                                };
 
571
                                                CandidatePortPrefixes=Temp;
 
572
                                        }
 
573
                                        else if(osName.equals("Irix"))
 
574
                                        {
 
575
                                                String[] Temp = {
 
576
                                                        "ttyc", // irix raw character devices
 
577
                                                        "ttyd", // irix basic serial ports
 
578
                                                        "ttyf", // irix serial ports with hardware flow
 
579
                                                        "ttym", // irix modems
 
580
                                                        "ttyq", // irix pseudo ttys
 
581
                                                        "tty4d",// irix RS422
 
582
                                                        "tty4f",// irix RS422 with HSKo/HSki
 
583
                                                        "midi", // irix serial midi
 
584
                                                        "us"    // irix mapped interface
 
585
                                                };
 
586
                                                CandidatePortPrefixes=Temp;
 
587
                                        }
 
588
                                        else if(osName.equals("FreeBSD")) //FIXME this is probably wrong
 
589
                                        {
 
590
                                                String[] Temp = {
 
591
                                                        "ttyd",    //general purpose serial ports
 
592
                                                        "cuaa",    //dialout serial ports
 
593
                                                        "ttyA",    //Specialix SI/XIO dialin ports
 
594
                                                        "cuaA",    //Specialix SI/XIO dialout ports
 
595
                                                        "ttyD",    //Digiboard - 16 dialin ports
 
596
                                                        "cuaD",    //Digiboard - 16 dialout ports
 
597
                                                        "ttyE",    //Stallion EasyIO (stl) dialin ports
 
598
                                                        "cuaE",    //Stallion EasyIO (stl) dialout ports
 
599
                                                        "ttyF",    //Stallion Brumby (stli) dialin ports
 
600
                                                        "cuaF",    //Stallion Brumby (stli) dialout ports
 
601
                                                        "ttyR",    //Rocketport dialin ports
 
602
                                                        "cuaR",    //Rocketport dialout ports
 
603
                                                        "stl"      //Stallion EasyIO board or Brumby N 
 
604
                                                };
 
605
                                                CandidatePortPrefixes=Temp;
 
606
                                        }
 
607
                                        else if(osName.equals("NetBSD")) // FIXME this is probably wrong
 
608
                                        {
 
609
                                                String[] Temp = {
 
610
                                                        "tty0"  // netbsd serial ports
 
611
                                                };
 
612
                                                CandidatePortPrefixes=Temp;
 
613
                                        }
 
614
                                        else if ( osName.equals("Solaris")
 
615
                                                        || osName.equals("SunOS"))
 
616
                                        {
 
617
                                                String[] Temp = {
 
618
                                                        "term/",
 
619
                                                        "cua/"
 
620
                                                };
 
621
                                                CandidatePortPrefixes=Temp;
 
622
                                        }
 
623
                                        else if(osName.equals("HP-UX"))
 
624
                                        {
 
625
                                                String[] Temp = {
 
626
                                                        "tty0p",// HP-UX serial ports
 
627
                                                        "tty1p" // HP-UX serial ports
 
628
                                                };
 
629
                                                CandidatePortPrefixes=Temp;
 
630
                                        }
 
631
 
 
632
                                        else if(osName.equals("UnixWare") ||
 
633
                                                        osName.equals("OpenUNIX"))
 
634
                                        {
 
635
                                                String[] Temp = {
 
636
                                                        "tty00s", // UW7/OU8 serial ports
 
637
                                                        "tty01s",
 
638
                                                        "tty02s",
 
639
                                                        "tty03s"
 
640
                                                };
 
641
                                                CandidatePortPrefixes=Temp;
 
642
                                        }
 
643
 
 
644
                                else if (osName.equals("OpenServer"))
 
645
                                        {
 
646
                                                String[] Temp = {
 
647
                                                        "tty1A",  // OSR5 serial ports
 
648
                                                        "tty2A",
 
649
                                                        "tty3A",
 
650
                                                        "tty4A",
 
651
                                                        "tty5A",
 
652
                                                        "tty6A",
 
653
                                                        "tty7A",
 
654
                                                        "tty8A",
 
655
                                                        "tty9A",
 
656
                                                        "tty10A",
 
657
                                                        "tty11A",
 
658
                                                        "tty12A",
 
659
                                                        "tty13A",
 
660
                                                        "tty14A",
 
661
                                                        "tty15A",
 
662
                                                        "tty16A",
 
663
                                                        "ttyu1A", // OSR5 USB-serial ports
 
664
                                                        "ttyu2A",
 
665
                                                        "ttyu3A",
 
666
                                                        "ttyu4A",
 
667
                                                        "ttyu5A",
 
668
                                                        "ttyu6A",
 
669
                                                        "ttyu7A",
 
670
                                                        "ttyu8A",
 
671
                                                        "ttyu9A",
 
672
                                                        "ttyu10A",
 
673
                                                        "ttyu11A",
 
674
                                                        "ttyu12A",
 
675
                                                        "ttyu13A",
 
676
                                                        "ttyu14A",
 
677
                                                        "ttyu15A",
 
678
                                                        "ttyu16A"
 
679
                                                };
 
680
                                                CandidatePortPrefixes=Temp;
 
681
                                        }
 
682
                                        else if (osName.equals("Compaq's Digital UNIX") || osName.equals("OSF1"))
 
683
                                        {
 
684
                                                String[] Temp = {
 
685
                                                        "tty0"  //  Digital Unix serial ports
 
686
                                                };
 
687
                                                CandidatePortPrefixes=Temp;
 
688
                                        }
 
689
 
 
690
                                        else if(osName.equals("BeOS"))
 
691
                                        {
 
692
                                                String[] Temp = {
 
693
                                                        "serial" // BeOS serial ports
 
694
                                                };
 
695
                                                CandidatePortPrefixes=Temp;
 
696
                                        }
 
697
                                        else if(osName.equals("Mac OS X"))
 
698
                                        {
 
699
                                                String[] Temp = {
 
700
                                                // Keyspan USA-28X adapter, USB port 1
 
701
                                                        "cu.KeyUSA28X191.",
 
702
                                                // Keyspan USA-28X adapter, USB port 1
 
703
                                                        "tty.KeyUSA28X191.",
 
704
                                                // Keyspan USA-28X adapter, USB port 2
 
705
                                                        "cu.KeyUSA28X181.",
 
706
                                                // Keyspan USA-28X adapter, USB port 2
 
707
                                                        "tty.KeyUSA28X181.",
 
708
                                                // Keyspan USA-19 adapter
 
709
                                                        "cu.KeyUSA19181.",
 
710
                                                // Keyspan USA-19 adapter
 
711
                                                        "tty.KeyUSA19181."
 
712
                                                };
 
713
                                                CandidatePortPrefixes=Temp;
 
714
                                        }
 
715
                                        else if(osName.toLowerCase().indexOf("windows") != -1 )
 
716
                                        {
 
717
                                                String[] Temp = {
 
718
                                                        "COM"     // win32 serial ports
 
719
                                                        //"//./COM"    // win32 serial ports
670
720
                                        };
671
721
                                        CandidatePortPrefixes=Temp;
672
722
                                }
707
757
                                        };
708
758
                                        CandidatePortPrefixes=temp;
709
759
                                }
 
760
                                else if(osName.toLowerCase().indexOf("windows") != -1 )
 
761
                                {
 
762
                                        String[] temp={
 
763
                                                "LPT"
 
764
                                        };
 
765
                                        CandidatePortPrefixes=temp;
 
766
                                }
710
767
                                else  /* printer support is green */
711
768
                                {
712
769
                                        String [] temp={};
740
797
                try {
741
798
                        switch (PortType) {
742
799
                                case CommPortIdentifier.PORT_SERIAL:
743
 
                                        return new RXTXPort( PortName );
 
800
                                        if(osName.toLowerCase().indexOf("windows") == -1 )
 
801
                                        {
 
802
                                        
 
803
                                                return new RXTXPort( PortName );
 
804
                                        }
 
805
                                        else
 
806
                                        {
 
807
                                                return new RXTXPort( deviceDirectory + PortName );
 
808
                                        }
744
809
                                case CommPortIdentifier.PORT_PARALLEL:
745
810
                                        return new LPRPort( PortName );
746
811
                                default: