Making an application that uses a dial-up modem is not only tricky because of the hardware-software connection, but also for finding the right hardware and setting it up properly.

Be careful when you are buying a modem for caller id, make sure not only that it says “Support caller id”, but it must NOT have the word “(optional)”. If you are not sure ask the seller to verify it.

The code in VB.Net is really simple. But you must be careful of 2 things:

  • If you have to get caller id info and use it, ALWAYS, create a second application and find a way to pass the data to the main one.
  • Use timers and boolean flags to process the data from the modem. When you try to get the data right away it fails. You need to give the modem time to process the call and return the data in its own time.

Private Sub InitPorts()
Dim objSerialPort As SerialPort
objSerialPort = New System.IO.Ports.SerialPort(Me.components)
objSerialPort.PortName = sCurrentPort._sComPortName
objSerialPort.ParityReplace = &H3B ‘ replace “;” when parity error occurs
objSerialPort.BaudRate = 9600
objSerialPort.Parity = IO.Ports.Parity.None
objSerialPort.DataBits = 8
objSerialPort.StopBits = IO.Ports.StopBits.One
objSerialPort.Handshake = IO.Ports.Handshake.None
objSerialPort.RtsEnable = False
objSerialPort.ReceivedBytesThreshold = 1 ‘threshold: one byte in buffer > event is fired
objSerialPort.NewLine = vbCr ‘ CR must be the last char in frame. This terminates the SerialPort.readLine
objSerialPort.ReadTimeout = 30000
objSerialPort.DataReceived, AddressOf SerialPort_DataReceived
End Sub
Private Sub SerialPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs)
Dim CurrentSerialPort As SerialPort = CType(sender, SerialPort)
‘ Your code here
End Sub

Finally, in order to get the modem ready, to get the caller’s id, you have to pass the next 3 commands to it:

AT+GCI=B4 (B4 sets UK, 46 sets Greece, 42 sets Germany)
AT+FCLASS=8 (making it voice modem)
AT+VCID=1 (activate caller id)

Personally, I tried to set one up in UK and later in Greece, the UK (B4) worked right away without any problems, but in Greece it looks like (46) is not always the case. With Cosmote (46) worked fine, but with Wind (46) didn’t work. And because some suggested that Greece is following the German standards, I tried (42) and it worked.

Here are some country+codes BUT always check the manual. More for command and help here.

Code Country Code Country
09 Australia 6C Malaysia
0A Austria 73 Mexico
0F Belgium 7B Netherlands
20 Canada 7E New Zealand
31 Denmark 82 Norway
72 Europe 26 People’s Republic of China
3C Finland 89 Philippines
3D France 8B Portugal
04 or 42 Germany 9C Singapore
46 Greece 9F South Africa
50 Hong Kong A0 Spain
51 Hungary A5 Sweden
53 India A6 Switzerland
54 Indonesia A9 Thailand
57 Ireland AE Turkey
59 Italy B4 United Kingdom
00 Japan B5 United States of America
61 Korea BC Vietnam

Use PUTTY to check the modem and it’s support for caller id.

If you want to check what are the possible values of a command use the question mark like this: AT+GCI=?

If you want to check what is the current value of a command use the question mark like this: AT+GCI?

I found that the following site helpful, with troubleshooting : Modem-Frustration

If you have any questions or you need help with coding your application, please, send as an email and we will be happy to share our code and/or our experience with you.

info (at) smobilesoft (dot) com