bashminicom

Send picocom commands via a bash script


I want to update the firmware of my device via a script using picocom commands to send the file (ymodem protocol). When I start picocom manually, with the relevant parameters (as below), it works. E.g. I can send the command via the terminal to restart the device. It works.

picocom /dev/ttyACM0 -b 115200

However, when I put the same command in a bash script I get the error 'no such file or directoryACM0' when I run the script. The user has been added to the dialout and tty groups. So I am puzzled by the error. any suggestions would be helpful. I also tried minicom, but did not have much luck.

port is        : /dev/ttyACM0
flowcontrol    : none
baudrate is    : 115200
parity is      : none
databits are   : 8
stopbits are   : 1
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
hangup is      : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv -E
imap is        : 
omap is        : 
emap is        : crcrlf,delbs,
logfile is     : none
initstring     : none
exit_after is  : not set
exit is        : no

: No such file or directoryACM0

Here are a couple examples of the commands that I want to send:

command: #000C0074B0FFFF28!  
command: 1 

Solution

  • You can try sending the commands through picocom's stdin, but might have to translate explicitly the Ctrl‑key sequences if you need them. For example Ctrlq should be translated to 0x11 (see this table for the other sequences):

    Update:

    An example with the given commands and a here-document would be:

    picocom /dev/ttyACM0 -b 115200 <<'EOF'
    #000C0074B0FFFF28!
    1
    EOF