Click here to Skip to main content
13,045,790 members (45,882 online)
Rate this:
Please Sign up or sign in to vote.

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.

Com1 Model IMEI IMSI

Com2 Model ImEI IMSI 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
    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))
                My.Computer.FileSystem.WriteAllText(My.Computer.FileSystem.SpecialDirectories.Temp + "\MobileConnect.log", "IMEI:" + ControlChars.NewLine, True)
                sp.WriteLine("AT+CGSN" + Chr(13))
                My.Computer.FileSystem.WriteAllText(My.Computer.FileSystem.SpecialDirectories.Temp + "\MobileConnect.log", "IMSI:" + ControlChars.NewLine, True)
                sp.WriteLine("AT+CIMI" + Chr(13))
                RichTextBox2.Text = My.Computer.FileSystem.ReadAllText(My.Computer.FileSystem.SpecialDirectories.Temp + "\MobileConnect.log")
                scana = False
            Label4.Text = "Scanning Finished"

            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


Posted 2-Apr-13 1:52am
Updated 2-Apr-13 1:54am
ThePhantomUpvoter 2-Apr-13 9:13am
Probably because you are just blindly sending commands to the serial ports without setting them up, opening them for communication, or knowing that the device attached to the serial port supports the commands you are sending to it.
jatin77 3-Apr-13 11:01am
Okay..Please Guide how to open the communication port and about setting up the Port.
Also when i detect the available COM ports , i got Two Com Ports(one sending,one receiving) for each Mobile Device. When i send command to receiving Com Port, it works.
So,how to determine the receiving Com Port?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 2 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100