Python Migration Guide
FrontPanel 6.0 introduces several breaking changes to the Python API. The most significant are:
- Device opening —
OpenBySerial()and device-listing methods are removed; useFrontPanelDevicesinstead - Data port separation — Wire, Trigger, Pipe, Register, and
ResetFPGAoperations move fromokCFrontPanelto a dedicatedokCFPGADataPortClassicobject - Standalone error codes —
okCFrontPanel.NoError,okCFrontPanel.Failed, etc. becomeok.ErrorCode.NoError,ok.ErrorCode.Failed - Removed convenience methods — Several methods eliminated in favor of
GetDeviceInfo()
Update Device Opening
OpenBySerial(), GetDeviceCount(), and GetDeviceListSerial() are removed. Use FrontPanelDevices instead.
# FP5:
xem = ok.okCFrontPanel()
xem.OpenBySerial("")
# FP6:
devices = ok.FrontPanelDevices()
xem = devices.Open()Code language: Python (python)Open() returns the device object directly. Pass a serial number to open a specific device, or pass an empty string (or omit) to open the first available device.
Device enumeration:
# FP5:
xem = ok.okCFrontPanel()
count = xem.GetDeviceCount()
for i in range(count):
serial = xem.GetDeviceListSerial(i)
# FP6:
devices = ok.FrontPanelDevices()
count = devices.GetCount()
for i in range(count):
serial = devices.GetSerial(i)Code language: Python (python)Obtain the Classic Data Port
After configuring the FPGA, call GetFPGADataPortClassic() on the device object. In Python, this returns the dataport object directly.
# FP5:
xem.ConfigureFPGA("my_design.bit")
if xem.IsFrontPanelEnabled():
print("FrontPanel support is enabled.")
xem.SetWireInValue(0x00, 0x01)
xem.UpdateWireIns()
# FP6:
xem.ConfigureFPGA("my_design.bit")
if xem.IsFrontPanelEnabled():
print("FrontPanel support is enabled.")
classic_data_port = xem.GetFPGADataPortClassic()
classic_data_port.SetWireInValue(0x00, 0x01)
classic_data_port.UpdateWireIns()Code language: Python (python)The object returned by GetFPGADataPortClassic() is owned by the device instance. It remains valid for the lifetime of that object.
Replace All Wire, Trigger, Pipe, and Register Calls
Change every call that previously went through the device object to go through the classic data port instead. The method names and parameters are identical — only the target object changes.
Wires:
# FP5:
xem.SetWireInValue(0x00, value, mask)
xem.UpdateWireIns()
xem.UpdateWireOuts()
out = xem.GetWireOutValue(0x20)
# FP6:
classic_data_port.SetWireInValue(0x00, value, mask)
classic_data_port.UpdateWireIns()
classic_data_port.UpdateWireOuts()
out = classic_data_port.GetWireOutValue(0x20)Code language: Python (python)Triggers:
# FP5:
xem.ActivateTriggerIn(0x40, 0)
xem.UpdateTriggerOuts()
if xem.IsTriggered(0x60, 1):
...
# FP6:
classic_data_port.ActivateTriggerIn(0x40, 0)
classic_data_port.UpdateTriggerOuts()
if classic_data_port.IsTriggered(0x60, 1):
...Code language: Python (python)Pipes:
# FP5:
xem.WriteToPipeIn(0x80, data)
xem.ReadFromPipeOut(0xA0, data)
xem.WriteToBlockPipeIn(0x80, blockSize, data)
xem.ReadFromBlockPipeOut(0xA0, blockSize, data)
# FP6:
classic_data_port.WriteToPipeIn(0x80, data)
classic_data_port.ReadFromPipeOut(0xA0, data)
classic_data_port.WriteToBlockPipeIn(0x80, blockSize, data)
classic_data_port.ReadFromBlockPipeOut(0xA0, blockSize, data)Code language: Python (python)Registers:
# FP5:
value = xem.ReadRegister(addr)
xem.WriteRegister(addr, data)
# FP6:
value = classic_data_port.ReadRegister(addr)
classic_data_port.WriteRegister(addr, data)Code language: Python (python)ResetFPGA:
# FP5:
xem.ResetFPGA()
# FP6:
classic_data_port.ResetFPGA()Code language: Python (python)Update Error Code References
Error code values are no longer attributes on okCFrontPanel. They are now members of the ok.ErrorCode enum.
# FP5:
if xem.ConfigureFPGA("design.bit") != xem.NoError:
...
# FP6:
if xem.ConfigureFPGA("design.bit") != ok.ErrorCode.NoError:
...Code language: Python (python)All error code values follow the same pattern:
xem.NoError→ok.ErrorCode.NoErrorxem.Failed→ok.ErrorCode.Failedxem.Timeout→ok.ErrorCode.Timeoutxem.DeviceNotOpen→ok.ErrorCode.DeviceNotOpenxem.FileError→ok.ErrorCode.FileErrorok.ErrorCodeis a PythonIntEnum, so you can use it in comparisons andstr()for display.
Replace Removed Convenience Methods
Several convenience methods are removed in favor of GetDeviceInfo():
# FP5:
serial = xem.GetSerialNumber()
model = xem.GetBoardModel()
major = xem.GetDeviceMajorVersion()
minor = xem.GetDeviceMinorVersion()
device_id = xem.GetDeviceID()
fast = xem.IsHighSpeed()
# FP6:
info = ok.okTDeviceInfo()
xem.GetDeviceInfo(info)
# info.serialNumber, info.deviceID, info.productName,
# info.productID, info.deviceMajorVersion, info.deviceMinorVersion,
# info.usbSpeed, info.wireWidthCode language: Python (python)Other removals:
GetErrorString()— useGetErrorMessage(ok.ErrorCode)insteadEnableAsynchronousTransfers()— removed, no replacementIsFrontPanel3Supported()— removed, no replacementGetHostInterfaceWidth()— useinfo.wireWidthfromGetDeviceInfo()GetDeviceListModel()— useFrontPanelDevices(see Step 1)
Update Helper Functions and Classes
If your code passes the device object to helper functions or classes solely for wire/trigger/pipe operations, update those to accept the classic data port instead.
# FP5:
class MyDevice:
def __init__(self, xem):
self.xem = xem
def read_status(self):
self.xem.UpdateWireOuts()
return self.xem.GetWireOutValue(0x20)
# FP6:
class MyDevice:
def __init__(self, classic_data_port):
self.dp = classic_data_port
def read_status(self):
self.dp.UpdateWireOuts()
return self.dp.GetWireOutValue(0x20)Code language: Python (python)If the helper also needs device management methods (e.g., IsOpen()), pass both:
class MyDevice:
def __init__(self, dev, classic_data_port):
self.dev = dev
self.dp = classic_data_port
def read_status(self):
if not self.dev.IsOpen():
return -1
self.dp.UpdateWireOuts()
return self.dp.GetWireOutValue(0x20)Code language: Python (python)Migration Checklist
- Replace
okCFrontPanel()+OpenBySerial("")withFrontPanelDevices().Open(). - After
ConfigureFPGA(), addclassic_data_port = xem.GetFPGADataPortClassic(). - Find-and-replace all wire/trigger/pipe/register calls from
xem.toclassic_data_port.. - Replace error code references:
xem.NoError→ok.ErrorCode.NoError. - Replace removed convenience methods with
GetDeviceInfo().