kermit doesn't wait long enough

261 views Asked by At

I'm writing a kermit script to start an elf on an IMX board running a custom kernel and I'm trying to capture a string written by the elf, with the following script:

set input echo on
lineout tests_domains/usb/hid/build/test  # send elf name to the board's shell
minput 40 "<--- PNC TEST STATUS: PASS" "<--- PNC TEST STATUS: INCONCLUSIVE" "<--- PNC TEST STATUS: FAIL" "<--- PNC TEST STATUS: NOTRUN" "<--- PNC TEST STATUS: TIMEOUT"
switch \v(minput) {
  :1, echo "TEST PASS", exit 0
  :2, echo "TEST INCONCLUSIVE", exit 1
  :3, echo "TEST FAIL", exit 2
  :4, echo "TEST NOTRUN", exit 3
  :5, echo "TEST TIMEOUT", exit 4
  :default, echo "entering default case", echo \v(minput), exit 255
}

However minput returns before having received one of the <--- PNC TESTS STATUS string and before 40 seconds. It returns circa 5~6 seconds after having launched the elf.

The full output of the board on its uart is as follows: https://pastebin.com/vsps5ZQ1 It ends up correctly with <--- PNC TEST STATUS: PASS

Whereas when capturing the output with the script above, it terminates as follows: https://pastebin.com/wFSDdn5s Output shows that the default case of the switch is executed, after having captured the string "0". It always return after a string of the form [ 6.099262][usbd:imx ] prime_endpoint: IN endpoint 1 (3) (last line written by the board in the second paste). I don't understand why the latter happens.

If there are alternatives to kermit to perform what I'm doing, please propose them to me. Online documentation for kermit is sparse.

Final note: ny kermit startup script (~/.kermrc) is as follows:

set line /dev/ttyUSB0
set speed 115200
set carrier-watch off
set handshake none
set flow-control none
robust
set file type bin
set file name lit
set rec pack 1000
set send pack 1000
set window 5
1

There are 1 answers

1
Dario On BEST ANSWER

\v(minput) expands to the index of the received string, and indexing is zero-based. This means that you should have written

minput 40 "<--- PNC TEST STATUS: PASS" "<--- PNC TEST STATUS: INCONCLUSIVE" "<--- PNC TEST STATUS: FAIL" "<--- PNC TEST STATUS: NOTRUN" "<--- PNC TEST STATUS: TIMEOUT"
switch \v(minput) {
  :0, echo "TEST PASS", exit 0
  :1, echo "TEST INCONCLUSIVE", exit 1
  :2, echo "TEST FAIL", exit 2
  :3, echo "TEST NOTRUN", exit 3
  :4, echo "TEST TIMEOUT", exit 4
  :default, echo "entering default case", echo \v(minput), exit 255
}

What happens with your code is that, upon receiving <--- PNC TEST STATUS: PASS, minput exits with \v(minput) set to 0 and the switch only matches the default. The 0 in your output is not the string being received, it is its index as given to minput.