View Single Post
Old 06-08-2009, 05:36 AM   #13 (permalink)
dcb
needs more cowbell
 
dcb's Avatar
 
Join Date: Feb 2008
Location: ÿ
Posts: 5,038

pimp mobile - '81 suzuki gs 250 t
90 day: 96.29 mpg (US)

schnitzel - '01 Volkswagen Golf TDI
90 day: 53.56 mpg (US)
Thanks: 158
Thanked 269 Times in 212 Posts
Ok, can of worms but ok. Adam was messing around with client stuff here: http://ecomodder.com/forum/showthrea...tml#post106367 , I was rooting for java so anyone could use it, have used rxtx a lot Deploying JAVA with RXTX - Rxtx


just for example, here is a sample java prog that sends a character version of the serial bits to stdout and a hex converted version to stderr (9600, com2)
PHP Code:
import gnu.io.CommPortIdentifier;

import gnu.io.SerialPort;

import java.io.InputStream;

import java.io.OutputStream;

public class 
SerialMon {

    static 
InputStream input;
    static 
OutputStream output;
    static 
char[] hexstr = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};

    static 
String toHex(int x){
        return 
""+hexstr[x/16]+hexstr[x%16];
    }
    
    public static 
void main(String[] argsthrows Exception{
        
        
CommPortIdentifier portId CommPortIdentifier.getPortIdentifier(
                
"COM2");

        
SerialPort port = (SerialPort)portId.open("serial madness"4000);
        
input port.getInputStream();
        
output port.getOutputStream();
        
port.setSerialPortParams(
                  
9600,
                  
SerialPort.DATABITS_8,
                  
SerialPort.STOPBITS_1,
                  
SerialPort.PARITY_NONE);
        while(
true){
            while (
input.available()>0){
                
int x input.read();
                
System.out.print((char)x);
                
System.err.print(toHex(x));
            }
        }
    }

__________________
WINDMILLS DO NOT WORK THAT WAY!!!
  Reply With Quote