UART expect v extract
What happens with an 'expect' and 'extract' clause in the same UART command?
I ask in that I'm getting unexpected behaivor.
With the following test plan:
- ident: FW
title: Firmware Revision
steps:
- uartcmd: uart UART0
send: 'info fwver\r\n' #needs parsing
expect: '+RES 0'
extract: 'VAL val\[(.*)]\r\n'
extractKey: FWVER
timeoutms: 20000
And the following UART log:
CLI>info fwver
+VAL val[0.0.5.5]
+RES 1
CLI>
I'm getting a "PASS". This is troubling in that the expected string ("RES 1") didn't come. Can I imply that if the EXTRACT clause is satisified then the EXPECT clause is ignored?
-
To clarify, was that a typo in your comment above, where you said "This is troubling in that the expected string ("RES 1") didn't come". Did you mean that "+RES 0" didn't come?
I think this may be a limitation of the uart command. Generally the expect value is used before extraction. The idea being, watch the input coming in, go until an expected string is found, then extract a value out.
Looking into it...
-
You shouldn't rely on this behavior, because I think this is a bug. We don't intend to have this command PASS when expect isn't satisfied.
My advice with this command at the moment would be to write it something like:
- ident: FW
title: Firmware Revision
steps:
- uartcmd: uart UART0
send: 'info fwver\r\n' #needs parsing
expect: 'VAL val'
extract: 'VAL val\[(.*)]\r\n'
extractKey: FWVER
timeoutms: 20000
Please sign in to leave a comment.
Comments
3 comments