Extract the code to send the command in a helper function called send().

Signed-off-by: Thiago Farina <tfarina@chromium.org>