Shop OBEX P1 Docs P2 Docs Learn Events
Java and BS — Parallax Forums

Java and BS

HoffaHoffa Posts: 46
edited 2006-11-06 18:38 in BASIC Stamp
Hi

I want to communicate with my BS trough Java. The BS is connected to the computer with an USB cable, but with and COM-protocol. So as I understand it one can use it as COM6. How do I do, both in Java and BS, to connect and communicate?

Comments

  • FranklinFranklin Posts: 4,747
    edited 2006-11-04 19:02
    If you are using a board to support your BS (board of ed or homework board or the like) the usb port will be connected to the debug port and you can use debug and debugin to send/receive at the BS end. As for the PC end have java output to the serial port (com6?)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • HoffaHoffa Posts: 46
    edited 2006-11-05 20:57
    I use the board of education, and I have tried the following code in java:


    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.TooManyListenersException;

    import javax.comm.CommPortIdentifier;
    import javax.comm.PortInUseException;
    import javax.comm.SerialPort;
    import javax.comm.SerialPortEvent;
    import javax.comm.SerialPortEventListener;
    import javax.comm.UnsupportedCommOperationException;

    public class ComControl implements Runnable, SerialPortEventListener {
    static CommPortIdentifier portId1;

    InputStream inputStream;
    OutputStream outputStream;
    SerialPort serialPort1, serialPort2;
    Thread readThread;
    protected String divertCode = "10";
    static String TimeStamp;

    public static void main(String[noparse]/noparse args) {

    try {
    portId1 = CommPortIdentifier.getPortIdentifier("COM6");
    ComControl reader = new ComControl();
    }

    catch
    (Exception e) {
    TimeStamp = new java.util.Date().toString();
    System.out.println(TimeStamp + ": COM1 " + portId1);
    System.out.println(TimeStamp + ": msg1 - " + e);
    }
    };
    .
    .
    .


    Someone know what's wrong and what I gonna do?
  • HoffaHoffa Posts: 46
    edited 2006-11-05 20:59
    Oh, I forgot to post the exception:

    Sun Nov 05 21:57:57 CET 2006: COM1 null
    Sun Nov 05 21:57:57 CET 2006: msg1 - javax.comm.NoSuchPortException
    Error loading SolarisSerial: java.lang.UnsatisfiedLinkError: no SolarisSerialParallel in java.library.path
    Caught java.lang.UnsatisfiedLinkError: readRegistrySerial while loading driver com.sun.comm.SolarisDriver
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2006-11-05 22:49
    Are you trying to do this on a Windows system or on a Solaris system?

    Your error messages seem to indicate that it's a Solaris system, in which case your ports may not be configured correctly. Also, unless specifically named ComXYZ, Unix naming conventions are usually along the lines of tty0, tty1, or something similar. So there's a good possibility that something isn't configured correctly. Also, without seeing your PBasic code, there's no way to tell if there is a problem there.

    If you have a Windows PC, the best place for you to start would be creating a small PBasic program that can communicate through the Debug Terminal in the Stamp IDE. If that works correctly, you'll at least know that the serial connection and PBasic code are okay. If you have done that already, and are using a Solaris system, try connecting to the BS2 through a terminal program first, to make sure your serial port is correctly configured. Then move to the Java program.

    Right now, there are too many unknown variables concerning your setup to effectively isolate the problem.
  • HoffaHoffa Posts: 46
    edited 2006-11-06 08:05
    I´m trying to do this on a windows system with the Generic version of javax.comm. Is there a better way to do it in windows?
  • HoffaHoffa Posts: 46
    edited 2006-11-06 17:21
    What I want is the way to send and get information via the commport with java in Windows
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-11-06 17:47
    I think we understand what you're trying to do, Hoffa, it's just most 'lurkers' on this forum don't know how to do that either. Peter Verkaik may have some insights -- you could ask on the "Javelin" forum.

    Post Edited (allanlane5) : 11/6/2006 7:04:35 PM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-11-06 18:38
    See the last post in this thread:
    http://forums.parallax.com/showthread.php?p=476754
    Part of this post:
    There is a nasty bug in the Windows version of javax.comm right now that I
    hope they will fix. Suppose you have a few disk drives like I do C: D: E: F:
    G:. Now, say your JDK is installed on D:. You put your program on F:
    Everything seems to work, but the javax.comm reports that no serial ports
    are available. Nothing you can do will make it work. Except moving your
    class files (at least) to the D: drive or moving the javax.comm libraries to
    F.

    Apparently if your application and the javax classes are on different drives,
    no com ports are found.

    regards peter
    ·
Sign In or Register to comment.