Test modem on COM port

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
Kris
Posts: 375
Joined: Wed May 12, 2010 3:22 am

Test modem on COM port

Post by Kris »

Hi all,

I have a Siemens TC55 modem on COM1 to send SMS notifications.
However, sometimes it hangs and is unreachable.

Is there a way to test if the modem is still alive?
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

You may setup Text Log test to check GSM log file, specified on SMS:GSM page of Options dialog.
E.g. Text Log test may check this log file for "Error:" string and start assigned actions.

Please check the manual for more information:
http://www.ks-soft.net/hostmon.eng/mfra ... tm#textlog
Kris
Posts: 375
Joined: Wed May 12, 2010 3:22 am

Post by Kris »

Even though I'd rather would have had a real COM port test, this solution will do the trick as well :)

Thanks!
Kris
Posts: 375
Joined: Wed May 12, 2010 3:22 am

Post by Kris »

Since reading the logfile for something that went wrong already isn't very predictive :P I decided to write a small program to send a AT command to the COM port and waits for response.

If no response it will timeout in HM and set the test in "Unknown" status, which in turn triggers a email action.

Just wanted to share :)
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

We wrote VB script that can send AT commands and check for response from GSM modem. It can be used with Shell Script test method:
http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell

Code: Select all

Option Explicit

const statusAlive       = "scriptRes:Host is alive:"
const statusDead        = "scriptRes:No answer:"
const statusUnknown     = "scriptRes:Unknown:"
const statusNotResolved = "scriptRes:Unknown host:"
const statusOk          = "scriptRes:Ok:"
const statusBad         = "scriptRes:Bad:"
const statusBadContents = "scriptRes:Bad contents:"

'---- entry point ----
Const ForReading = 1
Const ForWriting = 2

DIM fso, com, s, objArgs

Set objArgs = WScript.Arguments

IF objArgs.Count<>4 Then
WScript.StdOut.Write statusUnknown & "Expected parameters <COM port> <speed> <AT command> <Expected response> E.g.: COM2 19200 AT OK"
Wscript.Close
End if

Set fso = CreateObject("Scripting.FileSystemObject")
Set com = fso.OpenTextFile(objArgs(0) & ":" & objArgs(1) & ",N,8,1", ForWriting)
com.WriteLine(objArgs(2))
com.Close()
Set com = fso.OpenTextFile(objArgs(0) & ":" & objArgs(1) & ",N,8,1", ForReading)
com.ReadLine
s = com.ReadLine
if s = objArgs(3) then
WScript.StdOut.Write statusOk & s
else
WScript.StdOut.Write statusBad & s
end If
com.Close()
Start CMD: cmd /c cscript /B /E:VBScript %Script% %Params%

Script requires four parameters: <COM port> <speed> <AT command> <Expected response>. E.g. COM2 19200 AT OK

This script works well on our Windows 7, however we couldn't manage to run it correctly on Windows XP :(
Post Reply