Mail Archives: cygwin/2003/05/12/14:10:25
Ah!
I couldn't solve the CygWin issues, but I think I have a solution
that will do for me.
Background: I'm not going to use this from the command line, but
from a Java app.
Here is what I did:
- I launched the lsz command from Java
- From the Java app I opened up a serial port and read stdout
from lsz and fed it to the serial port and input from the serial
port to stdin of the lsz app
Voila! I have xmodem, ymodem and zmodem from Java.
I was able to upload to HyperTerminal in Windows using a nullmodem
cable when I tested.
Øyvind
In case anybody cares, here is the stuff that I hacked up to test
my hypothesis. If it flies (I need it to be compatible with
a certain troublesome bootloader, and Redboot), I'll have to clean
up the code to be production quality(lots of error handling).
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.comm.CommPortIdentifier;
import javax.comm.NoSuchPortException;
import javax.comm.PortInUseException;
import javax.comm.SerialPort;
import javax.comm.UnsupportedCommOperationException;
public class Upload
{
public void run()
{
Runtime runtime=Runtime.getRuntime();
try
{
//--16-bit-crc --ascii --escape
String
foo="c:\\cygwin\\home\\oyvind\\xyz\\install\\bin\\lsz --16-bit-crc
--ymodem c:\\download\\ntregmon.zip" ;
Process process=runtime.exec(foo);
System.out.println(foo);
CommPortIdentifier portId =
CommPortIdentifier.getPortIdentifier("COM2");
SerialPort sPort = (SerialPort)
portId.open("transfer", 0);
sPort.setSerialPortParams(19200,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
sPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
InputStream sIn=sPort.getInputStream();
OutputStream sOut=sPort.getOutputStream();
InputStream pIn = process.getInputStream();
InputStream pErr = process.getErrorStream();
OutputStream pOut = process.getOutputStream();
all:
for (;;)
{
Thread.sleep(100);
while (pErr.available()>0)
{
System.out.print((char)pErr.read());
}
try
{
process.exitValue();
break all;
}
catch (IllegalThreadStateException e)
{
}
/** received from process, stuffed into
serial port */
while (pIn.available()>0)
{
int c=pIn.read();
sOut.write(c);
//System.err.print(""+(char)c+"("+c+")");
}
sOut.flush();
/** received from serial port, stuffed
into process */
while (sIn.available()>0)
{
int c=sIn.read();
pOut.write(c);
//System.out.print(""+(char)c+"("+c+")");
}
pOut.flush();
}
sPort.close();
} catch (IOException e)
{
e.printStackTrace();
} catch (NoSuchPortException e)
{
e.printStackTrace();
} catch (PortInUseException e)
{
e.printStackTrace();
} catch (UnsupportedCommOperationException e)
{
e.printStackTrace();
} catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args)
{
new Upload().run();
}
}
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -