Temporarily I will only give minor codes and concept. Other codes are to follow for I'm not the one who wrote them.
Ok let's start!
First rule. You can't communicate with the modem or it doesn't get detected unless the CD drive that is loaded at first insert of the device gets ejected.
Dim CDROMDeviceQuery As New SelectQuery("Win32_CDROMDrive") Dim CDROMDeviceSearch As New ManagementObjectSearcher(CDROMDeviceQuery) Dim CDROMDeviceInfo As ManagementObject For Each CDROMDeviceInfo In CDROMDeviceSearch.Get() If CDROMDeviceInfo("caption").ToString.Contains("ZTE") Then Dim tst As New VolumeEject tst.Eject(CDROMDeviceInfo("drive").ToString.Replace(":", "")) End If Next
The code above will try to enumerate all available DVD/CD ROM drives in your computer and search for the ZTE CD drive, then ejects it. After it ejects the drive, the modem will then be detected and you can start using it.
Now that the modem is available and ready we will now try to initialize it. In this example I'm going to put the port number manually but of course the best way is to enumerate all ports especially if you have multiple modems installed.
Dim serialport As New IO.Ports.SerialPort With serialport .PortName = "COM14" .BaudRate = 96000 .Parity = Parity.None .DataBits = 8 .StopBits = StopBits.One .Handshake = Handshake.RequestToSend .ReadTimeout = 300 .WriteTimeout = 300 .Encoding = Encoding.GetEncoding("iso-8859-1") .DtrEnable = True .RtsEnable = True .NewLine = vbCrLf End With serialport.Open()
TO BE CONTINUED... LOL
0 comments:
Post a Comment