tty

Programming Linux serial port, ttyS0

。_饼干妹妹 提交于 2019-12-03 06:25:39
问题 I'm trying to learn how to program the ttyS0 serial port in Linux using C. I have another machine connected to my serial port sending alternating hex values of 5f and 6f about every two seconds. I've verified with other port monitoring apps that these values are appearing at the port. In my code I'm using a blocking read() into a 10 char length buffer. Even though my other machine is still sending data, read() blocks forever. If I include the line fcntl(fd, F_SETFL, FNDELAY); which sets read(

How to switch linux kernel console after boot process?

大兔子大兔子 提交于 2019-12-03 02:04:56
On my embedded system I usually use /dev/ttyS0 as a main console. This is achieved by passing kernel parameter console=/dev/ttyS0 and when init takes its part, getty is fired on the same device as specified in inittab by eg. ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100 . Is there any possibility to change these settings without restart and switch the console to another terminal like ttyS1 , ttyUSBx or even some pseudo tty? It seems that perhaps you don't actually want the console log messages on another device, but are only proposing to redirect them there to stop them from interfering

Why does ssh wait for my subshells without -t, and kill them with -t?

我只是一个虾纸丫 提交于 2019-12-03 01:59:51
I have a bash script start.sh which looks like this: for thing in foo bar; do { background_processor $thing cleanup_on_exit $thing } & done This does what I want: I run start.sh, it exits with code 0, and the two subshells run in the background. Each subshell runs background_processor , and when that exits, it runs cleanup_on_exit . This works even if I exit the terminal from which I originally ran start.sh (even if that was an ssh connection). Then I tried this: ssh user@host "start.sh" This works, except that after start.sh has exited, ssh apparently also waits for the subshells to exit. I

What does TTY mean in the unix ps command?

最后都变了- 提交于 2019-12-03 01:10:40
When I run PS one of the columns output is TTY. What does this mean? In particular, how does as value of "??" compare with "ttys000"? I ask because I have a Java program execute sort via ProcessBuilder, and when this program is run via my IDE (IntelliJ) the process takes 5x less than when run as an executable jar outside the IDE. In each case I run ps when the sort is running and the only difference is the IDE creats a process with a TTY of ?? whereas the jar creates a process with TTY of ttys000. A TTY is a computer terminal. In the context of ps , it is the terminal that executed a

Can you fool isatty AND log stdout and stderr separately?

拥有回忆 提交于 2019-12-02 20:09:36
Problem So you want to log the stdout and stderr (separately) of a process or subprocess, without the output being different from what you'd see in the terminal if you weren't logging anything. Seems pretty simple no? Well unfortunately, it appears that it may not be possible to write a general solution for this problem, that works on any given process... Background Pipe redirection is one method to separate stdout and stderr, allowing you to log them individually. Unfortunately, if you change the stdout/err to a pipe, the process may detect the pipe is not a tty (because it has no width

Programming Linux serial port, ttyS0

北城以北 提交于 2019-12-02 19:52:00
I'm trying to learn how to program the ttyS0 serial port in Linux using C. I have another machine connected to my serial port sending alternating hex values of 5f and 6f about every two seconds. I've verified with other port monitoring apps that these values are appearing at the port. In my code I'm using a blocking read() into a 10 char length buffer. Even though my other machine is still sending data, read() blocks forever. If I include the line fcntl(fd, F_SETFL, FNDELAY); which sets read() to non-blocking read() always returns with a value of -1, meaning no data was in the UART buffer, and

Executing string sent from one terminal in another in Linux pseudo-terminal

。_饼干妹妹 提交于 2019-12-02 13:14:47
Lets say I have one terminal where the output of "tty" is "/dev/pts/2" From another terminal, I want to send a command to the first terminal and execute it. Using: echo "ls" > "/dev/pts/2" only prints "ls" in the first terminal Is there a way to execute the string? No; terminals don't execute commands. They're just channels for data. You can sort of run a command and attach it to another terminal like this, though: ls </dev/pts/2 >/dev/pts/2 2>/dev/pts/2 It won't behave exactly like you ran it from that terminal, though, as it won't have that device set as its controlling terminal. It's

Change ttyUSB permissions using udev

不打扰是莪最后的温柔 提交于 2019-12-02 12:28:11
问题 My program needs to access ttyUSB without root permission. I tried changing it with chmod 777 /dev/ttyUSB0 as you know, when I reboot this permission changed to default. How can I configure my udev rules.d for this? 回答1: Look for ttyUSB* in the rules.d directory and update it to look lke below: KERNEL=="ttyUSB*", MODE="0777" Leave any other entries you find on the line unchanged, add the mode attribute if it does not exist. 来源: https://stackoverflow.com/questions/14291431/change-ttyusb

How to set a non-standard baudrate on a serial port device on Linux?

安稳与你 提交于 2019-12-02 09:16:50
What are the ways of setting custom baudrates on Linux? An answer to this question must be at a level of userland low-level APIs ( ioctl , etc.) above the level of a syscall. It should be useful in these circumstances at least: Writing low-level C-based userland code that uses serial ports, Writing libraries that abstract the serial port functionality, Writing kernel serial port drivers. Things are, unfortunately, driver-dependent. Good drivers will implement all of the methods below. Bad drivers will implement only some of the methods. Thus you need to try them all. All of the methods below

Why is terminfo[kcuu1] = '\EOA'?

北慕城南 提交于 2019-12-02 03:30:36
问题 From what I can tell reading terminfo(5) , kcuu1 should be the sequence that the terminal sends when the up arrow is pressed. I have never, ever seen that be anything other than ^[[A (speaking now about cat , messed up terminal settings, etc). So, given that the terminals I've used (rxvt, gnome-terminal, iTerm) all default to TERM=xterm, why isn't kcuu1 \E[A ? I see that cuu1 is \E[A , but (from the man page, again), that's the string that I should send to the terminal to move the cursor, not