完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,我正在使用C#,visa32和LAN Connection。
基于签证帮助文档,使用的函数可以是这样的,public static extern int viPrintf(int vi,string writeFmt,byte [] arr); 我的代码看起来像byte [] buffer; // length = 8972 viError = visa32.viPrintf(session,“MMEM:TRAN d:\ demofile.txt#48972%b”,缓冲区); //%b是否正确? viError = visa32.viPrintf(session,“ n”); // END终结器它返回错误-1073807297(VI_ERROR_INV_FMT),似乎writeformat字符串不正确。 我的问题是,应该使用哪种修饰符和格式代码? 1)“%b”? 2)“%y”? 非常感谢,如果有人可以分享您如何使用写入块数据格式化viprintf的经验。 谢谢! 以上来自于谷歌翻译 以下为原文 Hi, I am using C#, visa32 and LAN Connection. Base on visa help doc, the function used could be this, public static extern int viPrintf(int vi, string writeFmt, byte[] arr); and my code looks like, byte[] buffer; //length = 8972 viError = visa32.viPrintf(session, "MMEM:TRAN d:\demofile.txt #48972%b", buffer); //is %b correct? viError = visa32.viPrintf(session, "n"); //END Terminator it returns error -1073807297 (VI_ERROR_INV_FMT), seems writeformat string is not correct. My question is, which modifier and format code should be used? 1) " %b " ? 2) " %y " ? Very appreciated if anyone can share your experiences on how to format viprintf with writing block data. Thanks! |
|
相关推荐
5个回答
|
|
幸运的是,这是最近讨论过的(在C#中,不会少)。
另一个用户包括他们用于传输收集文件的代码:https://community.keysight.com/message/66655#comment-66655 以上来自于谷歌翻译 以下为原文 Luckily this was recently discussed (in C#, no less). Another user included their code for transferring a collected file: https://community.keysight.com/message/66655#comment-66655 |
|
|
|
btywyrww 发表于 2018-11-22 09:21 我道歉,我刚看到这个问题是关于以另一种方式传输文件(从PC到PNA)。 看起来你有一些命令权限(就命令字符串而言),但你遗漏了一些东西。 字符串应为:visa32.viPrintf(session,“MMEM:TRAN'd: demofile.txt',#48972%* ly”,长度,缓冲区); 有关viPrint格式的信息来自这里(向下看):http://www.ni.com/white-paper/4727/en/它提到如果你不包括块传输的长度说明符,它是 假设数据缓冲区的长度只有1个字节。 此外,命令字符串中的“y”占位符允许您在需要时指定数据顺序(endian-ness)。 我没有尝试自己运行,所以我不确定文件名后是否需要逗号(但应该要求单引号)。 也不确定尺寸后是否需要空间。 但是试一试 - 你应该有更多的运气。 以上来自于谷歌翻译 以下为原文 My apologies, I just saw that this question was about transferring files the other way (from PC to PNA). It looks like you sort of have the command rights (as far as the command string), but you're missing a couple of things. The string should read: visa32.viPrintf(session, "MMEM:TRAN 'd:demofile.txt', #48972%*ly", length, buffer); Information about viPrint formatting came from here (look towards the bottom): http://www.ni.com/white-paper/4727/en/ It mentions that if you don't include the length specifier for block transfers, it is assumed the data buffer is just 1 byte in length. Also, the 'y' placeholder in the command string allows you to specify data order if required (endian-ness). I didn't try running this myself, so I'm not sure if the comma is required after the filename (but the single quote SHOULD be required). Also not sure if there is a space required after the size. But give it a go - you should have more luck. |
|
|
|
btywyrww 发表于 2018-11-22 09:39 感谢您的回复,但viPrintf没有超载,需要从visa32.cs获取4个参数。 (它来自agilent IO lib,Not NI)[DllImportAttribute(“VISA32.DLL”,EntryPoint =“#269”,ExactSpelling = true,CharSet = CharSet.Ansi,SetLastError = true,CallingConvention = CallingConvention.Cdecl)] public static extern int viPrintf(int vi,string writeFmt,byte [] arr); 如果viPrintf只需要3个参数,有没有办法传输字节数组? 以上来自于谷歌翻译 以下为原文 Thanks for your reply but there is no overload of viPrintf that takes 4 arguments from visa32.cs. (it comes form agilent IO lib, Not NI) [DllImportAttribute("VISA32.DLL", EntryPoint = "#269", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true, CallingConvention = CallingConvention.Cdecl)] public static extern int viPrintf(int vi, string writeFmt, byte[] arr); is there any way to transfer byte array if viPrintf only takes 3 arguments? |
|
|
|
guanrui1202 发表于 2018-11-22 09:52 我不太清楚要告诉你什么。 我刚刚在此处提取了Agilent VISA用户指南:http://www.home.agilent.com/upload/cmc_upload/All/iols_15_5_visa_users_guide.pdf该指南在第41页上显示了viPrintf的示例调用:viPrintf(vi, writeFmt [,arg1] [,arg2] [,...]); 下一行显示了一个名为viVPrintf的函数,它只允许3个参数。 这是你在用什么? 以上来自于谷歌翻译 以下为原文 I'm not quite sure what to tell you. I just pulled up the Agilent VISA User's guide here: http://www.home.agilent.com/upload/cmc_upload/All/iols_15_5_visa_users_guide.pdf The guide shows, on page 41, an example call of viPrintf: viPrintf(vi, writeFmt[, arg1][, arg2][, ...]); The next line shows a function called viVPrintf which ONLY allows 3 arguments. Is that what you're using? |
|
|
|
btywyrww 发表于 2018-11-22 10:00 我只是意识到需要用户手动从visa32.dll导入viPrintf(int vi,string writeFmt,int pointCount,byte [] array)。 它默认情况下不包含在visa32.cs中,来自agilent io lib。 以上来自于谷歌翻译 以下为原文 I was just aware of that viPrintf(int vi, string writeFmt, int pointCount, byte[] array) need to be imported from visa32.dll by user manually. It is NOT included in visa32.cs by default from agilent io lib. |
|
|
|
只有小组成员才能发言,加入小组>>
1272 浏览 0 评论
2371 浏览 1 评论
2187 浏览 1 评论
2061 浏览 5 评论
2944 浏览 3 评论
1089浏览 1评论
关于Keysight x1149 Boundary Scan Analyzer
745浏览 0评论
N5230C用“CALC:MARK:BWID?”获取Bwid,Cent,Q,Loss失败,请问大佬们怎么解决呀
910浏览 0评论
1273浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-19 15:46 , Processed in 2.605659 second(s), Total 88, Slave 71 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号