I'm connecting to a development board over a serial port like so..
$ screen /dev/ttyUSB0 9600
I'm connected to a boot loader now, and it is asking me to send a file in srec format. I have the file, but how can I send it over the screen session?
Hopefully you have already solved this problem yourself, but I'll answer in case anyone else have the same problem.
GNU screen has a command called readreg
which you can use to read a file into a register. After a register is filled with data you can paste that data using the paste
command.
Inside screen you press Ctr + a
and then :
to execute a command. Then you simply write and press enter:
readreg p /path/to/thefile
After you have executed the command you should se a message saying Slurped X character into buffer
.
You can then paste the data in that buffer by again pressing Ctr + a
and then :
, then write and press enter:
paste p
Note: p is the name of the register
And you're done.
You could also execute the commands outside the screen session using the -X
option. If you have a screen session named "ucontroller" which is attached to your serial port you can send the commands by executing:
screen -S ucontroller -X readreg p /path/to/thefile
screen -S ucontroller -X paste p
The information I have provided is taken directly from the man pages of screen(1)
, here is the relevant part of the man page:
readreg [-e encoding] [register [filename]]
Does one of two things, dependent on number of arguments: with zero or one arguments it it duplicates the paste buffer contents into the register specified or entered at the prompt.
With two arguments it reads the contents of the named file into the register, just as readbuf reads the screen-exchange file into the paste buffer. You can tell screen the encoding of the file via the -e option. The following example will paste the system's password file into the screen window (using register p, where a copy remains):
C-a : readreg p /etc/passwd
C-a : paste p
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With