简体   繁体   English

如何在Raspberry Pi上关闭USB屏幕会话?

[英]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. 我通常使用GNU屏幕打开服务器上的虚拟终端,以便在注销或断开连接时可以运行长时间运行的程序。 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). 我现在在弄乱Raspberry pi,我在上面附加了一个Sparkfun OpenScale来读取称重传感器 (用于衡量我的体重的体重秤)。

To read out this OpenScale board I connect to it using 要读取此OpenScale板,请使用

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). 如果您看到上面的菜单,您可能会认为我可以按x ,但这只是退出此菜单,然后进入测量读数模式(它开始打印从秤上获得的权重)。 If I then press x again it simply opens up this menu again. 如果再按一次x ,则只需再次打开此菜单。

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. 我当然可以从会话中分离(使用Ctrl + a然后按d ),然后终止屏幕会话,但是该程序不会将目标存储为零。 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. 它正确存储了校准,但没有正确存储零点,这使读数完全错误,并且每次重新启动时都需要将tar降至零。 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. 由于您将屏幕用作串行设备的终端仿真器,除非串行设备本身将校准数据存储在某种NVRAM中,否则您每次重置Raspberry Pi时都可能需要运行重新校准。

I would recommend starting screen with the -L option to log the output to a file. 我建议使用-L选项启动屏幕以将输出记录到文件中。 Once the calibration routine is complete you can detach from screen session using Ctrl-a d . 校准例程完成后,您可以使用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 \\ . 但是,如果您确实要退出屏幕,以便可以打开另一个进程并从串行设备中读取,则可以使用Ctrl-a \\ Screen will prompt you if you want to exit, type y to exit. 屏幕将提示您是否要退出,请键入y退出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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