Skip to content

Commit

Permalink
Only allow one match when FTDI attributes are used to identify a device.
Browse files Browse the repository at this point in the history
  • Loading branch information
docbacardi committed Oct 11, 2024
1 parent 760dd0e commit 1e68d97
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion iomatrix/templates/io_matrix/ftdi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ function IoMatrix_FTDI:__find_ftdi_devices(atAllDevices, atDeviceAttr)
)
end
else
local atMatchingDevices = {}
for _, tDevice in pairs(atAllDevices) do
-- Is the device already part of the identified devices?
for _, tIdentDev in pairs(self.atDeviceAttrs) do
Expand All @@ -211,11 +212,20 @@ function IoMatrix_FTDI:__find_ftdi_devices(atAllDevices, atDeviceAttr)
self.tLog.debug('The module index of device [%s] does not match.', tDevice.strPrettyPortNumbers)
else
self.tLog.debug('Device [%s] matches.', tDevice.strPrettyPortNumbers)
tFoundDevice = tDevice
table.insert(atMatchingDevices, tDevice)
break
end
end
end
local sizMatchingDevices = #atMatchingDevices
if sizMatchingDevices==1 then
-- There is exactly one matching device.
tFoundDevice = atMatchingDevices[1]
elseif sizMatchingDevices==0 then
self.tLog.error('No device matches the search criteria.')
else
self.tLog.error('%d devices matches the search criteria. There should be exactly one.', sizMatchingDevices)
end
end

if tFoundDevice==nil then
Expand Down

0 comments on commit 1e68d97

Please sign in to comment.