Electronic Engineer Discuss

View: 16080|Reply: 8
Print Prev. thread Next thread

二次开发,如何在程序中连接HDG2002B

[Copy link]

1

Threads

5

Posts

5

Credits

新手上路

Rank: 1

Credits
5
Jump to specified page
1#
Post time 2016-11-24 12:22:31 | Show the author posts only Reply Awards |Descending |Read mode
我想在我的程序里通过SCPI命令控制HDG2002B,如何才能连接到设备呢?
首先,我尝试使用Windows API CreateFile, Delphi代码如下:

procedure TfrmVIMain.Button1Click(Sender: TObject);
var
  hFile: THandle;
  S: AnsiString;
  BytesWrote, Err: Cardinal;
begin
  hFile := CreateFile('\??\USB#VID_049F&PID_505B#HTG10000522222#{a5dcbf10-6530-11d2-901f-00c04fb951ed}',
                          GENERIC_READ or GENERIC_WRITE,
                          FILE_SHARE_READ or FILE_SHARE_WRITE,
                          nil,
                          OPEN_EXISTING,
                          FILE_ATTRIBUTE_NORMAL,
                          0);
  if hFile = INVALID_HANDLE_VALUE then
    ShowMessage('Failed to connect')
  else
  try
    S := 'SYSTem:BEEP'#10;
    if not WriteFile(hFile, PAnsiChar(S)^, Length(S), BytesWrote, nil) then
    begin
      Err := GetLastError;
      Caption := IntToStr(Err);
    end;
  finally
    CloseHandle(hFile);
  end;
end;

CreateFilech成功返回了一个句柄,但是 WriteFile失败了,错误码是6(无效句柄),我也尝试ReadFile,得到同样的错误.

贵公司一位工程师说,可以通过安装安捷伦的KeySight软件包,使用其中的visa32.dll来与设备通信.
我下载并安装了,但是使用KeySight Connection Expert无法检测到HDG2002B.
那么我怎么能使用viOpen(sesn, rsrcName, accessMode, timeout, vi)来指定rsrcName名呢?

请指教,谢谢!
Reply

Use magic Report

167

Threads

2070

Posts

2232

Credits

版主

Rank: 7Rank: 7Rank: 7

Credits
2232
2#
Post time 2016-11-25 09:50:21 | Show the author posts only



请将您的电脑设备管理器截图给我看一下。

1

Threads

5

Posts

5

Credits

新手上路

Rank: 1

Credits
5
3#
 Author| Post time 2016-11-25 10:54:18 | Show the author posts only
amy replied at 2016-11-25 09:50
请将您的电脑设备管理器截图给我看一下。



驱动应该是安装正常了,TTSource软件也可以正常连接和控制设备.

Keysight扫描结果:



This post contains more resources

You have to Login for download or view attachment(s). No Account? Register

x

167

Threads

2070

Posts

2232

Credits

版主

Rank: 7Rank: 7Rank: 7

Credits
2232
4#
Post time 2016-11-25 11:19:52 | Show the author posts only
需要把原来的驱动卸载,然后重启电脑,才能与Keysight软件连接。

1

Threads

5

Posts

5

Credits

新手上路

Rank: 1

Credits
5
5#
 Author| Post time 2016-11-25 13:26:12 | Show the author posts only
好的,在我删除DDS Source Device时选择删除驱动程序后,IVI的驱动程序自动被使用上了,现在可以了.

谢谢!

1

Threads

5

Posts

5

Credits

新手上路

Rank: 1

Credits
5
6#
 Author| Post time 2016-11-25 13:33:50 | Show the author posts only
另外,在我的程序安装包中打包visa.dll的话,我理解存在版权问题?

0

Threads

29

Posts

29

Credits

新手上路

Rank: 1

Credits
29
7#
Post time 2016-11-25 16:03:32 | Show the author posts only
南飞雁 replied at 2016-11-25 13:33
另外,在我的程序安装包中打包visa.dll的话,我理解存在版权问题?

我不知道你的意思,仅仅打包visa.dll不行,必须完全安装kesight suit套件才能与设备通信。

1

Threads

5

Posts

5

Credits

新手上路

Rank: 1

Credits
5
8#
 Author| Post time 2016-11-25 17:24:43 | Show the author posts only
Hantek_Zhang replied at 2016-11-25 16:03
我不知道你的意思,仅仅打包visa.dll不行,必须完全安装kesight suit套件才能与设备通信。
...

明白了,我以为visa.dll就可以了.

原先想仅仅打包visa.dll,但那是安捷伦的库文件,所以我直接在我的安装包理打包使用的话,我担心侵犯他们的版权.
如果要安装整个keysight suit套件的话,那我更要担心版权问题了,因为我从keysight的版权声明看,如果没有购买他们的产品,是不能使用keysight的,这就是我的担心.

167

Threads

2070

Posts

2232

Credits

版主

Rank: 7Rank: 7Rank: 7

Credits
2232
9#
Post time 2016-11-28 14:34:30 | Show the author posts only
南飞雁 replied at 2016-11-25 17:24
明白了,我以为visa.dll就可以了.

原先想仅仅打包visa.dll,但那是安捷伦的库文件,所以我直接在我的安装包 ...

安捷伦的库文件是公开可以使用的,不存在版权问题。
You have to log in before you can reply Login | Register

Points Rules

Dark room|Mobile|Archiver|Electronic Engineer Discuss

2024-4-20 23:48 GMT+8 , Processed in 0.164632 second(s), 21 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

Quick Reply To Top Return to the list