Search code examples
linuxadbat-commandredmi-device

adb shell cmgs AT command in pdu mode on Redmi 7 not working


I run these commands:

cat /dev/smd7 & echo "AT+CSCS=\"GSM\";\r" > /dev/smd7
cat /dev/smd7 & echo "AT+CMGF=0;\r" > /dev/smd7
cat /dev/smd7 & echo "AT+CMGS=24;\r" > /dev/smd7

Then I enter the PDU message:

07...985C369F01

I get this output:

/system/bin/sh: 07...985C369F01: not found

Solution

  • Let's analyze the two commands you provide to your shell:

    cat /dev/smd7 &
    echo "some_data" > /dev/smd7
    
    1. cat /dev/smd7 &: Listen to device /dev/smd7: from now on all data coming from that device will be redirected to the stdout (the shell you are writing in). Do it in background (&) in order to be able to send further commands
    2. echo "some_data" > /dev/smd7: send some_data to device /dev/smd7

      1. The connection with the device is open
      2. The data is sent
      3. The connection is closed and the control comes back to the shell

    When you send echo "AT+CMGS=24;\r" > /dev/smd7

    1. AT+CMGS=24;\r is sent to the device
    2. The connection is closed
    3. ... in the meanwhile the device sends back > prompt character telling you that it is waiting for the PDU message
    4. ... but the shell has the control. The > prompt is just a print on the shell, so any sent data will be directly sent to the shell!
    5. Since the sent data is not a shell command, the not found error is shown

    In conclusion, in order to send correctly the PDU message to the device, just keep sending it through echo command:

    echo "07...985C369F01" > /dev/smd7
    

    Note: Make sure to terminate the sequence with CTRL+Z character (ASCII 0x1A).