简体   繁体   中英

VB.net sending/recieving AT commands from SIM Card

ok, so i have been using Vb for a while but brand new to communicating with devices.

I have a HP Elitebook 820 which has a SIM card slot, what id like to do is display the SIM card info - specifically the serial number. I have done a bit of searching and found lots of people talking about AT commands. after a bit more searching i gave it a try.

    Dim com1 As SerialPort = New System.IO.Ports.SerialPort

    com1.PortName = "COM6"

    com1.Open()

    If com1.IsOpen Then
        com1.Write("AT+CIMI")
        Dim result As String
        result = com1.ReadExisting
        MsgBox(result)
    Else
        MsgBox("port not open")
    End If

No Errors but just blank string returned. Could anyone help me out by letting me know, first if this even possible and second am i going about it the right way?

Step 1. Fetch a copy of the V.250 modem standard and read at least all of chapter 5. That will teach you a lot of basic AT command handling, like for instance that an AT command line should be terminated with \\r .

Step 2. The very best documentation is your modem manufacturer's specific documentation which you definitely should try to get hold of that, however for basic mobile phone commands like AT+CIMI you can use the 3GPP spec 27.007 as well (assuming the manufacturer has not deviated in its implementation. Sometimes they do for some commands so this is something to watch out for (hence my recommendation to first and foremost get the modem manufacturer's specific documentation). The AT+CIMI command is however so simple there is nothing to deviate from really.).

Step 3. The reception handling, eg result = com1.ReadExisting is way too simplistic. You MUST read and parse every single line of response from the modem until you get a Final result code back (most commonly OK or ERROR , but there are several others). Any other way cannot work reliably. See this answer for pseudo code structure of how to do it properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM