in reply to [SOLVED (workaround)]: External C function called through XS not Doing The Right Thing

I'm suspecting this isn't a Perl/XS problem, but I'm head scratching. After adding some print statements in core locations in the C code just prior to the data being sent to the LCD, I get the exact same output between the C example and the Perl example, which leads me to believe the way I'm sending data in through Perl/XS is fine:

# C sndcmd: 40 sndcmd: 12 sndcmd: 12 sndcmd: 12 sndcmd: 1 sndcmd: 2 sndcmd: 6 sndcmd: 20 sndcmd: 1 sndcmd: 2 sndcmd: 128 sndcmd: 80 sndcmd: 31 sndcmd: 17 sndcmd: 17 sndcmd: 21 sndcmd: 31 sndcmd: 17 sndcmd: 17 sndcmd: 31 put: 2 sndcmd: 2 # Perl sndcmd: 40 sndcmd: 12 sndcmd: 12 sndcmd: 12 sndcmd: 1 sndcmd: 2 sndcmd: 6 sndcmd: 20 sndcmd: 1 sndcmd: 2 sndcmd: 128 sndcmd: 80 sndcmd: 31 sndcmd: 17 sndcmd: 17 sndcmd: 21 sndcmd: 31 sndcmd: 17 sndcmd: 17 sndcmd: 31 put: 2 sndcmd: 2
  • Comment on Re: External C function called through XS not Doing The Right Thing
  • Download Code

Replies are listed 'Best First'.
Re^2: External C function called through XS not Doing The Right Thing
by Anonymous Monk on Mar 10, 2017 at 02:12 UTC

    Hi

    ? Are you sure about  "V0C*", ?

    You really want V An unsigned long (32-bit) in "VAX" (little-endian) order. Maybe you mean "C0" as in character mode?

      I am not 100% sure, I've tried a few things. I just know that with "V0C*", I get the exact same parameters from a C program as I do with the Perl script in the called function.

      I'll re-review the pack documentation now that I at least have a workaround.

        After reviewing the docs, because the function accepts an unsigned char array[8], I went with pack "C[8]", ...;, as from what I can tell, that's most appropriate.

        This didn't solve the initial issue, but thanks for pointing that out!