Connect with us

help please, how to send data using AT commands?

Discussion in 'Microcontrollers, Programming and IoT' started by jimjim, Jan 31, 2012.

Scroll to continue with content
  1. jimjim

    jimjim

    3
    0
    Jan 31, 2012
    hello
    i have been written a program in J2ME(java microedition) for a mobile device with MT6225 processor for communicating to PC by using the COM4 serial port. when i used hyper terminal to test the app for send and receive, nothing showed up on hyper terminal window or mobile lcd. i have no error in my app. so i went to google and found that the mobile communicates to PC using the AT command set. so is it possible to use this command set for data transmition? e.g. AT+CSNS=4;[a string like "hello" here]
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    11,644
    2,691
    Nov 17, 2011
    Hi,
    AT commands are used to control modems and the like (e.g. setting modem speed etc.). They basically have nothing to do with the data transmitted or received. Even AT commands are just strings of bytes sent via the COM interface. SO in order for AT commands tow work you must first establish a working COM-port connection, which is obviously not the case here.

    Stating that you "have no error in [your] app" is a bit bold. There is no such thing as error-free software (unless trivial, maybe).

    There are a few things you could check:
    1) are the COM port parameters set correctly on both PC and Mobile? -> baudrate, parity, No. of start and stop bits?

    2) are both devices connected correctly? TxD needs to be connnected to RxD and vice versa. A common Ground (GND) connection is required, too.

    3) can you see any traffic on the data lines (verify with RS232 tester, oscilloscope or logic probe ore even multimeter, whatever is available).

    4) is hyperterminal set up correctly to listen to COM4? Is COM4 operational in the PC? Check, if possible, by attaching another serial device with known good function to COM4.

    5) do you use hardware handshake or software handshake (http://www.lammertbies.nl/comm/info/RS-232_flow_control.html)? Hardware handshale using RTS and CTS requires that these signals aer connected between PC and Mobile and the COM port parameters for hardware handshake be set up correctly. Software handshake doesn't need this connection. Sometimes it may be useful to connnect RTS and CTS at ech device directly (RTS-PC <> CTS-PC and RTS-Mobile <> CTS-Mobile). It may be worth testing.

    You can find loads of additional information here http://www.lammertbies.nl/comm/info/RS-232_specs.html (left column: Quick links).

    Regards,
    Harald
     
  3. Rleo6965

    Rleo6965

    585
    9
    Jan 22, 2012
    Its also better to connect DTR and DTS pins.
     
  4. jimjim

    jimjim

    3
    0
    Jan 31, 2012
    well if i send AT i get OK. ATD<num> and the mobile starts to dial. so i guess everything is set. my app is just 10 lines of code! just for testing the InputStream(j2me). anyway, the mobile is connected to USB port.

    i guess every string line that doesn't starts with AT is totally ignored by the phone. on the other hand when i start the app mobile asks me for a permission: "the Midlet program needs to communicate with PC directly. do you agree?" and so i press "Yes" and app starts.

    this doesn't make any sense! if the mobile allows direct communication as the permission message shows then why nothing can be transmitted?
     
  5. Harald Kapp

    Harald Kapp Moderator Moderator

    11,644
    2,691
    Nov 17, 2011
    It look like you're using the phone as a modem.
    That's why you need to send AT commands from the PC to the "modem" to establish a connection.
    Sorry, that's not what I expected from your original post. If you just want to send data to the mobile using the PC's COM port, you will have to set up a corresponding COM port on the mobile, too. Then the app on the mobile and hyperterminal (or any other porgram) on the PC can exchange data via the COM lines.

    Harald
     
  6. jimjim

    jimjim

    3
    0
    Jan 31, 2012
    the mobile only supports port 0. when i use the following code to open a connection it'll only accept the comm:0 connection and any other will throw an error which says that the port doesn't exist. here is how i establish the connection in java microedition:
    CommConnection con = new CommConnection("comm:0");
    so the sun manuall says that you should open the port by a string like this: comm:com0
    but my phone throws the error and when i asked nobody knew what went wrong.
    your reply is very intresting! so based on that if i connect my mobile by its cable which is provided by its company, i'm actually connecting my mobile "modem" to the pc! so if that is the case then why when i connect the mobile to my PC it's giving me the com port option?
    there are also other options like webcam, pict bridge and mass storage. so how is that work?
     
  7. Harald Kapp

    Harald Kapp Moderator Moderator

    11,644
    2,691
    Nov 17, 2011
    That's probably because a PC "speaks" to a modem via COM port?
    But I'm afraid the details of this now exceed my knowledge.

    Sorry, I hope you find someone with more detailed knowledge in this area.

    Harald
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-