Forum: Ruby ffi: Can't get dll to work

Posted by Axel Friedrich (axel555)
on 2013-01-09 11:34
Hi,

I want to use PICkit's dll (PICkitS.dll) from Ruby on Windows XP, but I
doesn't succeed to get it done. I'd greatly appreciate any help.

I think, ffi would be usefull.

Documentation of PICkitS.dll says, for example:


Simple Function call:

PICkitS.Basic.Initialize_PICkitSerial()

Returns: True if successful, False if not
[...]


More complex Function call:

PICkitS.Basic.Send_SPI_Receive_Cmd(byte
p_num_bytes_to_read, ref byte[] p_data_array, bool
p_first_cmd, bool p_last_cmd, ref string p_script_view)

Returns: True if successful, False if not
[...]



I tried for example this:

require 'ffi'
module PicKit
  extend FFI::Library
  ffi_lib 'D:\e\Microchip\PICkit Serial Analyzer\PICkitS.dll'
  ffi_convention :stdcall
  attach_function :Initialize_PICkitSerial, [], :void
end

PicKit::Basic.Initialize_PICkitSerial([:pointer, nil])


This returns the following error:

ruby18_mingw/lib/ruby/gems/1.8/gems/ffi-1.3.0-x86-mingw32/lib/ffi/library.rb:251:in
`attach_function': Function 'Initialize_PICkitSerial' not found in
[D:\e\Microchip\PICkit Serial Analyzer\PICkitS.dll] (FFI::NotFoundError)


I've installed:
ruby 1.8.7 (2009-06-12 patchlevel 174) [i386-mingw32]
and
ruby 1.9.3p327 (2012-11-10) [i386-mingw32]
on
Window XP

I do not know C.

Best regards,
Axel
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.