Hi, I recently have started experimenting with motorcontrollers, specially ones that control servo motors. I wanted to use Java because I am most familiar with this language, and I am learning javax.comm. However, I am clueless when it comes to giving the motorcontroller actual commands to carry out, I can't seem to figure out how to do this. I'd imagine that different motorcontrollers might have different commands that are applicable to them. I am using the EZ4AXIS model by All motion (http://www.allmotion.com/EZ4AXISdescription.htm). This is what I have so far:
package LBIC; import javax.comm.*; import java.io.*; import java.util.*; public class comm implements SerialPortEventListener, CommPortOwnershipListener { public static SerialPort sPort; public static void main (String args[]) { try { CommPortIdentifier com = CommPortIdentifier.getPortIdentifier("COM4"); System.out.println(com); System.out.println(com.getName()); try { sPort = (SerialPort)com.open("COMM", 1000); try { OutputStream os = sPort.getOutputStream(); } catch (IOException e) { sPort.close(); e.printStackTrace(); } try { InputStream is = sPort.getInputStream(); } catch (IOException e) { sPort.close(); e.printStackTrace(); } try { sPort.addEventListener(this); } catch (TooManyListenersException e) { sPort.close(); e.printStackTrace(); } com.addPortOwnershipListener(this); } catch (PortInUseException e) { e.printStackTrace(); } } catch (NoSuchPortException e) { e.printStackTrace(); } } @Override public void serialEvent(SerialPortEvent arg0) { // TODO Auto-generated method stub } @Override public void ownershipChange(int arg0) { // TODO Auto-generated method stub } }
Any help would be greatly appreciated.