2010-06-21 2 views
0

Je travaille sur un projet basé sur un FASTRACK SUPREME qui doit recevoir des commandes via une RS232 série. Le problème est: Lorsque j'utilise HyperTerm la commande ATDxxxxxxxxx; fonctionne bien. Lorsque j'utilise la bibliothèque CVI RS232, rien ne se passe. Est-il possible que ma commande reste bloquée dansEnvoi d'une commande ATD à un Fastrack Supreme via RS232 dans LabWindows/CVI

le tampon série? Voici mon 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; 
} 

Où est le problème? S'il vous plaît aider! Merci.

Répondre

0

J'ai essayé votre code tel qu'il était. Je ne suis pas sûr de ce que vous entendez par "rien ne se passe" Quand j'ai utilisé le code tel qu'il est (sauf que je devais utiliser le port 2) tout a bien fonctionné. le nombre de caractères était de 18 sur la fonction ComWrt.

Assurez-vous que le port de communication que vous essayez d'utiliser est disponible.

à l'exception de votre #includes, voici votre code avec des mods mineures que je courais sur mon PC, Windows XP en cours d'exécution CVI 2010:

#define PORT 2 
#define PORTNAME "COM2" 

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

int main() 
{ 
    configurePort(); 
    sendCommand(); 
    return 0; 
} 
int configurePort() 
{ 
    port_open = 0; 

    error = OpenComConfig (PORT, PORTNAME,115200 ,0,8,1,0, -1); 
    if (error) 
    { 
     printf("Error!\n"); 
    } 
    if (error == 0) 
     { 
      port_open = 1; 
      SetXMode (PORT, 0); 
      SetCTSMode (PORT, 0); 
      SetComTime (PORT, 0); 
     } 
return 0; 
} 
int sendCommand() 
    { 
     char bufferWrite[100] ; 
     Fmt(bufferWrite,"%s","ATD0040761768027;"); 
     error = ComWrt(PORT, bufferWrite, sizeof("ATD0040761768027;")); 
     return 0; 
    } 
Questions connexes