Results 1 to 2 of 2

Thread: VB.net sending/recieving AT commands from SIM Card

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2015
    Posts
    9

    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 i'd like to do is read and 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.


    Code:
    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? i was told that i would have to go through all the responses from the port but i dont really know what this means

  2. #2
    Frenzied Member
    Join Date
    May 2014
    Location
    Central Europe
    Posts
    1,388

    Re: VB.net sending/recieving AT commands from SIM Card

    i'd guess that at the time you sent "AT+CIMI" and then read existing the devices response has not yet arrived. you can simply put a 1 second delay after the write to see if this assumtion is true. for final code you should change this to more clever approches with threads/events.
    (untested)
    Code:
    Dim com1 As SerialPort = New System.IO.Ports.SerialPort
    
        com1.PortName = "COM6"
    
        com1.Open()
    
        If com1.IsOpen Then
            com1.Write("AT+CIMI")
            Threading.Thread.Sleep(1000)
            Dim result As String
            result = com1.ReadExisting
            MsgBox(result)
        Else
            MsgBox("port not open")
        End If

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width