Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com From: =?iso-8859-1?Q?=D8yvind_Harboe?= To: Subject: RE: Sending files over the serial port Date: Mon, 12 May 2003 19:59:17 +0200 Message-ID: <000001c318b0$34ec2db0$0200000a@famine> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Priority: 3 (Normal) X-MSMail-Priority: Normal Importance: Normal In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id h4CIAP416242 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/