凌华PCI-DASK驱动程序中严重的bug!!! 点击:3735 | 回复:6



nuaa

    
  • 精华:0帖
  • 求助:0帖
  • 帖子:6帖 | 3回
  • 年度积分:0
  • 历史总积分:74
  • 注册:2001年5月30日
发表于:2002-07-21 17:43:00
楼主
我有幸被某奸商宰了一刀,花了8000多买了一块microcomputerboard 的CIO-DAS1602/12数据采集卡,却发现“凌华PCI-DASK驱动程序中严重的bug!!!” 请看samples 中SDK9112Dma是如何在VC中调用AI_ContScanChannels()的,结果发现pci-dask有严重的问题: In PCI-dask samples SDK9112Dma, // allocate a memory for user DMA buffer mem_size=data_size*2; hMem = GlobalAlloc(GMEM_ZEROINIT,mem_size); ????????? ai_buf = GlobalLock(hMem); ??????????????? if (ai_buf == NULL ) { MessageBox(hWnd,"INT", "No Memory", MB_OK); } GlobalFix(hMem); AI_9112_Config(card,TRIG_INT_PACER); AI_AsyncDblBufferMode(card, 0); AI_ContScanChannels (card, channel, range, ai_buf, data_size, (F64)sample_rate, SYNCH_OP); //AI_ContReadChannel(card, channel, AD_B_5_V, ai_buf, data_size, (F64)sample_rate, SYNCH_OP); { The GlobalAlloc function allocates the specified number of bytes from the heap. In the linear Win32 API environment, there is no difference between the local heap and the global heap. If the function succeeds, the return value is the handle of the newly allocated memory object. } 既然在DASK2000 Device Driver Configuration中定义了PCI9112的AI Buffer, 用函数AI_InitialMemoryAllocated ()也能返回buffer的大小,可为什么还要在SDK9112Dma中用: hMem = GlobalAlloc(GMEM_ZEROINIT,mem_size); ai_buf = GlobalLock(hMem); 再重复申请内存?????? 本来应当直接有个函数返回DASK2000 Device Driver Configuration中定义了PCI9112的AI Buffer的句柄,这样就能直接在AI_ContScanChannels (card, channel, range, ai_buf, data_size, (F64)sample_rate, SYNCH_OP);中调用buffer了。 其实看看AI_ContScanChannels()中ai_buffer,应该是申请内存区的句柄,而不是指针或别的。 在PCI-dask help中关于buffer是这样解释的: { Buffer : An integer array to contain the acquired data. The length of Buffer must be equal to or greater than the value of parameter ReadCount. The acquired data is stored in interleaved sequence. For example, if the value of Channel is 3, and the scanned channel numbers is descending (e.g. PCI-9112), then this function input data from channel 2, then channel 1, then channel 0, then channel 2, then channel 1, ... The data acquired is put to Buffer by order. So the data read from channel 2 is stored in Buffer[0], Buffer[3], Buffer[6], ... The data from channel 1 is stored in Buffer[1], Buffer[4], Buffer[7], ... The data from channel 0 is stored in Buffer[2], Buffer[5], Buffer[8], ... If double-buffered mode is enabled, this buffer is of no use, you can ignore this argument. Please refer to Appendix C, AI Data Format for the data format in Buffer. } 真不知道这个驱动是谁写的,出了这么大的bug竟然到了3.23版还没人发现, I fu l adlink! 如果不是我用delphi写程序,可能那些自诩VC高手还在不停的按照SDK9112Dma 中的GlobalAlloc, GlobalLock,GlobalFree写下去。 那个NuDAQ PCI Configuration Utility其实一点用也没有。 microcomputerboard 的Universal Library 中的函数为: 1.cbWinBufAlloc() Description: Allocates a Windows global memory buffer which can be used with the scan functions and returns a memory handle for it. Function Prototype: C/C++: int cbWinBufAlloc (long NumPoints) Visual Basic: Function cbWinBufAlloc(ByVal NumPoints&) As Long Delphi: function cbWinBufAlloc (NumPoints:Longint):Integer; Arguments: NumPoints Size of buffer to allocate. Specifies how many data points (16-bit integers, NOT bytes) can be stored in the buffer. Returns 0 if buffer could not be allocated or a non-zero integer handle to the buffer. 2.int cbAInScan () C/C++: int cbAInScan (int BoardNum, int LowChan, int HighChan, long Count, long *Rate, int Range, int MemHandle, int Options) Visual Basic: Function cbAInScan(ByVal BoardNum&, ByVal LowChan&, ByVal HighChan&, ByVal Count&, Rate&, ByVal Gain&, ByVal MemHandle&, ByVal Options&) As Long Delphi: function cbAInScan (BoardNum:Integer; LowChan:Integer; HighChan:Integer; Count:Longint; var Rate:Longint; Gain:Integer;MemHandle:Integer; Options:Integer):Integer; 3.cbWinBufToArray() Description: Copies data from a Windows memor



李侃

  • 精华:22帖
  • 求助:0帖
  • 帖子:30帖 | 813回
  • 年度积分:0
  • 历史总积分:1015
  • 注册:2002年2月27日
发表于:2002-07-05 16:56:00
1楼
PCIS-DASK的用户友好性确实不太好。 关于DASK2000 Device Driver Configuration中给板卡设定的Buffer和在pci-9112 dma例子程序中用Globalalloc分配的buffer其实是两种概念了。用中断和DMA操作都需要对一段连续的内存进行操作,DASK2000 Device Driver Configuration给PCI-9112分配的buffer是预先向windows系统申请的buffer,windows 在启动时会尝试留出一段DASK2000 Device Driver Configuration所定义的连续buffer。这个buffer PCI-9112不用的时候,别的程序也可以使用,但PCI-9112如果要用的话,则最多只能用这么多。通常这个Buffer可以设的大一点,但有时候系统可能分配不了这么多连续的Buffer,所以需要用AI_InitialMemoryAllocated ()函数确认一下。 在用户程序中,AI_ContScanChannels (card, channel, range, ai_buf, data_size, (F64)sample_rate, SYNCH_OP)中的ai_buffer是PCI-9112一次DMA调用buffer了。这个buffer可以用Gloalalloc分配,也可以简单的用一个数组代替----长度不要超过DASK2000 Device Driver Configuration所定义的Buffer。 PCIS-DASK的用户友好性将会在4.0得到改进: 1。具有代码自动生成器 2。具有在线用户入门指导 3。提供delphi和BCB的例子 PCIS-DASK 4.0的稳定版本可能在十月份出现。 其实从驱动的稳定性和性能上,我个人认为PCIS-DASK很不错。

nuaa

  • 精华:0帖
  • 求助:0帖
  • 帖子:6帖 | 3回
  • 年度积分:0
  • 历史总积分:74
  • 注册:2001年5月30日
发表于:2002-07-05 21:47:00
2楼
其实我觉得没有必要让用户去用AI_InitialMemoryAllocated ()函数确认一下。首先引起我的误解。 这种方式也未必好, 这个buffer可以用Gloalalloc分配, 也可以简单的用一个数组代替----长度不要超过DASK2000 Device Driver Configuration所定义的Buffer。----〉only VB.

国安

  • 精华:1帖
  • 求助:0帖
  • 帖子:3帖 | 242回
  • 年度积分:0
  • 历史总积分:256
  • 注册:2002年4月15日
发表于:2002-07-11 15:12:00
3楼
关于这个问题,我想是不同的厂家的驱动做法不同。 其实以我所知,凌华板卡的驱动的取初也是提供底层的Buffer直接供客户调用的,但你也知道,现在高手很少、俗手很多,搞不清楚又乱用,造成系统死锁。所以后来就采用了这种方法。 顺便提醒一下,PCIS-DASK和DASK2000是两个驱动,不要搞混了。 另外如果调用的话,是不一定要用GlobalAlloc一类函数的,其实只要用new I16[10000]或是类似的函数就可以了。这一点可能是做例子的人一直写底层写惯了。

SH007

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 3回
  • 年度积分:0
  • 历史总积分:53
  • 注册:2002年7月21日
发表于:2002-07-21 17:43:00
4楼
NUAA: 你好! CIO-DAS1602/12数据采集卡并非凌华产品,而你却说"凌华PCI-DASK驱动程序中严重的bug!!!”,这两者并无联系(硬件和软件属于不同厂商),请明确你想要讨论的问题,以便我为你解答问题。谢谢

热门招聘
相关主题

官方公众号

智造工程师