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
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