Skip to content

Commit 68c15fe

Browse files
committed
FlyCapture2_Camera-bugfixes: Add automatic configuration of packet size for GigE cameras.
Device will now automatically set to the largest possible packet size available on the network. If Jumbo Frames are not available, print a warning. This also prints what the packet size is set to if it is changed.
1 parent 885ed42 commit 68c15fe

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

FlyCapture2Camera/blacs_workers.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,29 @@ def __init__(self, serial_number):
6060
self.pixel_formats = IntEnum('pixel_formats',fmts)
6161

6262
self._abort_acquisition = False
63+
64+
# check if GigE camera. If so, ensure max packet size is used
65+
cam_info = self.camera.getCameraInfo()
66+
if cam_info.interfaceType == PyCapture2.INTERFACE_TYPE.GIGE:
67+
# open second GigE interface to camera with GigE config functions
68+
gige_camera = PyCapture2.GigECamera()
69+
gige_camera.connect(bus.getCameraFromSerialNumber(serial_number))
70+
mtu = gige_camera.discoverGigEPacketSize()
71+
if mtu <= 1500:
72+
msg = """Maximum Transmission Unit (MTU) for ethernet NIC
73+
FlyCapture2_Camera '%s' is connected to is only %d. Reliable
74+
operation not expected. Please enable Jumbo frames on NIC."""
75+
print(dedent(msg%(self.device_name,mtu)))
76+
77+
gige_pkt_size = gige_camera.getGigEProperty(PyCapture2.GIGE_PROPERTY_TYPE.GIGE_PACKET_SIZE)
78+
# only set if not already at correct value
79+
if gige_pkt_size.value != mtu:
80+
gige_pkt_size.value = mtu
81+
gige_camera.setGigEProperty(PyCapture2.GIGE_PROPERTY_TYPE.GIGE_PACKET_SIZE)
82+
print('Packet size set to %d'%mtu)
83+
84+
# close second handle to camera
85+
gige_camera.disconnect()
6386

6487
def set_attributes(self, attr_dict):
6588
"""Sets all attribues in attr_dict.

0 commit comments

Comments
 (0)