|
|
|||||||
Hi all! I have read the tutorials, on how to use DynaWrap/DynaCall, but I'm still lost on this one... I have include the dll I need to use, and I wonder if someone (Apronk?) could help me in the right direction on how to call it. I can get as far as creating the DynamicWrapper-object, but that's it T.I.A /Viggen |
||||||||
|
|
|||||||
What do you want to do with it? Do you have any documentation on this DLL? |
||||||||
|
|
|||||||
The dll is needed to get data from a barcode reader. In the so called SDK for it, there was an ocx, and I had no problem connecting to the reader, but I couldn't get any data. I mailed the support (in Taiwan...) and they answered, that they don't support it any longer, and sent me the dll... (with no docs at all), so I tried to register it with Regsvr32 which didn't work... I mailed them again and they haven't answered in 10 days I have opened the file in Visual C++ 2008 express edition, and I can see what "calls" I have to make (their allmost the same as in the ocx), but i can't figure out how to use the DynamicWrapper. (I guess I need to use that, or is there another way to do it?) /Viggen |
||||||||
|
|
|||||||
oh, so it's not com aware. that's a pita. can't really USE it in kixtart. |
||||||||
|
|
|||||||
Well, that's the hope in dynawrapper... but with no docs its gonna be tough. |
||||||||
|
|
|||||||
But he has the OCX source code, which makes the DLL calls under-the-covers ... so might be a straight-forward mapping ... But since the OCX failed to read the data from the DLL, wouldn't place much hope on dynawrapper being any different ... but hey go for it man ! |
||||||||
|
|
|||||||
Umm... I might be missing something here... but when I used the ocx, I didn't have a dll at all. and the "big" difference between the ocx and the dll is that the ocx used "DownloadData", while the dll uses "UploadRecords". (since this is waaaay out of my league, I don't know if it means anything) and about that "source code for the ocx... nope... they supplied a vb-file, so with that and typelib viewer I figured it out. Oh! and I forgot one thing... They sent a demo.exe which uses the dll, and that demo can get the data from the reader, into a textbox. /Viggen |
||||||||
|
|
|||||||
I guess no source code for the demo.exe ? |
||||||||
|
|
|||||||
hmm... hang on... I got this. (but, personally, since this is not my cup o' tea, I found out more, with the "Visual C++ express"-thingy) |
||||||||
|
|
|||||||
Just fired-up VS 2005 and checked-out that project with the component. That control is named "BCP5Control" yeah ? It actually appears as the progress bar along the top of the form ... cool idea. Anyway, that control is actually a VB.NET control ... written back in .NET 1.1 ... that makes things even trickier (x2) ... 1) Its a .NET control - not a COMable object 2) Its probably not DynaWrappable ... jury's still out 3) Since its a control, it needs a "container" to live in - like VB.NET or even maybe Internet Explorer ... Any of this ring true ? The OCX you had would have probably worked with the older VB6 ... that "might" be COMable (because OCX's are just standardized COM objects) ... can we get our hands on that ? -Shawn |
||||||||
|
|
|||||||
Here's the ocx and the "sdk", that dosen't even work... I made a small test with the help from the vb-file, and from what I found in TypeLib Viewer. Perhaps I have missed something, since I can't get the data from it? Would KiXforms.NET work as a container? Code: $Port = 12 $Pwd = "1234" $bcreader = CreateObject("BCP5Ctrl.BCP5Controller") ?? @error $open = $bcreader.OpenBCP($Pwd,$Port) ? $open debug on $text = $bcreader.DownloadData ; If $Port or $Pwd is wrong it displays "Device did not open", else it displays "Communication failed to establish." $nul = $bcreader.EraseData ; Even though I get a "Communication failed...", (on the "DownloadData") it erases all data in the scanner. ; Which indicates that the comm. is in fact working? $close = $bcreader.CloseBCP |
||||||||
|
|
|||||||
The OCX seems to be very COMable ... you said the vb demo application works fine eh ? What specific actions and buttons did you use with the demo. I assume you started like: 1) Selected a COM port 2) Entered password in password box. 3) Clicked the "OpenBCP" button ... What next ... |
||||||||
|
|
|||||||
After that I click the "Upload Data"-button, and wait for the data to appear in the textbox. The next step is to "Erase Data" or "CloseBCP" |
||||||||
|
|
|||||||
hmmmm, looking at your script above ... I think you did a great job in reverse engineering the OCX and scripting something that "should" work ;-) Re-reading your comments, the problem your having is only with the DownloadDATA method eh ? (You said the EraseData erases fine) ... 1) You getting anything returned in the $text variable ? Whats the LEN($text) ? 2) Whats the @SERROR after your DownloadDATA ? |
||||||||
|
|
|||||||
Seems to display the value of CommPort ok after the OpenBCP method ... ?"ComPort = " + $bcreader.CommPort |
||||||||
|
|
|||||||
Does this vbscript version behave same (vbscript has better COM support) ... it appears to on my end ... Code: Dim bcReader Dim port Dim password Dim text port = 12 password = "1234" Set bcReader = CreateObject("BCP5Ctrl.BCP5Controller") bcReader.OpenBCP password, port WScript.Echo "Opened = " & bcReader.Opened text = bcReader.DownloadData() WScript.Echo "text = " & text bcReader.CloseBCP |
||||||||
|
|
|||||||
It took some guesswork, but I got some results =) When I get to "$text = $bcreader.DownloadData" and press enter (in debug mode) It takes a few sec. and then I get a messagebox telling me "Communication failed to establish." ? Len($text) = 0 The @serror is "The operation completed successfully" (I'm guessing that this is the result of the messagebox displaying) I have had some form of result from every "call" in the ocx, except the DownloadData. |
||||||||
|
|
|||||||
Sorry I get a "Opened = False" Then I get a "Device did not open." and after that I get "text = " |
||||||||
|
|
|||||||
I'm seeing the same - everything except DownloadData appears to work. Able to try that VB script version above ? |
||||||||
|
|
|||||||
Yes, thats when I get the "Opened = False" |
||||||||
|
|
|||||||
Had a thought, and as long as your machines have .net 2.0 this might work for you ... I took the .Net version of the BCP control and "wrapped" it inside a .NET COM object ... a wrappper class ... then put the whole thing inside an MSI because registering these assemblies can be a real pain ... here's the MSI: BCPWrapper Download and install it, if it installs ok then run the script below. I can't test this obviously, have my fingers crossed ... Code: Break On $BCPController = CreateObject("BCPWrapper.BCPController") $rv = $BCPController.OpenBCP("COM12", "1234") $text = $BCPController.UploadData() ?"text = " + $text $BCPController.Close Exit 0 |
||||||||
|
|
|||||||
I think I can safely say, that I speak for most on this board when I say, ‘Shawn we are lucky to have you around, Thanks for being there for us.’ |
||||||||
|
|
|||||||
well... where should I start... hmmm... let me try this... THANK YOU!!! It works great! Thank you so much for all your help! /Viggen |
||||||||
|
|
|||||||
lol. talk about silver platter... not only did Shawn provided the working stuff, he even wrapped it with a installer. woot. |
||||||||
|
|
|||||||
woohoo glad it worked. I can quickly add the erasedata method and anything else you might need. let just me know. I will also provide you with the vs2005 project so that you can support it going forward ... |
||||||||
|
|
|||||||
I can't thank you enough Shawn! The only thing that is needed right now is the erase method. The vs2005 project would be a great way to learn a bit more about theese things Thank you again! /Viggen |
||||||||
|
|
|||||||
wow... Viggen - you don't know how lucky you are. Shawn used to be here and post dozens of times every day, but for a while now there have been weeks or months that he has not stopped by or posted. Thanks for being here again and helping Shawn. |
||||||||
|
|
|||||||
Hey man no problems. The THANKS viggen gave made it all worthwhile ... many times over and I mean that ... I posted a new build its available in a zip here: BCPWwrapper.zip It includes a new MSI and a ZIP of the entire project with source code so you should be able to change and rebuild yourself. The project consists of two sub-projects ... the wrapper itself and the MSI builder (setup1) ... if you have any questions feel free to shoot me a PM ... Made two changes to the wrapper: 1) Renamed the OpenBCP method to just Open - thats to be consistent with the Close method and because thats what the real methods are called under-the-covers - just for consistency. 2) Added the EraseData method. Here's some new source ... Code: Break On $BCPController = CreateObject("BCPWrapper.BCPController") $bool = $BCPController.Open("COM12", "1234") $text = $BCPController.UploadData() ?"text = " + $text $bool = $BCPController.EraseData $BCPController.Close Exit 0 And like I said, any questions or even if you want me to add some new methods properties - let me know ... -Shawn |
||||||||
|
|
|||||||
Thanks again! Just tried the new build, and the EraseData method works perfect. however... The Open method dosen't... OpenBCP is still there So this will be a perfect way for me to get acquainted with the source code. /Viggen |