打印
[ZLG-ARM]

求助汽车电子或用过CVI编程的朋友

[复制链接]
6231|19
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
hotpower|  楼主 | 2007-3-31 03:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
沙发
hotpower|  楼主 | 2007-4-1 03:54 | 只看该作者

自己半夜顶一下~~~

郁闷~~~好长时间没见汽车电子的身影了~~~很是挂念~~~

今天看见汽车电子给菜农玩的网站也被人攻占了~~~

菜农的域名没了~~~

使用特权

评论回复
板凳
王紫豪| | 2007-4-1 18:26 | 只看该作者

re:

ComSetEscape
int ComSetEscape (int COMPort, int escapeCode);

Purpose
Directs a COM port to carry out an extended function such as clearing or setting the RTS signal line or setting the transceiver mode for RS-485. The serial device driver defines the extended functions.

Not all device drivers support all escape codes. ComSetEscape returns Unknown System Error (-1) when the device driver does not support a particular escape code.

Parameters
Input 
Name Type Description 
COMPort integer A number that indicates the COM port on which to operate.

This number is paired with deviceName, which represents the COM port, during the OpenComConfig function call.

Default Value: 1—COM1
Valid Range: 1—1,000 
escapeCode integer The escape code of the extended function. Use the following values:

CLRDTR—Clears the DTR (data-terminal-ready) signal.

CLRRTS—Clears the RTS (request-to-send) signal.

GETMAXCOM—Returns the maximum COM port identifier the system supports. This value ranges from 0x00 to 0x7F, such that 0x00 corresponds to COM1, 0x01 to COM2, 0x02 to COM3, and so on.

SETDTR—Sends the DTR signal.

SETRTS—Sends the RTS signal.

SETXOFF—Causes the port to act as if it has received an XOFF character.

SETXON—Causes the port to act as if it has received an XON character.

You can use the following values only with the National Instruments RS-485 serial driver:

WIRE_4—Sets the transceiver to four-wire mode.

WIRE_2_ECHO—Sets the transceiver to two-wire DTR controlled with echo mode.

WIRE_2_CTRL—Sets the transceiver to two-wire DTR controlled without echo.

WIRE_2_AUTO—Sets the transceiver to two-wire auto TXRDY controlled mode.  

Return Value
Name Type Description 
result integer The result of this function call. This code is a negative value that specifies the type of error that occurred. 

使用特权

评论回复
地板
hotpower|  楼主 | 2007-4-1 18:54 | 只看该作者

谢谢~~~ComSetEscape我试过不行~~~

去年汽车电子给了我一些串口通的CVI6.0片段.
由于对6.0不太满意就放下了.

现在都8.0/8.1了,功能很强.

所以就准备放弃Delphi玩CVI了.

数据库/注册表等都已学会.就串口的DTR/RTS让我头晕~~~

这是我按例程改的,但都不行.所以只能求助了~~~
    //打开并配置串口
//    OpenComConfig (1, "", 38400, 0, 8, 1, 512, 512);
//    SetXMode (1, 0);
//    SetCTSMode (1, LWRS_HWHANDSHAKE_CTS_RTS_DTR);
//    SetCTSMode (1, LWRS_HWHANDSHAKE_CTS_RTS_DTR);
//    SetCTSMode (1, LWRS_HWHANDSHAKE_OFF);
        
    
//    ComSetEscape (1, 6);
//    ComSetEscape (1, 4);
    
//    ComSetEscape (1, 4);
//    ComSetEscape (1, 5);
    
    
//    ComSetEscape (1, SETRTS);
//    ComSetEscape (1, CLRRTS);
//    ComSetEscape (1, SETDTR);
//    ComSetEscape (1, CLRDTR);
//    ComSetEscape (1, CLRRTS | CLRDTR);
    


再次感谢!!!估计只能等汽车电子回归了~~~

使用特权

评论回复
5
王紫豪| | 2007-4-1 19:02 | 只看该作者

呵呵,CVI倒是玩的比较熟,就是DTR没用过。。不好意思

使用特权

评论回复
6
hotpower|  楼主 | 2007-4-1 19:06 | 只看该作者

倒塌了~~~要想搞定LPCARM必须过DTR/RTS~~~

汽车电子当时的程序被格式化了~~~惨痛呀~~~

我估计应该和SetCTSMode()等有关系.

使用特权

评论回复
7
hotpower|  楼主 | 2007-4-1 20:44 | 只看该作者

哈哈~~~搞定了~~~

就是用ComSetEscape();
估计昨晚是硬件问题.
再者就是变换DTR/RTS时,必须在打开串口时,否则蹦出错误.
晕~~~SPCOMM可没这个问题~~~

刚做CVI菜鸟,确实晕水~~~.

真是没C++就太难了~~~,满天的全局变量---2.5个字:晕+水

    //打开并配置串口
    OpenComConfig (1, "", 38400, 0, 8, 1, 512, 512);
    SetXMode (1, 0);
    SetCTSMode (1, LWRS_HWHANDSHAKE_OFF);
    GetCtrlVal (panelHandle, PANEL_CHECKBOX_1, &val);
    if (val == 0) ComSetEscape (1, CLRDTR);
    else ComSetEscape (1, SETDTR);
    GetCtrlVal (panelHandle, PANEL_CHECKBOX_2, &val);
    if (val == 0) ComSetEscape (1, CLRRTS);
    else ComSetEscape (1, SETRTS);
    //给串口Com1安装指定的回调函数,当输入队列满50个字符时产生中断
    InstallComCallback (1, LWRS_RECEIVE, 50, 0, ComCallback, callbackdata);

使用特权

评论回复
8
hotpower|  楼主 | 2007-4-1 21:17 | 只看该作者

想请教王紫豪同志1个CVI的问题(原为2个问题)

第1个问题:  CVI链接ADO数据库问题.
已解决~~不错~~~不过还是在操作记录和字段时比delphi麻烦很多~~~

    //建立数据库联接,并获得联接句柄
//    hdbc = DBConnect ("Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=D:\LabWindows\14\user.mdb;");
//    hdbc = DBConnect ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\LabWindows\14\user.mdb;Persist Security Info=False"); 
    hdbc = DBConnect ("Provider=MSDASQL.1;Persist Security Info=False;Data Source=client");
//    hdbc = DBConnect ("DSN=client");
    DisplayPanel (panelHandle);
    RunUserInterface ();
    DiscardPanel (panelHandle);
    
    //当退出应用程序时,关闭数据库连接
    DBDisconnect (hdbc); 



第2个问题: CVI调用控制台程序并取其结果问题
如CreateProcess().
在delphi里是这样的:
function TForm1.WinExecAndWait32(FileName: string; Visibility: Integer; var ShowString: string): Cardinal;
var
  sa: TSecurityAttributes;
  hReadPipe, hWritePipe: THandle;
  ret: BOOL;
//  strBuff: array[0..255] of Char;
  strBuff: array[0..4095] of Char;
  lngBytesread: DWORD;
  WorkDir: String;
  StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
begin
  FillChar(sa, Sizeof(sa), #0);
  sa.nLength := Sizeof(sa);
  sa.bInheritHandle := True;
  sa.lpSecurityDescriptor := nil;
  CreatePipe(hReadPipe, hWritePipe, @sa, 0);

  WorkDir := ExtractFileDir(Application.ExeName);
  FillChar(StartupInfo, Sizeof(StartupInfo), #0);
  StartupInfo.cb := Sizeof(StartupInfo);
  StartupInfo.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
  StartupInfo.wShowWindow := Visibility;

  StartupInfo.hStdOutput := hWritePipe;
  StartupInfo.hStdError := hWritePipe;

  if not CreateProcess(
    nil,
    PChar(FileName),               { pointer to command line string }
    @sa,                           { pointer to process security attributes }
    @sa,                           { pointer to thread security attributes }
    True,                          { handle inheritance flag }
//    CREATE_NEW_CONSOLE or          { creation flags }
    NORMAL_PRIORITY_CLASS,
    nil,                           { pointer to new environment block }
    PChar(WorkDir),                { pointer to current directory name, PChar}
    StartupInfo,                   { pointer to STARTUPINFO }
    ProcessInfo)                   { pointer to PROCESS_INF }
    then
  begin
    Result := INFINITE {-1};
  end
  else
  begin
    ret := CloseHandle(hWritePipe);
    ShowString := ';
    while ret do
    begin
      FillChar(strBuff, Sizeof(strBuff), #0);
      ret := ReadFile(hReadPipe, strBuff, 256, lngBytesread, nil);
      ShowString := ShowString + strBuff;
    end;

    Application.ProcessMessages;
    WaitforSingleObject(ProcessInfo.hProcess, INFINITE);//
    GetExitCodeProcess(ProcessInfo.hProcess, Result);
    CloseHandle(ProcessInfo.hProcess);  { to prevent memory leaks }
    CloseHandle(ProcessInfo.hThread);
    CloseHandle(hReadPipe);
  end;
end;

if WinExecAndWait32(str, ShowModeSele, buff) = 0 then
  Memo1.Lines.Add(buff);

这样即可收到进程FileName(EXE文件)在DOS界面的显示结果.

下图就是Keil应用CreateProcess()回显的成功例子,我用以上程序也调通了.
水潭里应该有帖图.



先在此感谢了~~~

使用特权

评论回复
9
王紫豪| | 2007-4-2 19:55 | 只看该作者

hotpower大叔

取控制台的结果还真的没整过,记得cvi里面有定向标准输出的函数,叫什么SetStdioPort,有时间研究一下!
另外你的delphi看着真让人头疼...看不懂

使用特权

评论回复
10
computer00| | 2007-4-3 00:43 | 只看该作者

蛮好看的,有空我也来玩玩.

使用特权

评论回复
11
hotpower|  楼主 | 2007-4-3 19:00 | 只看该作者

哈哈~~~终于找到老师了~~~

王紫豪先生,收菜农做弟子吧~~~家教费用如何收???

厉害~~~可以正式拜您为CVI老师吗???

哈哈~~~
相关链接:http://www.cpubbs.com/forum/viewthread.php?tid=2134&extra=page%3D1

使用特权

评论回复
12
王紫豪| | 2007-4-3 20:37 | 只看该作者

hotpower老大谦虚了,我还想败你为师呢!!

强烈支持老大付出那么多,写这些东东!!!

使用特权

评论回复
13
xiaomo| | 2007-4-4 23:42 | 只看该作者

顶一下两位高手!

使用特权

评论回复
14
hotpower|  楼主 | 2007-4-5 02:09 | 只看该作者

倒塌了~~~我才刚刚上路~~~

使用特权

评论回复
15
hotpower|  楼主 | 2007-4-5 12:23 | 只看该作者

晕菜了~~~一下搞了6种~~~

可能还有几种吧~~~不过一种就足够了~~~

记着不要用它搞"熊猫"呀~~~

相关链接:http://www.**/blog/hotpower/20689/message.aspx

使用特权

评论回复
16
hotpower|  楼主 | 2007-4-12 23:45 | 只看该作者

终于倒塌了CVI之ADO~~~一阵晕沉~~~

使用特权

评论回复
17
lpf336| | 2007-4-13 13:04 | 只看该作者

俺也回次帖吧

使用特权

评论回复
18
hotpower|  楼主 | 2007-4-17 21:20 | 只看该作者

汽车电子看我这个学生能否毕业~~~

使用特权

评论回复
19
汽车电子| | 2007-4-17 22:12 | 只看该作者

好,你竟然搞到数据库工具了

   有空我也玩玩,向你讨教。

使用特权

评论回复
20
hotpower|  楼主 | 2007-4-17 22:22 | 只看该作者

倒塌了~~~SQL Toolkit有bug,这是用纯种的ADO做的~~~

有时间QQ???(换号了)

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1460

主题

21619

帖子

506

粉丝