LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

FASTRACK SUPREME - send ATD command via RS232??

Solved!
Go to solution

I work on project based on a FASTRACK SUPREME which has to receive commands via a serial RS232. The

problem is:
When I use HyperTerm the command ATDxxxxxxxxx; works fine.
When I use the CVI RS232 library nothing happens. Is it possible that my command remains blocked in

the serial buffer?
Here is my code:

#include <ansi_c.h>
#include <cvirte.h>
#include <userint.h>
#include <rs232.h>
#include <utility.h>
#include <formatio.h>
#include <string.h>

int configurePort(void);
int sendCommand(void);
int port_open;
int error;

int main()
{
 configurePort();
 sendCommand ();
 return 0;
}
int configurePort()
{
 port_open = 0;
 
 error = OpenComConfig (4, "COM4",115200 ,0,8,1,0, -1);
 if (error)
 {
  printf("Error!\n");
 }
 if (error == 0)
        {
        port_open = 1;
  SetXMode (4, 0);
  SetCTSMode (4, 0);
  SetComTime (4, 0);
        }
 
 
 return 0;
}
int sendCommand ()
{
 char bufferWrite[100] ;
 Fmt(bufferWrite,"%s","ATD0040761768027;");
    ComWrt(4, bufferWrite, 18);
 return 0;
}
Where is the problem? Please help!

 

 

0 Kudos
Message 1 of 3
(4,153 Views)
Solution
Accepted by topic author Annees

Hi Annees,

working with a modem may imply some additional precaution than working with other serial devices.

 

First of all, you say in Hyperterminal the modem receives commands: I seem to remember that Hyperterminal always adds a carriage return at the end of each command so you may want to try this first:

 

    ComWrt (4, "ATD0040761768027;\r", 18);

(BTW you can avoid passing through a string unless you need to format it dynamically during the program)

 

Next I would check in Hyperterminal if you are using some form of handshaking between the PC and the modem: if so, you need to satisfy the hanshaking even in your CVI application.

 

Third hint, your modem may need some initialization before it can fulfil an AT command; under Windows you can set the modem connection so that it creates a log file: create it and examine it to discover the full set of commands interchanged between HT and the modem.

 

Finally, I suppose this addresses also this thread question: it is a good practice to open only one thread per question so that everyone can add his experience and avoid dulicating questions / answers unnecessarily.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 3
(4,141 Views)

To see if any bytes remain in output buffer you can use the GetOutQLen function.

 

Do you need to press Enter after typing the ATD command to send the command during the HyperTerm session?

If yes, you need to append '\n' and/or '\r' characters after the command string in CVI code.

 

Other than that, are you sure you need a zero timeout?

It may have side effects that I am not aware of.

I would set it to smth nonzero, if it is not there for a reason.

 

Hope this helps,

S. Eren BALCI
IMESTEK
Message 3 of 3
(4,137 Views)