annetutil / gnetcli

The ultimate solution for CLI automation in Golang
MIT License
35 stars 4 forks source link

Issue with Traffic Dump Command on ROS Devices #65

Closed miasalexey closed 3 weeks ago

miasalexey commented 1 month ago

Hello, I encountered an issue with ROS devices. When entering commands related to traffic dump on a port for a short period of time, I observed a problem. In my example, I am capturing traffic from ether2 for 2 seconds. Here is an example of how the command is executed:

err := dev.Connect(ctx)
if err != nil {
    panic(err)
}

defer dev.Close()

res, err := dev.Execute(cmd.NewCmd("/tool sniffer quick interface=ether2 direction=rx duration=2"))
if err != nil {
    fmt.Println(err)
}
if res.Status() == 0 {
    fmt.Printf("Result: %s\n", res.Output())
} else {
    fmt.Printf("Error: %s\nStatus: %d\n", res.Error(), res.Status())
}

In the logger, the result of the command execution is visible, but at the end, it throws an error:

unknown esc A ...                       PROTOCOL   SIZE CPU FP 
INTERFACE                                        ... 

Could you please advise how to fix this issue? Thank you!

gescheit commented 3 weeks ago

Hi! Sorry for the delay. Error "unknown esc A" means what the device is using an unimplemented in gnetcli terminal parser Cursor Up command. This 'tool sniffer quick' command produces interactive output suitable for terminal, it redraws frame with sniffed packets a couple times a second. Terminal parser in gnetcli is trying to evaluate the output so it would like the last frame in the terminal with cropped data in your case. I recommend you to add without-paging to tool sniffer quick so it will produce the output without redrawing it in the terminal.

miasalexey commented 3 weeks ago

Hi! Sorry for the delay. Error "unknown esc A" means what the device is using an unimplemented in gnetcli terminal parser Cursor Up command. This 'tool sniffer quick' command produces interactive output suitable for terminal, it redraws frame with sniffed packets a couple times a second. Terminal parser in gnetcli is trying to evaluate the output so it would like the last frame in the terminal with cropped data in your case. I recommend you to add without-paging to tool sniffer quick so it will produce the output without redrawing it in the terminal.

Tt's working thank you