TypeError when using SCONE with python main.py
When trying to use SCONE from the python main.py, the following error appears:
Traceback (most recent call last):
File "main.py", line 93, in <module>
output = rw.WriteProperty(device, address, offset, width, writevalue, verbose=verbose, logging=logging)
File "/home/rardino/scone-issue/ReadWriteTools/rw.py", line 34, in WriteProperty
write_value = ctypes.c_uint(value)
TypeError: an integer is required (got type c_uint)
Steps to reproduce the issue (which may be machine/ctype library version dependent):
ssh -Y ${USER}@pccmdlab40-22
cd /home/${USER}/
git clone https://gitlab.cern.ch/scouting-demonstrator/scone.git scone-issue
cd scone-issue/
cp /home/rardino/scone/address_table/address_table_vcu128.json address_table/
cd ReadWriteTools/
cc -fPIC -shared -o functions.so functions.c
cd ..
sudo /usr/local/bin/python3.6 main.py -j address_table/address_table_vcu128.json -b vcu128_demux -a set -v 255 -r link_enable -d 1
The error is caused by this line in main.py
https://gitlab.cern.ch/scouting-demonstrator/scone/-/blob/main/main.py#L92
Thus, writevalue is already a ctypes.c_uint
, so in
https://gitlab.cern.ch/scouting-demonstrator/scone/-/blob/main/ReadWriteTools/rw.py#L34
write_value = ctypes.c_uint(value)
tries to convert value
in a ctypes.c_uint
, but since value is already a ctypes.c_uint
, it gives the previous TypeError since it is expecting an integer and not a c_uint
.
Even if main.py
is not anymore mantained from what I understand, it is still quite useful to perform tests in B40, so it might be useful to fix this. I can create a Merge Request with a fix if it ok for you. It's just a fix in the main.py
file.