ctypes typecasting in perl

Jérôme Étévé jerome.eteve at gmail.com
Mon Sep 9 17:05:18 BST 2013

Would that help?



On 9 September 2013 16:55, Shantanu Bhadoria <shantanu at cpan.org> wrote:
> I have been playing around with talking to some IMU chips i.e gyroscopes,
> magnetometers and accelerometers from my raspberryPi and I am facing a
> slight problem which might seem trivial to those familiar more with C or XS
> code than I. I am trying to read registers off a chip which store data in
> int16_t format but since the data is in simple binary code, essentially
> when I read the register I get a simple unsigned int value from it. Is
> there a function or module in perl which would allow me to convert typecast
> something as int16_t?
> esentially in python the following gives me int 64256 typecast into c_int16
> and returns -1280.
> from ctypes import *
> print c_int16(64256).value
> Is there a equivalent function or module in perl that would do it? My
> thanks to whoever can help me solve this problem.
> Cheers,
> -Shantanu Bhadoria

Jerome Eteve

More information about the london.pm mailing list