From owner-freebsd-java@FreeBSD.ORG Tue Apr 8 10:23:28 2008 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 02ACB106566B for ; Tue, 8 Apr 2008 10:23:28 +0000 (UTC) (envelope-from guilhermegrg@gmail.com) Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.190]) by mx1.freebsd.org (Postfix) with ESMTP id 7B8088FC16 for ; Tue, 8 Apr 2008 10:23:27 +0000 (UTC) (envelope-from guilhermegrg@gmail.com) Received: by fk-out-0910.google.com with SMTP id b27so3038854fka.11 for ; Tue, 08 Apr 2008 03:23:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to:subject:date:mime-version:content-type:content-transfer-encoding:x-priority:x-msmail-priority:x-mailer:disposition-notification-to:x-mimeole; bh=KsEYGcezGuCzYYGW18n+VEObsC3lIUaLWnDEVRZ6uLU=; b=ZjjterdI8TlN3bBHIvYtM57CRUAiQpkOh/LlvdRw1oPwKasKHRiqU+ZCrXuFS1u1W/qZR/EsCZun9o3tTxgj5yI191dVdz42q6+nc13sNj4S7btqd7MYz/0IyKIK5FrvEh4HMHjHGfd4IjtmoyOl/FJ0pvwOCqEFA2ndPkcoDPE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:subject:date:mime-version:content-type:content-transfer-encoding:x-priority:x-msmail-priority:x-mailer:disposition-notification-to:x-mimeole; b=s+2+g2KwMtt9SLOjy9uaUOd8enNHqtM8iPJ2Ua0LZ/BggRke65lbx+RDOApnm6XZiPZqT2Umryy/TLxDCnGIte85iuFQS4rWf43x8d+rrzJ2MeG0PENyDs2lPvtbn41SKC2BXvrjFILRZLxPqi7ez3mmO2/vCIVNbw82iUQdCaU= Received: by 10.82.177.5 with SMTP id z5mr2350050bue.88.1207648586860; Tue, 08 Apr 2008 02:56:26 -0700 (PDT) Received: from laptop ( [85.242.244.191]) by mx.google.com with ESMTPS id a37sm16971785fkc.3.2008.04.08.02.56.24 (version=SSLv3 cipher=RC4-MD5); Tue, 08 Apr 2008 02:56:25 -0700 (PDT) Message-ID: <000201c8995e$ce4c1f90$6402a8c0@laptop> From: "Guilherme Gomes" To: Date: Tue, 8 Apr 2008 10:56:20 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 Subject: Java Communication API for FreeBSD Input Stream Problem X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Apr 2008 10:23:28 -0000 Hi I've read a post about a program in Java that you're made regarding sending AT commands to a GSM phone to send SMS messages, and the trouble about sending the ctrl+z byte and after that getting no data returned. I have the exact same issue, and can't find any solution on the internet so far. Been losing a lot of hours on this. Did you managed to fix this issue ? If so, how ? I attach the text of your original message as a reminder : Hi. I have a problem regarding the Java Communication API for FreeBSD port. One slight difference from a normal instalation of the JDK and the Java Communication port, is that i haven't installed the JDK. i have tried severel times to install it from the ports, but i got an error. (sorry, i can't provide you the error). I tried using the linux jdk allready installed, but when i try to install the Java Communication port i got an error regarding the jndi library. Anyway, i have copied a JDK instalation binaries from another FreeBSD machine, and then the comm port compiled and installed succesfully. I've just though i should mention this. I have search the net for a solution to this matter, posted messeges on forums, but still nothing. I'm a newbie regarding FreeBSD, but i think that it might be a problem in the libSerial.so module. A friend of mine suggested me to send you an email, so here it goes. I have an aplication that connects to a mobile phone via serial port. I want then to send a SMS, using at commands. The problem is that the end of the SMS is marked by the CTRL-Z character (ASCII 26). When i send this character to the OutputStream, the InputStream hungs up. It shows that there are bytes available for read, but when i try to read from the stream, it returns -1. Other AT commands are working fine. The code is: ... props.load(new FileInputStream("sms.properties")); portName = props.getProperty("serial_port_name"); center = props.getProperty("message_center"); CommPortIdentifier portID = CommPortIdentifier.getPortIdentifier( portName); SerialPort port = (SerialPort) portID.open("Alarm Server", 100); port.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); port.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); in = port.getInputStream(); out = new BufferedOutputStream(port.getOutputStream()); Thread.sleep(3000); ... private static String sendMessageText(String command) throws Exception { byte b = 0x1A; //CTRL-Z character synchronized(sincron){ Logger.log("Sending: "+command); out.write(command.getBytes()); out.write(b); out.flush(); String response = read(); Logger.log("Response: "+response); return response; } } private static String sendAT(String command) throws Exception { synchronized (sincron) { Logger.log("AT: "+command); out.write((command+"\r\n").getBytes()); out.flush(); String response = read(); Logger.log("Response: "+response); return response; } } private static String read() throws Exception { int n, i; char c; String answer = new String(""); System.out.println("Reading ..."); do { Thread.sleep(100); } while (!(in.available()>0)); for (i = 0; i < 5; i++) { while (in.available()>0) { System.out.println("Available: "+in.available()); n = in.read(); if (n != -1) { c = (char) n; answer = answer + c; Thread.sleep(1); Thread.sleep(1); }else break } } Thread.sleep(100); } return answer.trim(); } to send the SMS i use this code: public static void sendSMS(String number, String text) { String result; Logger.log("Trying to send to : " + number + "\n\t\t" sendAT("AT+CMGS=\"" + number + "\""); result = sendMessageText(text); Logger.log("I've got: " + result); } normaly, it shoud return on the InputStream OK and a message number if the SMS was succesfully sent or ERROR if there was an error after i send the CTRL-Z, the (InputStream) in.available() returns 20, and when i try to read it reads -1 if i use minicom (equivalent with windows's hyperterminal), it works just fine. I realy don't know what to do. I have tried everything crossed my mind, and other's minds. If you can take a look, and suggest a solution, i would apriciate it. Sorry if i've waisted your time with this question. Best Regards, Daniel Comsa