thank you for your attention. but i already test the program with no '\r' appendix, and i see no message receive body:
this is the output sendind 'at' command to the modem appending no '\r' or "\r\n" character(s). at message received:[at] message has been sent: [at] // this is because of echo behavior of modem settings ate0 // disable echo behavior message has been sent: ate0 message received:[] at // now send at command to modem message has been sent: at //indicate tat the command has been sent to modem message received:[] // an empty answer received. note that according to the serial modem communication rules, there must be a '\r' character after each command sent to modem. so if i send atdt7654321 command to my modem, i must send a '\r' also for modem to receive the command and answers it. On 10/30/08, Julien Vermillard <[EMAIL PROTECTED]> wrote: > On Thu, 30 Oct 2008 13:15:02 +0430 > "amin abbasi" <[EMAIL PROTECTED]> wrote: > >> I want to write a java program to communicate with my modem using >> apache-mina-serial package. >> these are my runngin environment properties: >> >> mina version: 2.0.0 M3 >> Os: win xp service pack 2 >> JVM: Java(TM) SE Runtime Environment (build 1.6.0_04-b12) >> >> the sample source code is attached to the email. >> >> i can send at command to the modem, and i can received the answer, for >> example i write "AT" and the sample code sends the command to my >> modem, then my modem answer the command with "OK" response. but, there >> is a problem with mina serial package, when i want to dial a phone >> number using at command : 'ATDT<a_phone_number>'. >> the problem is that the modem responds 'ok' immediately, without >> completely running the command. i think there may be other commands >> which returns before they runs completely such as the dial command (i >> do this later, using java comm api, and it works well). >> >> >> probable cause: >> >> i test the command using hyperterminal( in window xp) and i see that >> hyperterminal first trys to detect carrier singnal and if it was >> detected, trys to dial the phone number, and after successful dialing, >> it responds 'ok'. if I press a key (such as Enter) just when the >> 'atdt' command is running, hyperterminal stops dialing (stops running >> atdt command), and return 'ok'. >> >> so i think <mina serial> sends a '\r\n' or '\n' character to my modem, >> before atdt is completely run and this is why i receive 'ok' response, >> immediately after sending atdt command without any dial trys. >> >> please help me, what is the problem if i am wrong? > > Hi Amin, > > look like you use the TextLineCodec, so you are supposed to write > directly String to your sessions (ex : cf.getSession().write(rawcmd); ) > no need to add \n or \r\n, it's the TextLineCodec who will add it, > depending how you constructed it. > > Julien >
