Skip to content
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

spi read and write_read calls do will raise an exception as out values are in parameter list instead of being return values #10

Open
darkerspalbird opened this issue Feb 17, 2025 · 0 comments

Comments

@darkerspalbird
Copy link

Hi Marius,

principally I like the feel of dwfpy.

But when I tried to use spi I got a traceback error when reading back values, see below.
I use WaveForms beta 3.23.40 (latest beta) on Windows 11.

WaveForms has such a lot of functionality that I believe a testbench which tests all functions is mandatory.
I assume you convert from c to python with a translation script I did not try to debug further.
For sure many more read functions are affected.

Root cause of the conversion error is that the parameter list are not modified in a way that out channels are return values.

Please set up a regression test and clearly point out what is functioning correctly and what not.
Thanks for your effort!

==============================

Traceback (most recent call last):
File "C:\Users\grw2rt\Desktop_local_Coole_Eva_Kits\cj135_digilent_discovery\protocol_spi.py", line 51, in
rx = spi.read(words_to_receive=10)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\grw2rt\AppData\Local\Programs\Python\Python311\Lib\site-packages\dwfpy\protocols.py", line 417, in read
api.dwf_digital_spi_read(self._device.handle, dq_mode, bits_per_word, rx_buffer8, len(rx_buffer8))
TypeError: call takes exactly 4 arguments (5 given)

declaration in bindings.py

dwf_digital_spi_write_read = _dwf_function('FDwfDigitalSpiWriteRead', (_IN, HDWF, 'hdwf'),
(_IN, c_int, 'cDQ'),
(_IN, c_int, 'cBitPerWord'),
(_IN, POINTER(c_ubyte), 'rgTX'),
(_IN, c_int, 'cTX'),
(_OUT, POINTER(c_ubyte), 'rgRX'),
(_IN, c_int, 'cRX'))

incorrect use in protocols.py

"""
api.dwf_digital_spi_read(self._device.handle, dq_mode, bits_per_word, rx_buffer8, len(rx_buffer8))
"""

Possibly correct use, need to be corrected

rx_buffer8=api.dwf_digital_spi_read(self._device.handle, dq_mode, bits_per_word, len(rx_buffer8))

=========================
Traceback (most recent call last):
File "C:\Users\grw2rt\Desktop_local_Coole_Eva_Kits\cj135_digilent_discovery\protocol_spi.py", line 33, in
rx = spi.write_read(buffer=tx, words_to_receive=10)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\grw2rt\AppData\Local\Programs\Python\Python311\Lib\site-packages\dwfpy\protocols.py", line 463, in write_read
api.dwf_digital_spi_write_read(
TypeError: call takes exactly 6 arguments (7 given)

declaration in bindings.py

dwf_digital_spi_write_read = _dwf_function('FDwfDigitalSpiWriteRead', (_IN, HDWF, 'hdwf'),
(_IN, c_int, 'cDQ'),
(_IN, c_int, 'cBitPerWord'),
(_IN, POINTER(c_ubyte), 'rgTX'),
(_IN, c_int, 'cTX'),
(_OUT, POINTER(c_ubyte), 'rgRX'),
(_IN, c_int, 'cRX'))

incorrect use in protocols.py

"""
api.dwf_digital_spi_write_read(
self._device.handle,
dq_mode,
bits_per_word,
tx_buffer8,
len(tx_buffer8),
rx_buffer8,
len(rx_buffer8),
)
"""

Possibly correct use, need to be corrected

rx_buffer8=api.dwf_digital_spi_write_read(
self._device.handle,
dq_mode,
bits_per_word,
tx_buffer8,
len(tx_buffer8),
len(rx_buffer8),
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant