Java and BS
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?
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
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?
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
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.
Post Edited (allanlane5) : 11/6/2006 7:04:35 PM GMT
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:
G:. Now, say your JDK is installed on
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
F.
Apparently if your application and the javax classes are on different drives,
no com ports are found.
regards peter
·