首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在LabWindows/CVI中通过RS232向Fastrack发送ATD命令

在LabWindows/CVI中通过RS232向Fastrack发送ATD命令
EN

Stack Overflow用户
提问于 2010-06-22 05:56:54
回答 1查看 1.3K关注 0票数 0

我在一个基于FASTRACK至上的项目中工作,它必须通过串行RS232接收命令。这个

问题是:当我使用HyperTerm时,命令ATDxxxxxxxxx;工作正常。当我使用CVI RS232库时,没有任何反应。是否可能我的命令仍然被阻止在

串行缓冲区?下面是我的代码:

代码语言:javascript
复制
#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;
}

问题出在哪里?请帮帮我!谢谢。

EN

回答 1

Stack Overflow用户

发布于 2011-04-23 05:43:42

我试过你的代码了。我不确定你所说的“什么都没有发生”是什么意思,当我原样使用代码时(除了我不得不使用端口2),一切都运行得很好。ComWrt函数中的字符数为18个。

确保您尝试使用的com端口可用。

除了你的#includes之外,下面是我在我的PC上运行的带有次要mods的代码,WinXP运行CVI2010:

代码语言:javascript
复制
#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;
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3088788

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档