Update: ikegami's right. I shouldn't try to interact before having my second cup of tea. I exactly reverse the meaning of the underscore in my mind!

That shows that the calling convention used is __stdcall, so you should be able to call the dll successfully using Win32::API. __cdecl calling convention was used, so you will not be able to call the dll successfully winth Win32::API.

Ignore the rest!

And according to this translation of (probably the same?) chinese pdf, your (second) prototype:

my $readdevice = Win32::API->new ( 'HCE300_API.DLL', 'HCE300_Read','NP','N' ) or die $^E;
is correct. It also identifies that the maximum length of data that can be read from the device is 300 bytes (track 2 when in 210bpi mode). (Though despite the warning in the descroption that it can be 300 bytes, all the examples use char buf[250]!)

The upshot is that what you are trying should work. If it doesn't, there are many possibilities for why it doesn't, and all of them are far beyond the scope of this Perl forum.


You mentioned using USB. The description of the device shows that it is intended to be connected to an old fashioned RS232 serial port. My one attempt at using a USB connected serial port convinced me that their RS232 emulation is far from transparent. If the device/driver was never written and tested to operate over USB, you are likely to encounter real problems.

One possibility is that at the end of that manual above, there is a description of the comms protocol commands for driving the device. You might be able to bypass the DLL and drive the device directly by writing and reading raw bytes to and from the serial port itself. Though I'll have to just wish you luck with that, because serial comms is more a black art than science, and it is hard enough to do hands-on with a protocol analyser to hand. Doing it remotely is pretty much impossible.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re^7: Correct call for dll with Win32::API by BrowserUk
in thread Correct call for dll with Win32::API by walto

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.