Posted on 2004-11-06
Last Modified: 2012-05-05
Hi Experts

I work with GSM modems everyday that need to be configured via a hyperterminal session with 5 or 6 AT commands before they can be used properly.

I have been trying to find a solution for automating this task - or at least simplifying it.

I began by trying to copy and paste the "script" into a hyperterminal session, but for some strange reason it keeps changing the commands which results in errors. I tried importing a txt file with the same result... changes in the commands.

So what I am looking for is either a solution whereby I can "paste" or "import" this script into hyperterminal or preferably try and emulate the hyperterminal session is access.

I have been told that one can use the MSCOMM tool to this end, but would not know where to start.

In a perfect senario here is how I would like the system to work:
- - - - - - - - - - - - -
1. A form in the database opens with options to type in 5 or 6 commands.
2. Once these commands have been entered a button called "Write Script" should be clickable.
3. When the button is clicked a window should pop up asking for the COM port settings (port number, rate, etc)
4. Once these have been selected another button called "Update" should be clickable.
5. When this button is clicked a "hyperterminal" session needs to be created and the 5 or 6 commands sent to the modem.
6. Ideally, I would like these commands to be visible to the user so that if a problem occurs the user will see the error message and can rectify the problem. (Each commands either gives feedback ending in OK or ERROR)
7. Once completed successfully a dialog box should pop up saying "settings updated"
8. If an error occurs a dialog box stating the error should be displayed.

If the above senario won't work I have managed to get the following working:

1. I have hard-coded the scripting into a module in my database.
2. When the user clicks a macro which initialises this module, it copies the text of the script to the clipboard and the user can paste this script into a hyperterminal window.
3. At the moment all of the commands paste on one line perfectly. What I need is a way to emulate the ENTER key in between commands so that the hyperterminal session can process each command separately.
4. I have tried the Chr(10) option but this doesnt work in Hyperterminal.

Here is the code for the scripting I have that pastes to the clipboard. Unfortunately, due to the proprietory AT commands, I cannot paste the actual coding (but this shouldnt effect the outcome at the end):

Dim ManPass As String
Dim ChangePass As String
Dim Operator As String
Dim ManNumbers As String
Dim Purse As String
Dim LowPurse As String
Dim LockSim As String
Dim Save As String

Dim Script As String

ManPass =
ChangePass =
Operator =
ManNumbers =
Purse =
LowPurse =
LockSim =
Save = "AT" & Chr(38) & "W"

Script = ManPass & Chr(10) & ChangePass & Chr(10) & Operator & Chr(10) & ManNumbers & Chr(10) & Purse & Chr(10) & LowPurse & Chr(10) & LockSim & Chr(10) & Save & Chr(10)

ClipBoard_SetData ([Script]) ' This calls a module which copies the [Script] info to the clipboard.


At the moment the Chr(10) works perfectly when pasting into notepad or any other window but when doing it in Hyperterminal it results in strange characters popping out and not the ENTER key being emulated.

I would prefer the actual emulation of the entire process through access, but if anyone can offer a solution to the 2nd option it will suffice in the short-term.

Thx Experts..

Question by:StanKobrin
    LVL 44

    Accepted Solution

    Chr(10) is the linefeed character.  Try the carriage return character Chr(13).  In fact Hyperterminal may require them both, Chr(13) & Chr(10)
    LVL 27

    Expert Comment

    Hi Stan, GRayL,

    you can use vbcrlf in place of
    Chr(13) & Chr(10)


    Author Comment

    Hey jaffer, GRayL:

    Both of your options work perfectly.

    Except for 1 major problem: The same thing is happening as when I was importing the txt file.
    The first two lines of commands work perfectly - then it starts to paste garbage to the screen (mixtures of all the remaining commands)

    Is there a known reason for this and if so,. is there a solution?

    Or... is there a way I can screate my own hyperterminal session through access by opening a connection to the COM port using MSCOMM trick?

    Thx Stan
    LVL 44

    Expert Comment

    Sorry Stan, I'm all out of suggestions.  I haven't used hyperterminal in over three years.  
    LVL 27

    Expert Comment

    Sorry Stan, same here, I only commented on what GRayL posted.
    LVL 44

    Expert Comment

    Stan:  I opened hyperterminal and checked help.  When you dig into it, you can find a couple of lines about opening hyperterminal from the command line.  Open hyperterminal, click Help, How To, Set up a new connection, Using a command line. You have to know the path to where the app is.  You can open an app from the immediate pane of Access using the shell command:

    shell "c:\mypath\hyperterminal.exe/t<enter your command line parameters here>"
    LVL 50

    Expert Comment

    by:Steve Bink
    Do not accept this as an answer.

    I am positive you can use MSCOMM to set up the modem like you want, but since I've never used that object, I cannot provide any details.  The last time I worked with modems in that way was pre-Win95, and it was on the basic hardware level communicating with the port's chip.  If you're interested in pursuing this option, let me know and I'll be happy to explore it with you.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
    I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now