2010-06-21 2 views
0

저는 FASTRACK SUPREME을 기반으로 한 프로젝트에서 작업합니다.이 프로젝트는 직렬 RS232를 통해 명령을 수신해야합니다.LabWindows/CVI에서 RS232를 통해 Fastrack Supreme으로 ATD 명령을 보내십시오.

문제는 다음과 같습니다. HyperTerm을 사용할 때 ATDxxxxxxxxx 명령을 사용합니다. 잘 작동합니다. CVI RS232 라이브러리를 사용할 때 아무 일도 발생하지 않습니다. 내 명령이 차단 된 상태 일 가능성이 있습니까

직렬 버퍼가 있습니까?

#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; 
} 

문제가 : 여기 내 코드? 도와주세요! 감사합니다. .

답변

0

나는 당신의 코드를 그대로 사용했다. 나는 당신이 "아무 일도 없다"는 것을 확신하지 못한다. 나는 코드를 그대로 사용했을 때 (나는 포트 2를 사용해야했다.) 모든 것이 잘 작동했다. 문자 수는 ComWrt 함수에서 18입니다.

사용하려는 COM 포트를 사용할 수 있는지 확인하십시오.

#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; 
    } 
: 당신의 #include를을 제외하고

, 여기에 2010 내 PC에서 실행 사소한 개조와 코드, WINXP 실행 CVI이다
관련 문제