from PyChipsUser import *
from FmcTluI2c import *

boardIpAddr = "192.168.200.16"
boardPortNum = 50001

addrTable = AddressTable("./aida_mini_tlu_addr_map.txt")

board = ChipsBusUdp(addrTable, boardIpAddr, boardPortNum)

# Check the bus for I2C devices
boardi2c = FmcTluI2c(board)

boardFirmware = board.read("FirmwareId")
print "Firmware version = " , hex(boardFirmware)

#scanResults = boardi2c.i2c_scan()
#print scanResults

boardId = boardi2c.get_serial_number()
print "FMC-TLU serial number = " , boardId

# Set thresholds at about -0.1V ( with 1MOhm f/back resistors )
print "Setting Vthreshold to about -0.1V"
boardi2c.set_dac(7,0x4100)

