-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OverflowError: Python int too large to convert to C long #1
Comments
Could you run with that fix for a while and see if it errors again? I'll try and get to the bottom of this! Thanks. |
Ok, I've merged a fix into the testing branch. It's not a direct fix but I've implemented the SPI transfer more closely to how you're supposed to do it in C. Hopefully, by letting the the include file do the heavy lifting the bug should disappear! Let me know how you get on. I'll merge it into master later today, if there aren't any issues. |
You have a typo in linux_spi_spidev.py. The problem was detected at the install of pifacedigitalio (see bellow). But because pifacedigitalio downloaded locally the master branch of pifacecommon, the install finished, but without the fix... cd pifacedigitalio |
Ah, I fixed that on my local copy but I haven't updated it. Everything seems to work for me but since I don't really know how to replicate the error your in a better position to test it. I'll upload my changes to the testing branch in merge it into master by the end of the week if all goes well. |
I do not have error with the last fix. |
reflect changelog to current version
I get this exception (v1.1 and also in your last Jun 25 checkin):
Traceback (most recent call last):
File "/home/pi/sprinklermory/scheduler.py", line 90, in run
if a_rain_sensor.rain_detected and a_rain_sensor.watering_percent > watering_percent_from_rain_sensor:
File "/home/pi/sprinklermory/rainsensor.py", line 135, in rain_detected
rain_detected = ioserver.get_input_value(self.input_index)
File "/home/pi/sprinklermory/ioserver.py", line 123, in get_input_value
state = _pfd.input_pins[inputIndex].value;
File "/usr/local/lib/python3.2/dist-packages/pifacecommon/core.py", line 190, in value
return 1 ^ super().value
File "/usr/local/lib/python3.2/dist-packages/pifacecommon/core.py", line 170, in value
self.board_num)
File "/usr/local/lib/python3.2/dist-packages/pifacecommon/core.py", line 319, in read_bit
value = read(address, board_num)
File "/usr/local/lib/python3.2/dist-packages/pifacecommon/core.py", line 368, in read
op, addr, data = spisend((devopcode, address, 0)) # data byte is not used
File "/usr/local/lib/python3.2/dist-packages/pifacecommon/core.py", line 411, in spisend
ioctl(spidev_fd, iomsg, ctypes.addressof(transfer))
OverflowError: Python int too large to convert to C long
It's pretty random, but get it after a while.
The exception seem to appear when ctypes.addressof(transfer) return a very big number that fit only in an unsigned int. I believe ctypes.addressof is not necessary here but I'm not familiar with ctypes yet.
I get a fix that seem to works:
diff --git a/pifacecommon/core.py b/pifacecommon/core.py
index c1d5577..9584f0f 100644
--- a/pifacecommon/core.py
+++ b/pifacecommon/core.py
@@ -408,7 +408,7 @@ def spisend(bytes_to_send):
return ctypes.string_at(rbuffer, ctypes.sizeof(rbuffer))
The text was updated successfully, but these errors were encountered: