HI
I am working on an application In VB.Net using AT commands to detect Comport, IMEI, IMSI, Mobile Model etc. of all Mobile Devices connected Via USB with Computer.
I want to display list of each Comport mapped with its IMEI,etc.
Like:-
Com1 Model IMEI IMSI
Com2 Model ImEI IMSI
..........so on.........
So, please explain how to proceed.
I used below code:-
Imports System.Windows
Imports System.IO.Ports
Public Class Form1
Dim SerialPort As New System.IO.Ports.SerialPort
Private lsp As New List(Of SerialPort)
Dim scana As Boolean
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For Each sname As String In My.Computer.Ports.SerialPortNames
lsp.Add(My.Computer.Ports.OpenSerialPort(sname))
Next
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
scana = True
For Each sp As SerialPort In lsp
My.Computer.FileSystem.WriteAllText(My.Computer.FileSystem.SpecialDirectories.Temp + "\MobileConnect.log", "", False)
My.Computer.FileSystem.WriteAllText(My.Computer.FileSystem.SpecialDirectories.Temp + "\MobileConnect.log", "Current Modem:" + ControlChars.NewLine, True)
sp.WriteLine("ATI3" + Chr(13))
Threading.Thread.Sleep(100)
My.Computer.FileSystem.WriteAllText(My.Computer.FileSystem.SpecialDirectories.Temp + "\MobileConnect.log", "IMEI:" + ControlChars.NewLine, True)
sp.WriteLine("AT+CGSN" + Chr(13))
Threading.Thread.Sleep(1000)
My.Computer.FileSystem.WriteAllText(My.Computer.FileSystem.SpecialDirectories.Temp + "\MobileConnect.log", "IMSI:" + ControlChars.NewLine, True)
sp.WriteLine("AT+CIMI" + Chr(13))
Threading.Thread.Sleep(100)
RichTextBox2.Text = My.Computer.FileSystem.ReadAllText(My.Computer.FileSystem.SpecialDirectories.Temp + "\MobileConnect.log")
scana = False
Next
Label4.Text = "Scanning Finished"
Catch
Label4.Text = "Scanning Error"
scana = False
End Try
End Sub
Private Sub SerialPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort.DataReceived
If scana = True Then
My.Computer.FileSystem.WriteAllText(My.Computer.FileSystem.SpecialDirectories.Temp + "\TMobMgr.log", SerialPort.ReadExisting, True)
End If
End Sub
End Class
When running, code doesn't execute after line- sp.WriteLine("ATI3" + Chr(13))
Please check
Thanks,
Jatin