-
Notifications
You must be signed in to change notification settings - Fork 9
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
Bug when Out records self-update on a Raspberry Pi #153
Comments
I think this might be a bug here: https://github.com/dls-controls/pythonSoftIOC/blob/f2330b6464856d0d05127a79c84ad166a0d47d2d/softioc/extension.c#L103 Unfortunately there doesn't seem to be an The buffer being passed is constructed as ctypes.addressof(ctypes.c_double(7.62)) This is a (large) integer that we somehow need to pass to I would expect you to be able to reproduce the problem even more simply: does calling |
A closer look at how things are implemented suggests a possible fix, but we'll need to be able to reproduce the problem. Can you be very specific about the target system where you have the bug, as there are a lot of versions of the RPi around now. The output of Looking at the sources for return PyLong_FromVoidPtr(((CDataObject *)obj)->b_ptr); and according to the documentation we can call |
This might do the trick: diff --git a/softioc/extension.c b/softioc/extension.c
index fd71687..d14feac 100644
--- a/softioc/extension.c
+++ b/softioc/extension.c
@@ -98,9 +98,12 @@ static PyObject *db_put_field(PyObject *self, PyObject *args)
{
const char *name;
short dbrType;
- void *pbuffer;
+ PyObject *buffer_ptr;
long length;
- if (!PyArg_ParseTuple(args, "shnl", &name, &dbrType, &pbuffer, &length))
+ if (!PyArg_ParseTuple(args, "shOl", &name, &dbrType, &buffer_ptr, &length))
+ return NULL;
+ void *pbuffer = PyLong_AsVoidPtr(buffer_ptr);
+ if (!pbuffer)
return NULL;
struct dbAddr dbAddr;
@@ -133,9 +136,12 @@ static PyObject *db_get_field(PyObject *self, PyObject *args)
{
const char *name;
short dbrType;
- void *pbuffer;
+ PyObject *buffer_ptr;
long length;
- if (!PyArg_ParseTuple(args, "shnl", &name, &dbrType, &pbuffer, &length))
+ if (!PyArg_ParseTuple(args, "shOl", &name, &dbrType, &buffer_ptr, &length))
+ return NULL;
+ void *pbuffer = PyLong_AsVoidPtr(buffer_ptr);
+ if (!pbuffer)
return NULL;
struct dbAddr dbAddr; @AlexanderWells-diamond , can we look into whether we can reproduce this issue? I think the fix above is probably the right way to do things, but it'll need some checking. |
As I said in the bug report, it's a Raspberry Pi v4 with a Debian 12.1.
The bug is also triggered by a Everything works as expected when using |
How would I provide that to you? Is there any way to access that from Python? Or do I need to build from source and
This is on a x86 system:
And this on the Raspi:
Yes, it fails the same. But keep in mind (see my other post) that this only fails for I don't know about pythonSoftIOC internals, but |
I've patched pythonSoftIOC by hand and gave it a
Again, the same script failed previously. Thanks! |
That printf was probably enough information. Something very odd here ... I was expecting a 64-bit address! I definitely don't understand why that doesn't fit into a Anyhow, it's excellent news that my fix works for you. We'll apply it our end and run through our regression tests, and I expect it can be a general fix. |
Fixed in merge #154 |
Actually, yes it is! The difference is that |
Hi @codedump, apparently you are using an Arch64 ABI called ILP32 in which pointers are 4 bytes, Could you please confirm that is the case? you can do that by building a small c program that prints the value of |
I am sorry for the late reply. I'm away from the system for now and will be for another while, so I can't test, but that being a 32 bit system makes sense.
It's an "older" Pi 4 (meaning: a few years back), and there was a time when Debian for ARM wasn't get stable enough for the Pi 4. The recommended practice back then eas to install the 32-bit version, and this is what might've happened here.
The system is running a "recent Debian" in the sense that it was a recent `dist-upgrade`.
The C pointer test seems to indicate, anyway, that it was a 32-bit system, and that's plausibility consistent with the.history and age of the system (it's a custom-made sample holder at BESSY-II, about 3 years old).
Im any case, the fix was working properly.
Thanks & Cheers,
F.
|
Well, I'm very glad we caught this tricksy bug, and am happy with the fix .. so thanks for trying this on a weird system! |
Hello,
there appears to be a bug when using pythonSoftIOC on a Raspberry Pi.
Try out the "hello world" IOC example from the documentation (reproduced below without all the comments and without the
aIn
part, for better overview); then modify theon_update=...
parameter to self-update theaOut
record.This is something that is necessary, for instance, to implement specific EPICS motor fields, e.g.
HOMF
, which are expected to update their own value back to 0 once they're done.Here is the IOC in question:
Then trying to actually trigger the self-update, by simply just writing a value -- any value:
This is how it fails on a Raspberry Pi v4, with fairly recent Debian 12.1 (I think it's Bookworm):
The same IOC code works on as expected an x86 based computer.
How to fix this?
Cheers,
F.
PS: sorry, the error message somehow got botched while copy-pasting. It's fixed now.
The text was updated successfully, but these errors were encountered: