Code: Select all
#!/usr/bin/python
import sys
import redpitaya_scpi as scpi
rp_s = scpi.scpi(sys.argv[1])
# Set both to be input pins
rp_s.tx_txt('DIG:PIN:DIR IN,DIO0_N')
rp_s.tx_txt('DIG:PIN:DIR IN,DIO1_N')
# Get the state of both pins
print ("Initial state:")
rp_s.tx_txt('DIG:PIN? DIO0_N')
state = rp_s.rx_txt()
print ('DIO0_N is ' + str(state))
rp_s.tx_txt('DIG:PIN? DIO1_N')
state = rp_s.rx_txt()
print ('DIO1_N is ' + str(state))
Code: Select all
Initial state:
DIO0_N is 1
DIO1_N is 1
Code: Select all
# Set both to be output pins
rp_s.tx_txt('DIG:PIN:DIR OUT,DIO0_N')
rp_s.tx_txt('DIG:PIN:DIR OUT,DIO1_N')
# Set them both high
rp_s.tx_txt('DIG:PIN DIO0_N, '+str(1))
rp_s.tx_txt('DIG:PIN DIO1_N, '+str(1))
# Set both to be input pins
rp_s.tx_txt('DIG:PIN:DIR IN,DIO0_N')
rp_s.tx_txt('DIG:PIN:DIR IN,DIO1_N')
# Get the state of both pins
print("Set high:")
rp_s.tx_txt('DIG:PIN? DIO0_N')
state = rp_s.rx_txt()
print ('DIO0_N is ' + str(state))
rp_s.tx_txt('DIG:PIN? DIO1_N')
state = rp_s.rx_txt()
print ('DIO1_N is ' + str(state))
Code: Select all
Set high:
DIO0_N is 1
DIO1_N is 1
Code: Select all
# Set them both to be output pins
rp_s.tx_txt('DIG:PIN:DIR OUT,DIO0_N')
rp_s.tx_txt('DIG:PIN:DIR OUT,DIO1_N')
# Set them both low
rp_s.tx_txt('DIG:PIN DIO0_N, ' + str(0))
rp_s.tx_txt('DIG:PIN DIO1_N, ' + str(0))
# Set both to be input pins
rp_s.tx_txt('DIG:PIN:DIR IN,DIO0_N')
rp_s.tx_txt('DIG:PIN:DIR IN,DIO1_N')
# Get the state of both pins
print("Set low:")
rp_s.tx_txt('DIG:PIN? DIO0_N')
state = rp_s.rx_txt()
print ('DIO0_N is ' + str(state))
rp_s.tx_txt('DIG:PIN? DIO1_N')
state = rp_s.rx_txt()
print ('DIO1_N is ' + str(state))
Code: Select all
Set low:
DIO0_N is 0
DIO1_N is 1