Thanks for your reply attila.
In that case with single device, I need to do configuration as Slave, read data, switch configuration to Master and forward it?
What if I use 2x devices? In that case is it possible to have Slave running in one device, master in the second one and share data between it?
Is there an example for something close to the configuration switching?
I was also trying with SDK python, but here I cant read anything.
from ctypes import *
import math
import sys
import time
import numpy
if sys.platform.startswith("win"):
dwf = cdll.LoadLibrary("dwf.dll")
elif sys.platform.startswith("darwin"):
dwf = cdll.LoadLibrary("/Library/Frameworks/dwf.framework/dwf")
else:
dwf = cdll.LoadLibrary("libdwf.so")
hdwf = c_int()
rgbTX = (c_ubyte*8)(0,1,2,3,4,5,6,7)
rgbRX = (c_ubyte*8)()
print("Opening first device")
dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf))
# device configuration of index 3 (4th) for Analog Discovery has 16kS digital-in/out buffer
# dwf.FDwfDeviceConfigOpen(c_int(-1), c_int(3), byref(hdwf))
if hdwf.value == 0:
print("failed to open device")
szerr = create_string_buffer(512)
dwf.FDwfGetLastErrorMsg(szerr)
print(str(szerr.value))
quit()
print("Configuring SPI CH1")
# Configure the first SPI channel (DIO 0 - CS , DIO 1 - SCK, DIO 2 - MISO)
dwf.FDwfDigitalSpiModeSet(hdwf, c_int(1)) # Mode 1
dwf.FDwfDigitalSpiFrequencySet(hdwf, c_double(1e6)) # 1 MHz frequency
dwf.FDwfDigitalSpiClockSet(c_int(1)) # DIO 1 for clock (SCK)
# idxDQ – specify data index to set, 0 = DQ0_MOSI_SISO, 1 = DQ1_MISO, 2 = DQ2, 3 = DQ3
# idxChannel – DIO channel to use for SPI data
dwf.FDwfDigitalSpiDataSet(hdwf, c_int(1), c_int(2)) # 1 DQ1_MISO = DIO-2
dwf.FDwfDigitalSpiSelectSet(hdwf, c_int(0), c_int(1)) # CS: DIO-0, idle high
dwf.FDwfDigitalSpiOrderSet(hdwf, c_int(1)) # 1 MSB first
print("Configuring SPI CH2")
# Configure the first SPI channel (DIO 3 - CS , DIO 4 - SCK, DIO 5 - MOSI)
dwf.FDwfDigitalSpiModeSet(hdwf, c_int(1)) # Mode 1
dwf.FDwfDigitalSpiFrequencySet(hdwf, c_double(1e6)) # 1 MHz frequency
dwf.FDwfDigitalSpiClockSet(c_int(4)) # DIO 4 for clock (SCK)
# idxDQ – specify data index to set, 0 = DQ0_MOSI_SISO, 1 = DQ1_MISO, 2 = DQ2, 3 = DQ3
# idxChannel – DIO channel to use for SPI data
dwf.FDwfDigitalSpiDataSet(hdwf, c_int(0), c_int(5)) # 0 DQ0_MOSI_SISO = DIO-5
dwf.FDwfDigitalSpiSelectSet(hdwf, c_int(3), c_int(1)) # CS: DIO-3, idle high
dwf.FDwfDigitalSpiOrderSet(hdwf, c_int(1)) # 1 MSB first
while True:
dwf.FDwfDigitalSpiRead(hdwf, c_int(1), c_int(8), rgbRX, c_int(len(rgbRX)))
# Convert each byte in rgbRX to a hexadecimal string with leading zeros
hex_values = ['0x{:02X}'.format(x) for x in numpy.fromiter(rgbRX, dtype=numpy.uint8)]
# Join the hex values into a single string separated by spaces
print("RX: " + ' '.join(hex_values))
dwf.FDwfDigitalSpiWrite(hdwf, c_int(0), c_int(8), rgbTX, c_int(len(rgbTX)))
# Convert each byte in rgbRX to a hexadecimal string with leading zeros
hex_values = ['0x{:02X}'.format(x) for x in numpy.fromiter(rgbTX, dtype=numpy.uint8)]
# Join the hex values into a single string separated by spaces
# print("TX: " + ' '.join(hex_values))
time.sleep(0.1)