My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
sendmodem  
A tool to access the modem/baseband directly.
Updated Feb 4, 2010 by zibree

Introduction

The tool sendmodem is a tool that directly accesses the modem/baseband through /dev/tty.debug without the need to disable the commcenter.

Details

Normally, the modem/baseband is accessed through minicom which issues commands to /dev/tty.baseband. In order for minicom to work, the commcenter first needs to be disabled, then your can run minicom, and after you are done with minicom you again need to enable the commcenter.

# cd /usr/bin
# launchctl unload -w /System/Library/LaunchDaemons/com.apple.CommCenter.plist
# minicom
# launchctl load -w /System/Library/LaunchDaemons/com.apple.CommCenter.plist

With sendmodem commands to the modem/baseband can be directly executed from the commandline.

In order to use sendmodem on your iPhone, do the following:

  1. Upload the file sendmodem to your iPhone in /usr/bin (use your favorite program for this e.g. winscp, ibrickr, etc.)
  2. On your iPhone execute the following commands (e.g. from the terminal window or through ssh):
  3.   # cd /usr/bin
      # chmod +x sendmodem

To try sendmodem out, you can execute on your iPhone the following commands:

  • To see the help of sendmodem:
  •   # sendmodem
which will respond with:
  usage: sendmodem <at command>
  examples:       sendmodem "AT+XSIMSTATE=1"
                  sendmodem "AT+XGENDATA"
                  sendmodem "AT+CLCK=\"SC\",2"
  • To query the baseband:
  •   # sendmodem "AT+XGENDATA"
which will respond with (depending on your firmware and bootloader version):
  Sending command to modem: AT
  --.+
  AT
  OK
  Sending command to modem: AT+XGENDATA
  -..+
  AT+XGENDATA
  +XGENDATA: "
  ",
             "DEV_ICE_MODEM_04.01.13_G",
  "EEP_VERSION:207",
  "EEP_REVISION:8",
  "BOOTLOADER_VERSION:3.9_M3S2",1,0
 
  OK

Notes

  1. sendmodem always initiates communication to the modem/baseband with the "AT" command and waits till it receives the response "OK". While waiting it will write "-" to your screen. Be patient, the amount of dashes can very from a few to many.
  2. The original modem state is saved before any commands are send and restored after executing your commands.
  3. The original code was obtained from the iPhone-sms application source code, available from http://code.google.com/p/iphone-sms and was slightly modified in its screen output format
  4. Make sure not to send any commands to the modem of which you don't know what its effect is (you don't want a brick right?)

Another example

Have you ever wondered how to make iTunes display your phone number if it is not showing? Here are the commands to enter:

  • We first check what addressbook-mode the SIM card is in:
  •   # sendmodem "AT+CPBS?"
Usually it will respond with "SM" (general addressbook). If the response is not "ON", we change the addressbook to "ON" (SIM card owner specific numbers):
  # sendmodem "AT+CPBS=\"ON\""
  • Next we check what is currently in the addressbook item 1 (this is the location for your own phone number)
  •   # sendmodem "AT+CPBR=1"
  • If you are fine with overwriting the current content (it is probably empty), you can (re)write the first entry with your own phone number (indicated by xxx below, e.g. "+18885559999") and a description (indicated by yyy below, e.g. "your name here"). Btw, note the double ,, (this is not a mistake) and that the "+" sign in the number will disappear upon query.
  •   # sendmodem "AT+CPBW=1,\"xxx\",,\"yyy\""
  • Next you can query the results with the command below. It will respond back with what you entered plus the entry type, either 129 or 145. (129 fits a phone number with a national pattern, and 145 one with an international pattern):
  •   # sendmodem "AT+CPBR=1"
  • And if you are happy with what you see, you can issue the following command (this is how iTunes queries the "Owner Number"):
  •   # sendmodem "AT+CNUM"
  • Now put the SIM back to its original addressbook with the response answer from the first step (AT+CPBS?). In this example we assume it responded with "SM":
  •   # sendmodem "AT+CPBS=\"SM\""
  • And verify that it worked (it should respond with "SM"):
  •   # sendmodem "AT+CPBS?"
  • Now reboot your phone and after it is done rebooting, start up iTunes.
  •   # reboot

And voila, iTunes should be displaying your phone number under the summary tab and also if you scroll to the top of your contact list on the phone, you should now see your phonenumber.

Comment by shade...@gmail.com, Nov 24, 2007

Works fine! iTunes now shows my phone number! Thanks to everyone.

Comment by paul...@gmail.com, Dec 1, 2007

Thank you! Looks great!!! But I have another question. Can I with sendmodem command change carrier name? My operator is "Megafon RUS", but on my iPhone displayed "Mega..."

Comment by hqu...@gmail.com, Dec 3, 2007

Any way by using AT commands to set a different GSM frequency on the phones? At least one of 4 valid ones (850/900/1800/1900 MHz)?

Comment by g.raghav...@gmail.com, Dec 16, 2007

Hi... When i do this step

  1. sendmodem "AT+CPBW=1,\"+919885122245\",,\"Bablu\""

iam getting the following error.... # sendmodem "AT+CPBW=1,\"+919885122245\",,\"Bablu\"" Sending command to modem: AT -.+ AT OK Sending command to modem: AT+CPBW=1,"+919885122245",,"Bablu" -..+ AT+CPBW=1,"+919885122245",,"Bablu" ERROR

Need your help to proceed forward...

Comment by PmgRiPh...@gmail.com, Dec 16, 2007

>> g.raghavrao

Make sure you have the right address book selected in the SIM card with the command:

sendmodem "AT+CPBS=\"ON\""

You can try executing the same command, but omitting the + sign in the number (it is optional). If that doesn't work, try to remove Bablu from the name string (so just put two backslash quotes only; an empty name string):

sendmodem "AT+CPBW=1,\"919885122245\",,\"\""

Comment by g.raghav...@gmail.com, Dec 17, 2007

Hi...

sendmodem "AT+CPBW=1,\"919885122245\",,\"\""

worked fine. I can see my number in itunes and address book. Thanks a lot :)

Comment by olivier....@gmail.com, Dec 24, 2007

Hi,

For some reasons I have a "16(Resource busy)" error when I try the basic command like this : sendmodem "AT+XGENDATA"

Any clue ?

oho

Comment by olivier....@gmail.com, Dec 31, 2007

Yo Guys ...,

Still any clue ?

O.

Comment by olivier....@gmail.com, Jan 17, 2008

:(

Comment by dim...@gmail.com, Feb 4, 2008

may be you shoud stop somebody using it? launchctl unload -w /System/Library/LaunchDaemons?/com.apple.CommCenter?.plist

Comment by ambrosei...@yahoo.com, Feb 5, 2008

After my accidental upgrade to 1.1.3 of my OTB 1.1.2 moderm firmware 04.02.13_G

I have managed to find my way back to 1.1.2 modem firmware 04.03.13_G. (Thank you all that has contributed in making it possible to bring back my iphone to this current state.Thank you guys).

The phone now complains with every sim card (including the original OTB sim card)"incorrect SIM" No longer respects NEXTSIM or TurboSIM.

Can this routine perhaps able to re-instate the modem firmware to 04.02.13_G. If so how does one proceed.

Comment by namjam...@gmail.com, Feb 7, 2008

Add Source installer : http://iphonebaidu.com/app/ Test iPhone - iPhone Simulator : http://iphonebaidu.com/test/ All Software for Apple MAC : http://iphonebaidu.com/mac-iphone/ All Software for Apple iPhone : http://iphonebaidu.com/mac-iphone/iphone.html

Install iTransformy (.swf) view for iPhone : http://iphonebaidu.com/beta/ Forum iPhone : http://iphonebaidu.com/forum/

Copyright © 2008 iPhone Baidu! Inc. All rights reserved

Comment by jorge.a...@gmail.com, Feb 29, 2008

Why am I unable to save the output of sendmodem?

I want to save into a text file the phone number of the SIM

sendmodem "AT+CNUM" >output.txt produces a 0 byte file, and output is shown on screen.

Can this be fixed?

Comment by federico...@gmail.com, Mar 5, 2008

@jorge.asch:

Use: sendmodem "AT+CNUM" >output.txt 2>&1

Comment by smokeme...@gmail.com, May 1, 2008

when i type sendmodem "AT+CPBS=\"ON\"" it returns an error any ideas why?

Comment by smokeme...@gmail.com, May 1, 2008

by the way i have given it permissions - #chmod +x sendmodem

Comment by prabhat....@gmail.com, May 7, 2008

can u help me out .. whhat shoul i do to send smsm through the /dev/tty.debug have any idea, what should be the procedure?

thanks in advance

Comment by hage...@gmail.com, May 15, 2008

if I want to use sendmodem to send a sms from commandlind how is is done ?

it does allow me to include my text message when I used:

sendmodem at+cmgs=13456789

Comment by crafty...@gmail.com, May 19, 2008

Is there any way to emulate keypresses in sendmodem? For example, I want to execute: sendmodem "AT+CMGF=\"+1234567890\""

This AT + command requires a <CR>, followed by a string of text, followed again by a <Ctrl+z> to end the command. The whole thing would look like this:

AT+CMGF=+1234567890 <CR> >Hello world<Ctrl+z>

Comment by adrian.w...@gmail.com, May 22, 2008

could you provide an example of "How to send an SMS using sendmodem" I found a tutorial http://www.developershome.com/sms/howToSendSMSFromPC.asp saying:

AT OK AT+CMGF=1 OK AT+CMGW="+85291234567" > A simple demo of SMS text messaging. +CMGW: 1

OK AT+CMSS=1 +CMSS: 20

OK

everything works as aspected till the #AT+CMGW="+85291234567"' command. it seems like sendmodem does not provide the msg-text input.

Thanks a lot.

Adrian

Comment by vicky200...@gmail.com, Jul 29, 2008

Will anyone tell me how to send sms from SQL Schedular

Comment by jpmhous...@gmail.com, Sep 30, 2008

i'm trying to do something similar in my app and open("/dev/tty.debug"..) is returning -1. is there a reason this code wouldn't work in app built in Xcode by the SDK?? thx

Comment by jpmhous...@gmail.com, Sep 30, 2008

(duh, forgot..) and it looks like open returns with errno=1

Comment by shujaa...@gmail.com, Oct 15, 2008

endmodem AT+XGENDATA sending command to modem: AT

generates only - - - - where is the problem

Comment by shade...@gmail.com, Oct 24, 2008

Hi all,

this also works in the lastest iPhone 3G with firmware 2.1, but you need, for sure, jailbreak and then sign the binary with sauriks tutorial.

Greetings

Shade (www.iphonefix.de)

Comment by narender...@gmail.com, Jan 7, 2009

I am having the same problem like open("dev/tty.debug") returning -1 and exited with status 1. I stuck here and not going further to complete my application. I need your help. Thanks n@ren.

Comment by amine.re...@gmail.com, Jan 10, 2010

Dear Sir, I’d like to know if I can implement your code in the iPhone application. Because I need to develop an iphone application that sends programmatically AT command to the gsm network. This command look like at+cusd=1,”#123#”,15

Please reply to me

thank you

Comment by nickmitc...@gmail.com, Feb 22, 2010

on my mobile terminal it isn't working ipt 3g 3.1.2 i ran every step smoothly and then i try to implement the command it is was killed it looked like this

nicks-ipod:/usr/bin root# sendmodem "AT+XGENDATA" Killed nicks-ipod:/usr/bin root#

?????

Comment by IceR...@gmail.com, May 13, 2010

@nickmitchko

Baseband, as in PHONE not iPod. This is only to be used for iPhone.

Comment by dmitriy....@gmail.com, May 20, 2010

( Iphone 3G 16 gb. 3.1.2) When i try to execute command - i get "Killed" response. Any suggestions ?

Comment by dmitriy....@gmail.com, May 20, 2010

And yes - i've got the answer. To solve this Killed problem run

ldid -S /usr/bin/sendmodem

Comment by Zee.A.Z...@gmail.com, Aug 19, 2010

When I type sendmodem "AT+CPBS=\"ON\"" i get an error, any idea why is that?

Comment by axel50...@gmail.com, Sep 9, 2010

Does anyone know if it's working on the iPhone 4-4.0, and if it's still /dev/tty.debug as serial port ?

Comment by Tari...@gmail.com, Oct 4, 2010

Help!

This seems to have done something to my iPhone 4's modem; I get a big red dot on my call button, and the phone cannot detect any carrier signal!

Resetting settings didn't help; I guess the only way to fix it is a full restore using iTunes?? :(

If you have any suggestions, please help!

Comment by wwol...@gmail.com, Oct 25, 2010
TariqUR probably you disabled commcenter by launchctl

try launchctl load -w /System/Library/LaunchDaemons?/com.apple.CommCenter?.plist

Comment by VaterAnm...@gmail.com, Nov 10, 2010

Hi! Would You be so kind to help with iPhone 4 to send AT commands? I still not found any working solution to communicate the modem with....

Comment by sergeg...@gmail.com, Dec 2, 2010

I too seem to have trouble with sendmodem

sendmodem AT+CUSD=1,\"#100#\",15 doesnt return OK or Error

however, another USSD command AT+CUSD=1,\"#111#\",15 works, but the reply is only displayed on the iphone and not as a message in terminal

im running ios 4.2 with 05.13.04 baseband

i've also tried minicom and it works, however, i cannot make it save the output to a file

Comment by VaterAnm...@gmail.com, Dec 15, 2010

Is there anyone who can send AT commands to iPhone 4 iOS 4.1 or 4.2.1? Please PM me, I need your help. I still trying, but without any success, Any help would be appreciated.

Comment by nathan....@gmail.com, Dec 20, 2010

iPhone 3GS, iOS 4.1, baseband 6.15 (ipad baseband hack) Trying to use sendmodem to get my account balance. Normally, I would press "##122#", then 'call', and it would display my balance. This command seems to work, but produces no output.

-Nathans-iPhone:/usr/bin root# sendmodem "AT+CUSD=1,\"##122#\"" Sending command to modem: AT -.+

OK Sending command to modem: AT+CUSD=1,"##122#" -Nathans-iPhone:/usr/bin root#

It just produces a '-' character and then quits. Am I doing something wrong?

Comment by nathan....@gmail.com, Dec 20, 2010

however,

sendmodem "AT+XGENDATA"
works fine and shows all of my device info. Can anybody tell me what I'm doing wrong?

Comment by nikolaci...@gmail.com, Dec 21, 2010

Can anyone send sms from iphone 3GS iOS 4? Im trying with:

at+cmgf=1 at+cmgs="NUMBER" ENTER MESSAGE CTRL-Z

but it doesnt work....

(OR at+cmgs="+XXXXXXXX"\r\nMESSAGE\x1A)

Comment by nathan....@gmail.com, Dec 22, 2010

I've figured out my problem. Looking at the source code, the AT command only waits for 1 second for a response. I realized this when I used minicom, and the same command worked perfectly fine. A conventional USSD command is likely to take 5 or 6 seconds when requesting the balance of an account. I will try to fork the git repository and set a larger response timeout just for AT+CUSD commands, to fix this issue.

Comment by krishna....@gmail.com, Apr 6, 2011

Hi please let me know from where can i get sendmodem file to upload into iphone.

Comment by mallah.h...@gmail.com, Jul 19, 2011

sendmodem is blocking at:

Sending command to modem: AT ——————————————————————————————————-

and it continue like this for ever

Any advice?

Thanks


Sign in to add a comment
Powered by Google Project Hosting