Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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
Posted 2-Apr-13 2:52am
jatin77291
Edited 2-Apr-13 2:54am
v3
Comments
ThePhantomUpvoter at 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 at 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
0 OriginalGriff 7,800
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,790


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 2 Apr 2013
Copyright © CodeProject, 1999-2014
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