InexactError while using the PiGPIO.jl package from JuliaBerry

Hi,

I am trying to read sensor (MPU 6050) data using Raspberry Pi 3 and Julia using the PiGPIO package. I have connected my Pi to the pigpio daemon over a network.

When I am trying to use “i2c_write_byte” function something like i2c_write_byte(pi, 2, 0x19), I end up with the following error:

InexactError: check_top_bit(UInt32, 4294967271)

Stacktrace:
[1] throw_inexacterror(::Symbol, ::Any, ::UInt32) at ./boot.jl:567
[2] check_top_bit at ./boot.jl:581 [inlined]
[3] toInt32 at ./boot.jl:630 [inlined]
[4] Type at ./boot.jl:716 [inlined]
[5] convert at ./number.jl:7 [inlined]
[6] _u2i(::UInt32) at /home/pi/.julia/packages/PiGPIO/e5h1O/src/pi.jl:72
[7] i2c_write_byte(::Pi, ::Int32, ::UInt8) at /home/pi/.julia/packages/PiGPIO/e5h1O/src/i2c.jl:99
[8] top-level scope at In[51]:1

I tried to look up the function in the boot.jl file in the line mentioned but wasn’t able to figure it out since I am new to coding. Could someone please explain what the actual error is and also how to rectify it if possible?

Thank you

It comes from the function at

The function doesn’t really make sense to me, converting an unsigned integer to an Int32 can never give a negative result which is what is being checked.

I am guessing that instead of v = convert(Int32, x), what was intended was x % Int32.

2 Likes