How can I put a bit mask on /dev/zero
so that I can have a source not only for 0x00 but also for any byte between 0x01 and 0xFF?
Devices – Apply Bit Mask on /dev/zero to Get Non-Zero Bytes
devices
Related Solutions
What is a Terminal?
A terminal consists of a screen and keyboard that one uses to communicate remotely with a computer (the host). One uses it almost like it was a personal computer but the terminal is remote from its host computer that it communicates with (on the other side of the room or even on the other side of the world).
Question 1
/dev/tty
stands for the controlling terminal (if any) for the current process. To find out which tty's are attached to which processes use theps -a
command at the shell prompt (command line). Look at thetty
column. For the shell process you're in,/dev/tty
is the terminal you are now using.- In Linux the PC monitor is called the console and has several device
special files associated with it:
tty0
,tty1
,tty2
, etc. When you log in you are ontty1
. To go totty2
press Alt-F2.tty1
,tty2
, etc. are virtual terminals (sometimes called "virtual consoles"). You may log in to different virtual terminals and thus have a few different sessions with the computer going on at the same time. You switch between them using the Alt-F? key where "?" is the virtual-terminal number you want. The console is also known as/dev/tty0
and system messages may go to that device and display on your console. Only the system or the root user may write to/dev/tty0
to which/dev/console
is sometimes linked. ttyprintk
is a pseudo TTY driver, which allows users to makeprintk
messages, via output tottyprintk
device./dev/tty/S[[:digit:]]
represents the serial ports. Each terminal is connected to a serial port on the host computer (often just a PC). The ports have names/numbers. The first few are:ttyS0
,ttyS1
,ttyS2
, etc. These are represented by special files found in the/dev
(device) directory.ttyS0
corresponds to COM1 in DOS or Windows.ttyS1
is COM2, etc.
Question 3 and Question 4 are related. Gilles has a wonderful explanation from here. Some of the excerpts from his answer are,
Pseudo-terminals are provided by a terminal emulator, which is an application. Some types of pseudo-terminals are:
- GUI applications such as xterm, gnome-terminal, konsole, … transform keyboard and mouse events into text input and display output graphically in some font.
- Multiplexer applications such as screen and tmux relay input and output from and to another terminal, to decouple text mode applications from the actual terminal.
- Remote shell applications such as sshd, telnetd, rlogind, … relay input and output between a remote terminal on the client and a pty on the server.
Also, from the wiki page of pseudo terminal, I see the below information.
The master device file, which generally has a name of the form /dev/pty[p-za-e][0-9a-f], is the endpoint for communication with the terminal emulator. With this [p-za-e] naming scheme, there can be at most 256 tty pairs. Also, finding the first free pty master can be racy unless a locking scheme is adopted. For that reason, recent BSD operating systems, such as FreeBSD, implement Unix98 PTYs.[4]
BSD PTYs have been rendered obsolete by Unix98 ptys whose naming system does not limit the number of pseudo-terminals and access to which occurs without danger of race conditions. /dev/ptmx is the "pseudo-terminal master multiplexer". Opening it returns a file descriptor of a master node and causes an associated slave node /dev/pts/N to be created
So I suspect /dev/pty
is not available which is why you see /dev/pts
.
References
http://www.tldp.org/HOWTO/Text-Terminal-HOWTO-7.html
Linux: Difference between /dev/console , /dev/tty and /dev/tty0
Argh and grumble. I should have paid better attention to the output of dmesg | grep ftdi
. There was ftdi stuff in there, but I didn't recognize any of it. In particular one brltty
was showing up. I should have googled it. At which point I would have discovered this is the "Braille Display" thing. So apparently, default out of the box sets up some braille driver stuff which likes to gobble up the /dev/ttyUSB*
before other things.
I removed it and all is well now. I did end up making the modprobe
lines more specific (including vendor and product). I have no idea whether that was necessary or not.
Best Answer
The following
bash
code is set to work with the byte being representred in binary. However you can easily change it to handle ocatal, decimal or hex by simply changing the radixr
value of2
to8
,10
or16
respectively and settingb=
accordingly.EDIT - It does handle the full range of byte values: hex 00-FF (when I wrote 00-7F below, I was considering only single-byte UTF-8 characters).
If, for example, you only want 4 bytes
(characters in the UTF-8 'ASCII'-only hex 00-7F range), you can pipe it into head:... | head -c4
Output (4 chars):
To see the output in 8-bit format, pipe it into
xxd
(or any other 1's and 0's byte dump*):eg.
b=10000000
and piping to:... | head -c4 | xxd -b