# How do I issue an AT command (to modem) and get response?

Source: https://forum.modalai.com/topic/1597/how-do-i-issue-an-at-command-to-modem-and-get-response
Category: General Questions (https://forum.modalai.com/category/2/general-questions)
Posted: 2022-12-05 20:20:02 UTC by Ed Sutter
Replies: 15 · Views: 4068

## Ed Sutter · 2022-12-05 20:20:02 UTC

Hi,
I am sure I've done this before (maybe not, I'm tired!), but for some reason I can't issue an AT command to the LTE modem in such a way as to get a response.  In startup scripts I see **echo "AT!BLAH BLAH" >/dev/ttyUSB2**, but I'd like to issue "query" commands so I can see a response.  
Shouldn't I be able to just attach minicom (or similar) to /dev/ttyUSB2?

## Reply by tom (ModalAI staff) · 2022-12-05 20:29:01 UTC

@Ed-Sutter You sure can! See an example here: https://gitlab.com/voxl-public/voxl-sdk/utilities/voxl-modem/-/blob/master/scripts/voxl-modem-start.sh#L45

```
echo -ne "AT+QNWPREFCFG=\"mode_pref\",LTE:NR5G\r" | busybox microcom -t 1000 /dev/ttyUSB2
```

## Reply by Ed Sutter · 2022-12-05 21:14:37 UTC

Hey @tom , I'm concluding that I have a bad modem... I just stepped back to an older modem card and things worked as expected.   Thanks for the quick response.
Ed

## Reply by Ed Sutter · 2022-12-09 23:59:10 UTC

@tom Well, apparently there's still something odd going on...
I was able to access /dev/ttyUSB2 as expected when using the [VOXL Cellular LTE and USB hub add-on](https://www.modalai.com/products/voxl-lte?variant=32449203601459) (which has an RC7611 modem); however we are experimenting with using the Sierra Wireless EM7565, so I'm using an EM7565 plugged into a USB dongle which is then plugged into Voxl Flight Deck.  LTE comes up, VOXL establishes the wwan0 link and I'm able to communicate over it, so that's good.  The strange thing is that I can't issue any AT commands over /dev/ttyUSB2 when plugged into VOXL.  If I move the same USB/Modem configuration to my Linux host I am then able to do AT commands on /dev/ttyUSB2 just fine.   
Any idea why I would not be able to do this on VOXL?  I realize this is not your product, but if you have any ideas I'd appreciate your thoughts.

## Reply by tom (ModalAI staff) · 2022-12-10 00:47:05 UTC

@Ed-Sutter Does `/dev/ttyUSB2` come up at all? It could be there's another drive we're missing in order to enable coms over that port. Does it enumerate as something else on VOXL2 e.g. `/dev/ttyUSB3` ? 

Does `dmesg` give you any clues that may point you in the right direction.

## Reply by Ed Sutter · 2022-12-10 02:18:00 UTC

For sure /dev/ttyUSB2 comes up... All three (/dev/ttyUSB[012]) come up as soon as the modem is powered up.  Also, the init scripts in voxl assume its ttyUSB2, and the LTE connection does come up just fine.  
Regarding dmesg, honestly, I haven't looked at that simply because fundamentally the link is up and running (I've been streaming video over LTE with it).  I just can't probe things with AT commands. 
Just ran dmesg with USB as filter, below is some of that dump...
```
[    5.626078] qcserial 1-1.2:1.0: Qualcomm USB modem converter detected
[    5.626577] usb 1-1.2: Qualcomm USB modem converter now attached to ttyUSB0
[    5.655658] qcserial 1-1.2:1.2: Qualcomm USB modem converter detected
[    5.656186] usb 1-1.2: Qualcomm USB modem converter now attached to ttyUSB1
[    5.815383] qcserial 1-1.2:1.3: Qualcomm USB modem converter detected
[    5.815979] usb 1-1.2: Qualcomm USB modem converter now attached to ttyUSB2
```

## Reply by Ed Sutter · 2022-12-10 13:38:16 UTC (in reply to tom)

@tom Note, by the way, we are using VOXL1 (Flight Deck).

## Reply by Ed Sutter · 2022-12-12 16:24:07 UTC (in reply to tom)

@tom There is definitely different dmesg output when using the two different modems.
For the RC7611...
```
[   19.303681] usb 1-1.1: New USB device found, idVendor=1199, idProduct=68c0
[   19.303716] usb 1-1.1: New USB device strings: Mfr=3, Product=2, SerialNumber=4
[   19.303743] usb 1-1.1: Product: Qualcomm CDMA Technologies MSM
[   19.303766] usb 1-1.1: Manufacturer: Qualcomm, Incorporated
[   19.303788] usb 1-1.1: SerialNumber: 7e7dbded
[   19.343459] option 1-1.1:1.0: GSM modem (1-port) converter detected
[   19.345574] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB0
[   19.347060] option 1-1.1:1.2: GSM modem (1-port) converter detected
[   19.349603] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB1
[   19.351815] option 1-1.1:1.3: GSM modem (1-port) converter detected
[   19.353829] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB2
[   19.362619] mdss_register_panel: mdss mdp resource not initialized yet
[   19.362665] mdss_wb soc:qcom,mdss_wb_panel: unable to register writeback panel
[   19.373309] qmi_wwan 1-1.1:1.8: cdc-wdm0: USB WDM device
[   19.377024] qmi_wwan 1-1.1:1.8 wwan0: register 'qmi_wwan' at usb-xhci-hcd.0.auto-1.1, WWAN/QMI device, ffffffc06c1ebd10
[   19.383161] mdss_register_panel: mdss mdp resource not initialized yet
[   19.383184] mdss_wb soc:qcom,mdss_wb_panel: unable to register writeback panel
[   22.285452] usb 1-1.1: USB disconnect, device number 3
[   22.287788] option1 ttyUSB0: GSM modem (1-port) converter now disconnected from ttyUSB0
[   22.287966] option 1-1.1:1.0: device disconnected
[   22.289656] option1 ttyUSB1: GSM modem (1-port) converter now disconnected from ttyUSB1
[   22.289854] option 1-1.1:1.2: device disconnected
[   22.294800] option1 ttyUSB2: GSM modem (1-port) converter now disconnected from ttyUSB2
[   22.295177] option 1-1.1:1.3: device disconnected
[   22.296485] qmi_wwan 1-1.1:1.8 wwan0: unregister 'qmi_wwan' usb-xhci-hcd.0.auto-1.1, WWAN/QMI device
[   22.297369] [RMNET:HI] rmnet_config_notify_cb(): Kernel is trying to unregister wwan0
[   22.350081] [RMNET:HI] rmnet_config_notify_cb(): Kernel is trying to unregister wwan0
[   24.045813] msm-dwc3 7600000.hsusb: DWC3 in low power mode
[   30.455740] msm-dwc3 7600000.hsusb: DWC3 exited from low power mode
[   30.711346] usb 1-1.1: new high-speed USB device number 4 using xhci-hcd
[   30.812657] usb 1-1.1: config 1 has an invalid interface number: 8 but max is 3
[   30.812706] usb 1-1.1: config 1 has no interface number 1
```

then for the EM7565...
```
[    3.882936] usb 1-1.2: New USB device found, idVendor=1199, idProduct=9091
[    3.882948] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    3.882955] usb 1-1.2: Product: Sierra Wireless EM7565 Qualcomm\xffffffc2\xffffffae Snapdragon\xffffffe2\xffffff84\xffffffa2 X16 LTE-A
[    3.882961] usb 1-1.2: Manufacturer: Sierra Wireless, Incorporated
[    3.882969] usb 1-1.2: SerialNumber: UF92358533041506
[    3.893106] ufshcd 624000.ufshc: ufshcd_ioctl: User buffer is NULL!
[    3.908035] qcserial 1-1.2:1.0: Qualcomm USB modem converter detected
[    3.908701] usb 1-1.2: Qualcomm USB modem converter now attached to ttyUSB0
[    3.911484] mdss_register_panel: mdss mdp resource not initialized yet
[    3.911493] mdss_wb soc:qcom,mdss_wb_panel: unable to register writeback panel
[    3.933495] ufshcd 624000.ufshc: ufshcd_ioctl: User buffer is NULL!
[    3.938487] qcserial 1-1.2:1.2: Qualcomm USB modem converter detected
[    3.938850] usb 1-1.2: Qualcomm USB modem converter now attached to ttyUSB1
[    3.941502] mdss_register_panel: mdss mdp resource not initialized yet
[    3.941513] mdss_wb soc:qcom,mdss_wb_panel: unable to register writeback panel
[    3.961700] ufshcd 624000.ufshc: ufshcd_ioctl: User buffer is NULL!
[    3.962458] ufshcd 624000.ufshc: ufshcd_ioctl: User buffer is NULL!
[    3.964776] ufshcd 624000.ufshc: ufshcd_ioctl: User buffer is NULL!
[    3.970480] qcserial 1-1.2:1.3: Qualcomm USB modem converter detected
[    3.970849] usb 1-1.2: Qualcomm USB modem converter now attached to ttyUSB2
[    3.973775] mdss_register_panel: mdss mdp resource not initialized yet
[    3.973786] mdss_wb soc:qcom,mdss_wb_panel: unable to register writeback panel
[    4.003719] qmi_wwan 1-1.2:1.8: cdc-wdm0: USB WDM device
[    4.004200] qmi_wwan 1-1.2:1.8 wwan0: register 'qmi_wwan' at usb-xhci-hcd.0.auto-1.2, WWAN/QMI device, ffffffc0f080c390
[    4.006956] mdss_register_panel: mdss mdp resource not initialized yet
[    4.006966] mdss_wb soc:qcom,mdss_wb_panel: unable to register writeback panel
[    4.017858] ufshcd 624000.ufshc: ufshcd_ioctl: User buffer is NULL!
[    4.019045] ufshcd 624000.ufshc: ufshcd_ioctl: User buffer is NULL!
```
Do those errors on the EM7565 make any sense to you?

## Reply by tom (ModalAI staff) · 2022-12-12 17:58:24 UTC

@Ed-Sutter I'm not sure whether those errors are related to the Sierra modem or not. It might be worth reaching out to Sierra themselves about the issue? They may be able to provide any missing kernel patches if there are any.

## Reply by Ed Sutter · 2022-12-12 18:01:53 UTC (in reply to tom)

@tom I have been, see [here](https://forum.sierrawireless.com/t/em7565-in-usb-adapter-dev-ttyusb2-does-not-echo/28542).  They claim I'm using an old kernel, and running without their driver so they can't really help much.
I just updated to the 0.9 platform to see if that helps any.  My guess is it won't, but we'll see.

## Reply by Chad Sweet (ModalAI staff) · 2022-12-12 18:05:43 UTC

usually you just need to tell the kernel to associate the USB id with a driver. Has that been done where you have built your own kernel with the new USB device ID?

## Reply by Ed Sutter · 2022-12-12 18:07:49 UTC

@Chad-Sweet I forget the name of the file at the moment, but I did look into this a while back and the VID/PID for the EM7565 was already in your build, so I didn't do anything beyond that.

## Reply by Chad Sweet (ModalAI staff) · 2022-12-12 18:12:04 UTC

ah, shoot. that's an easy one :-)

## Reply by Ed Sutter · 2022-12-12 18:35:51 UTC

@Chad-Sweet  LOL, well I do have to go back now and "remember" what I did 'cause I just updated to the latest package and the wwan0 interface isn't coming up at all. :-(  Yikes!  I hope I took good notes.  :-(

## Reply by Ed Sutter · 2022-12-12 18:47:37 UTC

@Chad-Sweet FYI... to be clear, its only a problem with the EM7565 over USB, your modem card with the RC7611 works fine.

## Reply by Ed Sutter · 2022-12-12 18:58:36 UTC (in reply to Chad Sweet)

@Chad-Sweet Yet another update... after rebooting, and re-installing the EM7565, wwan0 did come up this time.  :-)  But I still have the problem that I can't communicate with /dev/ttyUSB2.  :-(
