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



nuaa

    
  • 精华:0帖
  • 求助:0帖
  • 帖子:6帖 | 3回
  • 年度积分:0
  • 历史总积分:74
  • 注册:2001年5月30日
发表于:2002-07-05 17:09: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 17:09: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很不错。

热门招聘
相关主题

官方公众号

智造工程师