spi read and write_read calls do will raise an exception as out values are in parameter list instead of being return values
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
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
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), )
Hi there, you are correct, I goofed up the SPI prototypes with some previous update (I need to find a way to test that automatically).
I pushed the updated binding to main for you to try: See https://github.com/mariusgreuel/dwfpy/wiki/Developer-Cheat-Sheet