Download TE USB API - Trenz Electronic
Transcript
Appendix B. Example program source code
UM-FX2-USB-API (v 1.01) 7 May 2012
print "ERROR: Failed to connect card"
raw_input('Press Enter...')
sys.exit()
print "Connected to card 1"
# Print FX2 firmware version
# prepare arguments to pass API function
cmd = create_string_buffer(64)
reply = create_string_buffer(64)
cmd[0] = CMD_FX2_READ_VERSION
cmd_length = c_int(64)
reply_length = c_int(64)
timeout_ms = c_int(1000)
SendCommand = fx2dll.TE0300_SendCommand
SendCommand.restype = c_int
# Call API
if SendCommand(m_handle, cmd, cmd_length, byref(reply),
byref(reply_length), timeout_ms) != 0:
print "ERROR: Can't call API function
TE0300_SendCommand"
raw_input('Press Enter...')
sys.exit()
if reply_length.value >= 4:
print "FX2 Firmware version %d.%d " % (ord(reply[0]),
ord(reply[1]))
print "Device version %d.%d" % (ord(reply[2]),
ord(reply[3]))
else:
print "ERROR: Unexpected command result:
TE0300_SendCommand"
raw_input('Press Enter...')
sys.exit()
fx2dll.TE0300_Close(byref(m_handle))
print "Test finished"
raw_input('Press Enter...')
21/36
www.trenz-electronic.de
TE USB API