简体   繁体   中英

How to close usb screen session on Raspberry Pi?

I normally use the GNU screen to open virtual terminals on servers so that long running programs can run while I log out or get disconnected. I'm now messing around with a Raspberry pi to which I attached a Sparkfun OpenScale to read out a load cell (a weighting scale to measure my body weight).

To read out this OpenScale board I connect to it using

screen /dev/ttyUSB0 9600

after which I get a terminal program with some options:

Serial Load Cell Converter version 1.0
By SparkFun Electronics
No remote sensor found
System Configuration
1) Tare scale to zero [-23555]
2) Calibrate scale [-9649]
3) Timestamp [Off]
4) Set report rate [95]
5) Set baud rate [9600 bps]
6) Change units of measure [kg]
7) Decimals [1]
8) Average amount [1]
9) Local temp [Off]
r) Remote temp [Off]
s) Status LED [Off]
t) Serial trigger [Off]
q) Raw reading [Off]
c) Trigger character: [120]
x) Exit

This works fine and after some calibration I get good readings. The things is that I don't understand how I can exit this program. If you see the menu above you might think that I can simply press x , but that just exits this menu after which you go into measurements reading mode (it just starts printing the weights it gets from the scale). If I then press x again it simply opens up this menu again.

I tried a multitude of things to close this:

q
x
Ctrl + c
Ctrl + d
Esc
Backspace

I can of course detach from the session (using Ctrl + a and then pressing d ) and then killing the screen session, but the program doesn't store the tarring to zero. It correctly stores the calibration, but not the zero point, which make readings totally false and it makes me need to tar to zero every time I reboot. That is the reason why I thought that properly exiting the program would maybe properly save the zero point.

Does anybody know a way to properly exit this program?

Since you are using screen as a terminal emulator for a serial device, unless the serial device itself stores the calibration data in some kind of NVRAM you may need to run the re-calibration every time you reset the Raspberry Pi.

I would recommend starting screen with the -L option to log the output to a file. Once the calibration routine is complete you can detach from screen session using Ctrl-a d . However the log file should continue to grow with the weights being measured.

However, if you truly want to exit screen so that another process can open and read from the serial device then you can use Ctrl-a \\ . Screen will prompt you if you want to exit, type y to exit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM