12-10-2009 07:59 PM
Hi,
I am programming MS4404 bar code scanner using LabVIEW. This is a miniscan and does not have trigger button. So we need to trigger it using Software.
Could communicates with scanner to enable. disable, beep, etc....issue is with the decoded data.
DLL put data in the allocated buffer, and send a windows message WM_XXXX to application. Problem is to check these windows messages and copy the buffer data into application..............struck up here..........There was an example for this scanner but that is in VC and it is using ON_MESSAGE function to catch windows message and memcpy() to copy buffer data into local.........................Not sure how to go ahead in LabVIEW
Appreciate any help from fellow members...........
Thanks in advance
12-11-2009 09:40 AM
Little advancement in the issue......
I am able to capture windows messages using Windows messages queue library (found on ni.com), Now the issue is with creating buffer for DLL and pulling data from that DLL on successfull Decode of data from scanner.
I think I am going wrong in giving cirrect data type while creating buffer here.
Below is the description of the function from manual
SSIDLL_API int __stdcall SetDecodeBuffer(int nComPort, unsigned char *pData, long max_length);
where:
. nComPort is the COM port number used in the call to SSIConnect
. pData is a pointer to the destination buffer for decode data returned from thescanner
. max_length is the size in bytes of the destination buffer
I am sure I am going wrong about the pData parameter.
I need to create this buffer before decoding, so the scanner fills this buffer with decoded data.
Thanks in advance for your help.
12-11-2009 10:08 AM
12-11-2009 11:43 AM
Hey Nathan,
that worked. DLL is allocating buffer and it seems that scanner is filling data in the buffer (I am reading windows message to know if any error in filling data).........I am trying to retrieve data from this buffer, how do we copy data into application from this buffer????
Thanks
12-11-2009 12:10 PM
12-11-2009 12:17 PM
Anil Reddy wrote:Hey Nathan,
that worked. DLL is allocating buffer and it seems that scanner is filling data in the buffer (I am reading windows message to know if any error in filling data).........I am trying to retrieve data from this buffer, how do we copy data into application from this buffer????
Hold on, who's supposed to be allocating the buffer - you or the DLL? If you're supposed to allocate a large enough buffer and pass it to the DLL so it can fill in the values, what nathan suggested is fine. On the other hand, if it's the DLL that's allocating the buffer you've got a different issue. In this case you need to be able to deallocate the buffer (probably through another function), or you will have a memory leak.
12-11-2009 12:18 PM
Hey......
Here my DLL works in bit different way......
I need to create buffer first (Using set buffer function in DLL).......After that I call another function Read Parameters (one of the functions), using another DLL call.....That is where the link is missing. It is easy in C# and C++ just copy the variable into local variable........I am just checking out here.....and I need to read the data after receiving WM_XXX message from scanner........
12-11-2009 12:21 PM
well..Am initializing an array and giving it to DLL using Call Lib Function. DLL allocates buffer for the data coming from scanner. Then I send a command to scanner to read parameters or decode bar code. Then scanner fills data into buffer and sends a windows message. We should be able to access that buffer immediately after getting windows message. then DLL will clear that buffer
12-11-2009 03:04 PM
So, if I'm understanding correctly, your DLL expects that your (LabVIEW) code will allocate the buffer. In one call, you provide the address of that buffer. In a different call, the DLL fills data into that buffer. So, you need a way to tell LabVIEW to allocate a non-moveable block of memory, so that you can pass its address to the DLL. You also need a way to copy the data from that buffer onto a LabVIEW wire. We're outside my area of experience here, but I think you need to look at the memory management functions LabVIEW provides for writing CINs. These same functions can be called from a Call Library Node by setting the DLL name to "LabVIEW." Help for those functions is available inside the help directory in your LabVIEW installation, take a look at lvexcode.chm and lvexcodeconcepts.chm. Also, search through the forum posts here, rolfk has written many, many helpful comments about using those functions.
I think you can do what you want by calling DSNewPtr to get your block of memory. This will return a pointer that you can pass to SetDecodeBuffer. Then, when you need to retrieve the data from that pointer, call MoveBlock. The source is your pointer and the destination should be a LabVIEW array. When your code terminates, call DSDisposePtr to release the memory for the buffer.
12-11-2009 09:46 PM - edited 12-11-2009 09:47 PM
Hi Nathan,
What you understood is correct.........
I will start looking into CINs..never worked with them......I worked mostly with API calls to DLLs using Call Library Functions only..............I thought this scanner programming would not be a big issue...but this only driving us crazy..................
Thank you for your help..............Will update with result after trying with CINs...........