Help with Caller ID app please

Hello,

I need some help with this project, I would like to have the caller ID displayed.

I have this code in the DataReceived Event Handler of my project

dim initString as string = "AT&FE0S0=0S6=2S7=10S8=2S9=255S29=70"
initString = initString + chr(13)

dim cidStrings() as string
cidStrings.append "#CID="
cidStrings.append "+VCID="
cidStrings.append "%CCID="
cidStrings.append "#CC"
cidStrings.append "*ID"
cidStrings.append "+FCLASS=8;+VCID="
cidStrings.append "#CLS=8#CID="
cidStrings.append "+CLIP="

Dim TheRightOne as string
TheRightOne = "*ID"

// enable Caller ID reporting
'dim cidONCmd as string = "AT&FE1S0=0"+cidStrings(TheRightOne)+"1"+endofLine.Macintosh
dim cidONCmd as string = "AT&FE1S0=0" + TheRightOne + "1" + endofLine.Macintosh

// disable Caller ID reporting
'dim cidONCmd as string = "AT&FE1S0=0"+cidStrings(TheRightOne)+"0"+endofLine.Macintosh
'cidONCmd = "AT&FE1S0=0" + TheRightOne +"0" + endofLine.Macintosh
// // The above is the meat of the whole process. I hope this can be useful to some of you.


Var data As String
data = Me.LookAhead(Encodings.ASCII)
If data.IndexOf(EndOfLine.Windows) > -1 Then
  TextArea1.Text = TextArea1.Text + Me.ReadAll(Encodings.ASCII)
End If

Xojo Version 2023 Release 3
macOS Monterey
Version 12.7

Mac mini (Late 2014), Processor 3 GHz Dual-Core Intel Core i7
Memory 16 GB 1600 MHz DDR3

The modem I am using is Caller ID capable.

This is what is displayed:
Screenshot Caller ID Serial Device Bar Code Reader

The Caller ID is not displayed.

Any suggestions to have this rectified?

Thanks.

Lennox

Does the telephone line also provide called id. Some providers charge for the service?

Do you have a telephone that supports it that you can plug in to test it with?

Yes, I have a Southwestern Bell Jumbo Caller ID which displays the caller ID.

All of my playing with caller ID predates my use of Xojo, and was done in Visual Basic back in the day. But my recollection is that these modem commands were not standardized, and you had to do brand if not model specific stuff to get caller ID to work. At least back in those days.

So are you sure the commands you are sending to the modem are correct?

I do not know much about modems and modem commands, those commands were taken from Desktop Phone Dialer - #4 by Lennox_Jacob1 and https://www.youtube.com/watch?v=xJUWdamf5g.

All I want to do is to have the caller ID displayed in my app and I can then get the other info from my database. I can do that if I have the Called ID displayed in my app.

I do have a Southwestern Bell Jumbo Caller ID which displays the caller ID, but I would have to manually input that data into my app and that is cumbersome.

Thanks.

Lennox

I am using an old fashion modem that supports CID…

When my app starts I have to turn on the modem’s support for CID as it is not active by default. CID needs to be on before the first ring is received… So you cannot turn it on in the DataReceived event… it is too late… at least on my modem. I do this with the following command:

Serial1.write “AT+VCID=1” + chr(13)

Note the chr(13) and not a chr(10)… but VCID is not used by all modems or phones… you will have to check the manual to get the correct command.

Hope this helps

Do you not have the instruction book for the device? If so, does it have a summary of the commands it accepts and what they do? If you don’t have it, look for the manual with Google. It’s bound to be downloadable from somewhere.

I don’t see anything which initialises the line speed between you and the modem. How do you know the modem is even receiving your commands? It’s 40 years since I did this stuff, but I seem to recall having to send two or three cr(13) to a modem to have it deduce the line speed. I’d start by forgetting the CID for the moment, and setting up a small test framework so you can send commends one by one by hand and then interrogate the modem to check it has changed state. Then I recall one state was whether or not it echoes your command or sends back “OK” or something when it gets a good command. How does it react if you send it junk? Just sending a stream of data without checking or knowing the effect seems a bit random to me.

This is the modem, no manual…

https://www.amazon.com/dp/B08H5R598Y?psc=1&ref=ppx_yo2ov_dt_b_product_details

So I have to Initialize the modem, I do not know how to do that, I would think that I need to put some code in the Opening event of the app.

Lennox

I gave you an example in my post… Yes once you have opened the port write something like:

Serial1.write “AT+VCID=1” + chr(13)

another possibility is send:

“AT#CID=1”

I suggest writing a simple xojo app that lets you write any command (from a text field) to the modem and display the response in the DataReceived. If the command is supported and works you should get back an “OK”.

Take a look at: What initialization command should I use for my modem? : Chronos for other possible commands.

Download putty, and work out the serial commands via it first, once you get them working, put them into your project.

1 Like

Thanks Jim,

I did not see the example, is it Serial1.write “AT+VCID=1” + chr(13) or is it a project?
I tried “AT+VCID=1” and it did not work.

I have this code in the connect button now:

If Me.Caption = "Disconnect" Then // Disconnect from the serial device
  SerialConnection1.Close
  'MessageBox("The selected serial device now closed.")
  Me.Caption = "Connect"
  DevicesPopupMenu.Enabled = True
  DeviceListUpdator.RunMode = Timer.RunModes.Multiple 'turn it on
Else // Connect to the serial device
  // Set the serial device to the index of the one chosen in the popup menu
  SerialConnection1.Device = SerialDevice.At(DevicesPopupMenu.SelectedRowIndex)
  'MessageBox("The selected serial device now opened.")
  
  // Initialize the modem:
  'The modem init string is built with:
  '&F = reset to factory settings
  
  //     https://forum.xojo.com/t/desktop-phone-dialer/42175/4
  // E0 = set echo off
  // S0=0 = turn off auto-answering
  // S7=10 = wait X seconds for carrier prior to hang up
  // S8=2 = set comma pause to 2 seconds
  // S9=255 = set minimum time for carrier recognition to 255/10 of second
  // S29=70 = set the flash modifier duration in units of 10ms
  // X4 or X3 = wait/noWait for dial tone
  // M0 = mute speaker
  // M2Ln = speaker always on and volume level to n
  
  'dim initString as string = "AT&FE0S0=0S6=2S7=10S8=2S9=255S29=70"
  
  'if WaitDialTone then
  'initString = initString + "X4"
  'else
  'initString = initString + "X3"
  'end if
  '
  'select case SoundVolume
  'case 0
  'initString = initString + "M0"
  'case 1
  'initString = initString + "M2L1"
  'case 2
  'initString = initString + "M2L2"
  'case 3
  'initString = initString + "M2L3"
  'end select
  
  'initString = initString + chr(13)
  // // After the initialization, to dial a voice phone number here it’s the dial command:
  // The modem dial string is built with:
  // D = dial
  // P = pulse or  T = tone
  // ^ = disable/enable calling tone (this is a toggle)
  
  'dim dialString as string
  '
  'dialString = "ATDT^" + numToDial + chr(13)
  // // For caller id, it’s simpler. The only thing to pay attention is there are different commands for this, depending on the hardware. Below are the most common (if not all) variations of commands to enable caller id reporting.
  // Initialization string depends from the modem brand/model
  // and it's generally one of the following.
  // Try them in order until you get an OK answer. ERROR answer means is not a valid command
  
  dim initString as string = "AT&FE0S0=0S6=2S7=10S8=2S9=255S29=70"
  initString = initString + chr(13)
  
  dim cidStrings() as string
  cidStrings.append "#CID="
  cidStrings.append "+VCID="
  cidStrings.append "%CCID="
  cidStrings.append "#CC"
  cidStrings.append "*ID"
  cidStrings.append "+FCLASS=8;+VCID="
  cidStrings.append "#CLS=8#CID="
  cidStrings.append "+CLIP="
  
  Dim TheRightOne as string
  TheRightOne = "*ID"
  
  // enable Caller ID reporting
  'dim cidONCmd as string = "AT&FE1S0=0"+cidStrings(TheRightOne)+"1"+endofLine.Macintosh
  dim cidONCmd as string = "AT&FE1S0=0" + TheRightOne + "1" + endofLine.Macintosh
  'dim cidONCmd as string = "AT&FE1S0=0" + "AT+VCID=" + "1" + endofLine.Macintosh
  'dim cidONCmd as string = "AT+VCID=1" + endofLine.Macintosh
  
  'Msgbox cidONCmd
  
  '// disable Caller ID reporting
  'dim cidONCmd as string = "AT&FE1S0=0"+cidStrings(TheRightOne)+"0"+endofLine.Macintosh
  'cidONCmd = "AT&FE1S0=0" + TheRightOne +"0" + endofLine.Macintosh
  
  // The above is the meat of the whole process. I hope this can be useful to some of you.
  
  
  Try
    SerialConnection1.Connect
    DevicesPopupMenu.Enabled = False
    DeviceListUpdator.RunMode = Timer.RunModes.Off
    Me.Caption = "Disconnect"
  Catch error As IOException
    Beep
    MessageBox("The selected serial device could not be opened.")
  End Try
End If

and this in tkeDataReceived event:

Var data As String
data = Me.LookAhead(Encodings.ASCII)
If data.IndexOf(EndOfLine.Windows) > -1 Then
  TextArea1.Text = TextArea1.Text + Me.ReadAll(Encodings.ASCII)
End If

I will try it tomorrow and let you know.

I will also try the info from What initialization command should I use for my modem? : Chronos for other possible commands.

Thanks again.

Lennox

Hi Daniel,

Where can I download “putty”?

Thanks.

Lennox

https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

Putty does SSH/Telnet/raw/Serial connections

OK - this probably doesn’t apply since it’s a USB modem.

I do notice that the Product Description / Packagae List does say a CD with driver and User Manual are included. Any help there?

Hi Tim,

The CD has only stuff for PC, .exe apps, nothing for Mac.
There is a leaflet with the following text:

KEY FEATURES

Modem

• V.92 (upto 56 kbps download, 48 kbps upload)
• V.90 (upto 56 kbps download, 38 kbps upload)
• V.34 (4.8 Kbps to 33.6 Kbps)
• V.32 bis (4.8 Kbps to 14.4 Kbps)
• V.23 (75 bps to 1.2 Kbps)
• V.22 bis (50 bps to 2.4 Kbps)
• V.21. Bell 103 / Bell 212
Automode
• V.44/V. 42bis/MNP 5 datacompression
• V.42/MNP2-4 error correction
• V.59 Diagnostic
• Hayes AT Command set
• TIES escape code
• Quick Connect (V .92)

Fax
• Group 3, Class 1
• V.17
• V.29
• V.27 ter

Voice Features
• ADPCM voice compression
• Digital Answering Machine

Telephony Services
• Wake Up on Ring
• Ring detection
• On/Off hook control
• Call progress monitor
• DTMF detection and generation
• Voice/fax/modem distinction
• Caller ID (optional)
• Modem on Hold (V.92)

Video Cohferencing
• V.80/H.324 interface support

Operating System Support
• Windows(98,98SE,ME,2000, XP
• Vista, Win7, Win 8 , Win 10 )

Power Consumption
• <50mA Operating Mode
• <0.5mA Stand-by

Diagnostic Tool
• Modem Helper

I have revised the project:

In the Connect Button Pressed Event Handlerr I have:

If Me.Caption = "Disconnect" Then // Disconnect from the serial device
  SerialConnection1.Close
  'MessageBox("The selected serial device now closed.")
  Me.Caption = "Connect"
  DevicesPopupMenu.Enabled = True
  DeviceListUpdator.RunMode = Timer.RunModes.Multiple 'turn it on
  
Else // Connect to the serial device
  // Set the serial device to the index of the one chosen in the popup menu
  SerialConnection1.Device = SerialDevice.At(DevicesPopupMenu.SelectedRowIndex)
  'MessageBox("The selected serial device now opened.")
  
  Try
    SerialConnection1.Connect
    DevicesPopupMenu.Enabled = False
    DeviceListUpdator.RunMode = Timer.RunModes.Off
    Me.Caption = "Disconnect"
  Catch error As IOException
    Beep
    MessageBox("The selected serial device could not be opened.")
  End Try
  
  // Initialize the modem:
  'The modem init string is built with:
  '&F = reset to factory settings
  
  //     https://forum.xojo.com/t/desktop-phone-dialer/42175/4
  // E0 = set echo off
  // S0=0 = turn off auto-answering
  // S7=10 = wait X seconds for carrier prior to hang up
  // S8=2 = set comma pause to 2 seconds
  // S9=255 = set minimum time for carrier recognition to 255/10 of second
  // S29=70 = set the flash modifier duration in units of 10ms
  // X4 or X3 = wait/noWait for dial tone
  // M0 = mute speaker
  // M2Ln = speaker always on and volume level to n
  
  dim initString as string = "AT&FE0S0=0S6=2S7=10S8=2S9=255S29=70"
  initString = initString + EndOfLine.macOS
  
  // enable Caller ID reporting
  dim cidONCmd as string
  
  '// reset the  modem:
  'cidONCmd = "ATZ"
  
  // Initialization string depends from the modem brand/model and it's generally one of the following.
  // Try them in order until you get an OK answer. ERROR answer means is not a valid command
  Dim TheRightOne as string
  TheRightOne = "#CID=1"
  'TheRightOne = "+VCID=1"
  'TheRightOne = "%CCID=1"
  'TheRightOne = "#CC1"
  'TheRightOne = "*ID1"
  'TheRightOne = "+FCLASS=8;+VCID=1"
  'TheRightOne = "#CLS=8#CID=1"
  'TheRightOne = "+CLIP="
  
  // enable Caller ID reporting
  cidONCmd = "AT&FE1S0=0" + TheRightOne + EndOfLine.macOS
  'Msgbox cidONCmd
  
End If

and in the Serial Connection1 Event Handler “DataReceived” I have this:

Var data As String
data = Me.LookAhead(Encodings.ASCII)
If data.IndexOf(EndOfLine.Windows) > -1 Then
  TextArea1.Text = TextArea1.Text + Me.ReadAll(Encodings.ASCII)
End If

// Try them in order until you get an OK answer. ERROR answer means is not a valid command
I do not get OK or ERROR.

Thanks again

Lennox

EndOfLine.macOS is a line feed = chr(10)… I think you need chr(13) a “return”.

You have a lot of code under the comment “Initialize the modem”, but I don’t see where you’re actually writing any of that to the serial device.

Hi Tim,

Where, in what event, do I code the (“Initialize the modem”, but I don’t see where you’re actually writing any of that to the serial device)?
How do I write code to the serial device?

Thanks.

Lennox

SerialConnection1.Write(something)

You are setting SerialConnection1.Device. And you are calling Connect. But then you have a lot of code that sets initString and TheRightOne and cidONCmd, but you’re not writing cidONCmd to SerialConnection1 to initialize it and ask it to send you caller iDs.

That should happen in the same Connect Button Pressed event where you set up SerialConnection1.Device.