Mr·GE 2023-04-23 16:40 采纳率: 51.5%
浏览 5
已结题

labwindows/CVI ComRd卡

串口收发数据,结果在读数据的时候卡了,卡在了ComRd处,请问是为什么?

int CVICALLBACK tt (int panel, int control, int event,
                    void *callbackData, int eventData1, int eventData2)
{
    int Byte_send;
    int Strlen;
    unsigned char ReadBuf[20]={0};
    unsigned char Receive[9]={0};
    double weiyi;
    
    int ReceiveData=0;
    switch (event)
    {
        case EVENT_TIMER_TICK:
            FlushInQ(6);
            FlushOutQ(6);
            Byte_send=ComWrt(6,Write,8);
            //Strlen=GetInQLen(6);
            ComRd(6,ReadBuf,20);
            for(int i=0;i<9;i++)
            {
                Receive[i]=ReadBuf[i+5];
            }
            sprintf(Receive,"%c%c%c%c%c%c%c",Receive[0],Receive[1],Receive[3],Receive[4],Receive[5],Receive[6],Receive[7]);
            weiyi=atof(Receive);
            SetCtrlVal(panelHandle,PANEL_NUMERICMETER,weiyi);
            FlushInQ(6);
            FlushOutQ(6);
            break;
    }
    return 0;
}

定时器设置为1秒,发送正常,接收的时候能卡5-10秒才收到数,函数参考NI的例程,为什么会出现卡的问题?

  • 写回答

1条回答 默认 最新

  • CSDN-Ada助手 CSDN-AI 官方账号 2023-04-23 18:32
    关注
    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 7月10日
  • 创建了问题 4月23日

悬赏问题

  • ¥15 java代码写在记事本上后在cmd上运行时无报错但又没生成文件
  • ¥15 关于#python#的问题:在跑ldsc数据整理的时候一直抱这种错误,要么--out识别不了参数,要么--merge-alleles识别不了参数(操作系统-linux)
  • ¥15 PPOCRLabel
  • ¥15 混合键合键合机对准标识
  • ¥100 现在不懂的是如何将当前的相机中的照片,作为纹理贴图,映射到扫描出的模型上
  • ¥15 魔霸ROG7 pro,win11.息屏后会显示黑屏,如图,如何解决?(关键词-重新启动)
  • ¥15 有没有人知道这是哪里出了问题啊?要怎么改呀?
  • ¥200 C++表格文件处理-悬赏
  • ¥15 Windows Server2016本地登录失败
  • ¥15 复合卡卡号轨道写入芯片卡