Page 1 of 1 1
Topic Options
#194945 - 2009-07-21 04:37 PM A new DynaWrap try
Viggen Offline
Starting to like KiXtart

Registered: 2002-03-22
Posts: 110
Hi everyone!

Not long after that Shawn helped me with the BCPwrapper, my boss came along... with another barcode scanner.
I told him that he should stick to the first one, but 'he's the boss' \:\/
(the new one is a small key-chain thingy...and *it's sooo much cooler* )

Anyways... The new scanner came with a much better SDK, so I thought I'd take a look at it, and the dll can't be registered.

Now I'm back at DynaWrap again, and I can contact the scanner, so I know that I have made some progress with it.
There is just some things that needs a bit of clarification =)

Here's my test so far:
 Code:
$Port = 15


$dyn = CreateObject("DynamicWrapper")
?? @error
$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2Init", "i=l", "f=s", "r=l")
?? @error
$dOpen = $dyn.csp2Init($Port)
?? @error
$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2DataAvailable","i=l", "f=s", "r=l")
?? @error
debug on
$dDA = $dyn.csp2DataAvailable()
?? @error
? @serror


By changing ports, I have verified that it works as far as opening it, but when I get to the error output after $dDA, I get:

-2147352562
Invalid number of parameters.

I have probably overlooked something, the question is what \:\)

In the SDK I found this:
 Code:
Declare Function csp2Init Lib "csp2.dll" (ByVal nComPort As Long) As Long
Declare Function csp2DataAvailable Lib "csp2.dll" () As Long 


So what makes the first one work, and the other not?

/Viggen

Top
#194955 - 2009-07-22 01:54 PM Re: A new DynaWrap try [Re: Viggen]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
i=describes the number and data type of the functions parameters
Since there are no Input parameters, don't include i=l for the csp2DataAvialable.

f=s, could try f=c
(s = Microsoft Compiled, c = Borland Compiled)

r=l thats right, the Return type is Long.

Top
#195038 - 2009-07-25 03:20 PM Re: A new DynaWrap try [Re: Arend_]
Viggen Offline
Starting to like KiXtart

Registered: 2002-03-22
Posts: 110
Ah!

I had a thought about omiting "i", and I tried these:
 Code:
$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2DataAvailable","i=", "f=s", "r=l")

$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2DataAvailable","i=''", "f=s", "r=l")

$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2DataAvailable","", "f=s", "r=l")

$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2DataAvailable",, "f=s", "r=l")


And then I gave up \:\)

I never thought about the "easy one" \:D

When you wrote "don't include..." it hit me...
It shall of course be this:

 Code:
$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2DataAvailable", "f=s", "r=l") 




Thanks for pointing me in the right direction!!

Now I have another problem, and that seems to be the end of this experiment.

Another of the functions in the dll expects a byte-input, and if I'm not totally wrong, kix can't create byte arrays.


/Viggen

******* Edit********

Hmm... found this, but I'm not sure if I can use that to create a byte array of 100 elements...
(aiming for something like "Dim bytearray(99) as byte")

Using ADO to convert to / from BYTE arrays




Edited by Viggen (2009-07-25 03:48 PM)
Edit Reason:

Top
#195053 - 2009-07-27 10:03 AM Re: A new DynaWrap try [Re: Viggen]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Don't use those routines at present, one of them has a bug.

I just created a test suite which converts all 0-255 bytes to a byte array and then back again to a standard KiXtart integer arrary to make sure that the functions still work OK.

There is a problem with integers 128 - 159.

I'm not sure yet which of the routines is failing, though I've got a pretty good idead which one and why. I'll work on them as soon as I get some free time.

Top
#195055 - 2009-07-27 10:50 AM Re: A new DynaWrap try [Re: Richard H.]
Viggen Offline
Starting to like KiXtart

Registered: 2002-03-22
Posts: 110
Oh, ok. \:\)

Thanks!

Top
#195222 - 2009-08-03 03:28 PM Re: A new DynaWrap try [Re: Viggen]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Glad you got it to work \:\)

Byte array is possible, look at my UUID2netbootGUID UDF.

Top
#195372 - 2009-08-10 05:28 PM Re: A new DynaWrap try [Re: Arend_]
Viggen Offline
Starting to like KiXtart

Registered: 2002-03-22
Posts: 110
Hey!
Thanks!

I looked at the UDF, and from that I pulled this (which seems to work) \:\)

 Code:
; ******************************************************
Function ByteArray($array)
  Dim $stream, $i

  $stream = CreateObject("ADODB.Stream")
  If @error
    Exit @error
  EndIf

  $stream.Type = 2
  $stream.CharSet = "windows-1252"
  $stream.Open

  For $i=0 to Ubound($array)
    $stream.WriteText(Chr(Val("&"+$array[$i])))
  Next

  $stream.Position = 0
  $stream.Type = 1
  $ByteArray = $stream.Read
  $stream.Close
Endfunction
; ****************************************************** 


However I'm stuck at the translation of the vb-code in the form for the scanner.
I'll start a new thread since this is now about the code, not DynaWrap.

Thanks again!

/Viggen


The new thread is here...


Edited by Viggen (2009-08-10 05:55 PM)
Edit Reason: added link to the new thread

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 581 anonymous users online.
Newest Members
Audio, Hoschi, Comet, rrosell, PatrickPinto
17880 Registered Users

Generated in 0.058 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org