tty

How can I read the terminal input on a tty device before a newline arrives?

一世执手 提交于 2019-12-11 01:14:52
问题 I am reading a serial device using embedded linux (angstrom) using open(), tcget/setattr(), read(). I can read and write data just fine. However, the device I am reading displays a prompt that is not terminated with a newline. This means I can't read the prompt until after I cause the device to send some other output that has a newline at the end. Basically, I know the prompt string ("COM3>") is sitting in the tty buffer waiting for the device to send a newline. read() won't access the "COM3>

What is a TTY and how can I enable it on Ubuntu?

穿精又带淫゛_ 提交于 2019-12-10 19:24:08
问题 I'm currently setting up a node.js server and I'm using the debug module here https://github.com/visionmedia/debug. I'm trying to enable it so I can get the colored debugging information in my output, however my terminal looks like the last terminal screen at the bottom after it says: When stdout is not a TTY, Date#toUTCString() is used, making it more useful for logging the debug information as shown below: Can anyone shed some light on this? Thanks. 回答1: tty is one of those funky Unix

Terminfo smkx and Application Cursor Keys vs Application keypad

妖精的绣舞 提交于 2019-12-10 15:09:34
问题 XTerm Control Sequences specifies the following key sequences: CSI ? 1 h → Application Cursor Keys (DECCKM) CSI ? 1 l → Normal Cursor Mode (DECOM) CSI ? 66 h → Application keypad (DECNKM) CSI ? 66 l → Numeric keypad (DECNKM) and the Terminfo Source Format has the following entry: Variable: keypad_xmit Capname: smkx Termcap: ks Description: Put terminal in "keypad-transmit" mode But the terminfo for xterm actually says smkx=\E[?1h\E= , which seems mixed up to me (smkx should affect the keypad,

Is there a way to wait for and get a key press from a (remote) terminal session?

北慕城南 提交于 2019-12-09 23:29:33
问题 I've been playing around with some ANSI stuff (like colors etc.) in java and php (from scratch) and I'm trying to find a way to basically wait for a key press. I'd like to have something like the following pseudo code at the end of my main event loop: If (KeyPressed) Begin var event = new KeyboardEvent(); event.Key = ReadKey(); this.BubbleEvent(event); End But everything I've been trying over the last couple days fails because the key presses only become available on STDIN after the user has

Correct initialization sequence for Linux serial port

亡梦爱人 提交于 2019-12-08 19:46:18
问题 I wrote an application that must use serial ports on Linux, especially ttyUSB ones. Reading and writing operations are performed with standard select()/read() loop and write(), and there is probably nothing wrong in them, but initialization code (or absence of some part of it) damages something in the tty subsystem. Here it is: vuxboot(string filename, unsigned baud = B115200) : _debug(false) { _fd = open(filename.c_str(), O_RDWR | O_NOCTTY); if(_fd < 0) throw new io_error("cannot open port")

Is it possible to accept user input as part of a remote git post-receive hook?

我的梦境 提交于 2019-12-07 06:13:51
问题 I've got a post-receive hook that deploys our master branch whenever we push master. I'd like to make the deployment optional; the hook asks for simple Y/N response to achieve this; bash pseudo code below: echo "Should I deploy this code now? Enter Y/N" read deploy_code case ${deploy_code} in "Y") do_a_deploy ;; "N") exit ;; *) # ask the question again if not Y or N ;; esac Because of the way the post-receive hook gets its arguments on stdin the read line doesn't pause for input from the user

Why can't I open/write from a serial port on Android?

风流意气都作罢 提交于 2019-12-06 10:13:12
问题 I have written an Android app which runs on a custom kernel on Android 4.4 Kitkat device, which uses the Android Serial Port API (https://code.google.com/p/android-serialport-api/) in order to open the serial port "/dev/ttyACM0" which is the port associated with my serial device. The port has the proper "666" permissions (crw-rw-rw), and the app itself even has the WRITE_EXTERNAL_STORAGE" permission. However, even though the permissions appear correct, when my app tries to open said serial

Is low latency mode safe to use with Linux serial ports?

廉价感情. 提交于 2019-12-06 05:11:18
问题 Is it safe to use the low_latency tty mode with Linux serial ports? The tty_flip_buffer_push function is documented that it "must not be called from IRQ context if port->low_latency is set." Nevertheless, many low-level serial port drivers call it from an ISR whether or not the flag is set. For example, the mpc52xx driver calls flip buffer unconditionally after each read from its FIFO. A consequence of the low latency flip buffer in the ISR is that the line discipline driver is entered within

Printed length of a string in python

最后都变了- 提交于 2019-12-06 01:31:21
问题 Is there any way to find (even a best guess) the "printed" length of a string in python? E.g. 'potaa\bto' is 8 characters in len but only 6 characters wide printed on a tty. Expected usage: s = 'potato\x1b[01;32mpotato\x1b[0;0mpotato' len(s) # 32 plen(s) # 18 回答1: At least for the ANSI TTY escape sequence, this works: import re strip_ANSI_pat = re.compile(r""" \x1b # literal ESC \[ # literal [ [;\d]* # zero or more digits or semicolons [A-Za-z] # a letter """, re.VERBOSE).sub def strip_ANSI(s

How to kill respawned process by init in linux

試著忘記壹切 提交于 2019-12-05 13:26:58
am respawning the /bin/bash on ttyS1 port.ttyS0 is my console. inittab entry is given below. ::respawn:/bin/bash < /dev/ttyS1 > /dev/ttyS1 2> /dev/ttyS1 My question is how to disable/kill respwning so that i can use serial port for other application. You can kill that bash process like other processes. However, init respawns it immediately - nothing gained. To disable the process you have to edit /etc/inittab and comment out that line. To inform init about this change you have to send a SIGHUP to init: kill -HUP pid-of-init . (I think that pid-of-init is always 1). If you need your bash