io: followup fix for retry-first-ident

followup fix: no error was raised ever for the first identification
message.

Change-Id: I80f0f431add6dfd7b37d750b9fc661174aa8f217
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/31318
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Georg Brandl <g.brandl@fz-juelich.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
This commit is contained in:
Alexander Zaft 2023-06-12 08:09:24 +02:00 committed by Markus Zolliker
parent fd917724d8
commit dff0c819de

View File

@ -269,16 +269,21 @@ class StringIO(IOBase):
idents = iter(self.identification) idents = iter(self.identification)
command, regexp = next(idents) command, regexp = next(idents)
reply = self.communicate(command) reply = self.communicate(command)
if self.retry_first_idn and not re.match(regexp, reply): if not re.match(regexp, reply):
self.log.debug('first ident command not successful.' if self.retry_first_idn:
' retrying in case of garbage data.') self.log.debug('first ident command not successful.'
idents = iter(self.identification) ' retrying in case of garbage data.')
idents = iter(self.identification)
else:
self.closeConnection()
raise CommunicationFailedError(f'bad response: {reply!r}'
f' does not match {regexp!r}')
for command, regexp in idents: for command, regexp in idents:
reply = self.communicate(command) reply = self.communicate(command)
if not re.match(regexp, reply): if not re.match(regexp, reply):
self.closeConnection() self.closeConnection()
raise CommunicationFailedError(f'bad response: {reply}' raise CommunicationFailedError(f'bad response: {reply!r}'
' does not match {regexp}') f' does not match {regexp!r}')
@Command(StringType(), result=StringType()) @Command(StringType(), result=StringType())
def communicate(self, command): def communicate(self, command):