cis 191: linux and unix class 9 april 1, 2015 hardware, project, and devices

29
CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Upload: moris-gray

Post on 11-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

CIS 191: Linux and Unix

Class 9April 1, 2015

Hardware, Project, and Devices

Page 2: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Outline

Final Project Overview

Amazingly Short Hardware Brief

rm –rf /

Part Handout

Page 3: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Raspberry PI

• For the final project, you’ll be working with a raspberry pi project to make something cool using your unix skills

• There are plenty of projects out there that can run on pis• We’ll be giving you the pis, and you already have access

to the internet

Page 4: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Raspberry PI

• For the final project, you’ll be working with a raspberry pi project to make something cool using your unix skills

• There are plenty of projects out there that can run on pis• We’ll be giving you the pis, and you already have access

to the internet• We just want you to make something cool• And sufficiently difficult…

Page 5: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Due Date

• The final project will be due on our last day of class, which is April 29th.

• So you have 4 weeks– Which should honestly be more than enough time to make

something great

Page 6: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Raspberry PIs are…

• A full multipurpose computer on a chip• Strong enough to run an Xbox media center emulation!• fully equipped with general purpose I/O pins

– We’ll go over how to use these a bit next week

• unable to handle anything more than 5 volts– so don’t try to output more than that or you’ll break it– In fact, don’t try to output more than 3.3V

• really cool

Page 7: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Running the raspberry pi

• You’ll have to load up an image• We’re not going to force you to use any in particular

– The official distribution is “raspbian”, which should also be fine• It’s also a derivative of debian, after all• This means apt-get is a-go

Page 8: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Raspberry PI project ideas…

• Let’s just look at youtube!

Page 9: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Outline

Final Project Overview

Amazingly Short Hardware Brief

rm –rf /

Part Handout

Page 10: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Ohm’s Law

V = IR

http://www.electrical4u.com/wp-content/uploads/2013/03/ohm-law-2.jpg

Page 11: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Vary Resistance

• You can vary resistance to modify the behavior of a circuit

• For example, in this fart detector project linked to on piazza, the circuit is modified to the ambient gas environment using a resistor ladder– This prevents false fart positives

Page 12: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Breadboards

http://www.mikroe.com/img/development-tools/compontents/breadboard-400/breadboard_400.png

Page 13: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

How to strip a wire

• https://www.youtube.com/watch?v=TZFTKbT4XFs

Page 14: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Color Coding your Circuit

• Red should come from source• Black should go to ground• Inner colors aren’t important

Page 15: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Polarized Parts

• Current can flow from the anode (the + terminal) to the cathode (the – terminal).

• BUT NOT THE OTHER WAY AROUND!

• Damage the parts and (maybe) even yourself

• See this sparkfun link to learn more

Polarized LED

Page 16: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

How to make a basic LED circuit

https://www.youtube.com/watch?v=k9jcHB9tWko

Page 17: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Raspberry Pi GPIO

• GPIO on the Raspberry Pi can be controlled pretty easily• To write to output, you can either write to a few files

through the terminal, use the gpio utility, or use a python interface.

• To read from the input, you can use the gpio utility or use the python interface.– Note that this can be a little iffy… they are digital input pins after

all– Anyone see how this might be a problem? How to work around

it?

Page 18: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Outline

Amazingly Short Hardware Brief

A Little More About /dev

rm –rf /

Part Handout

Page 19: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Remember /dev?

• /dev contains system device files• Linux systems accomplish tons of magic by treating

devices as special files– And by pretending that certain non-device objects are files…– Linux employs devices to provide lightweight “system services”

• The contents of /dev have odd permissions if you check with ls -l

Page 20: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Device Files are “Pseudofiles”

• When you read from or write to a device “file”, the operating system silently intercepts your request and feeds it to a driver

• The driver knows how to interact with the device• Drivers are typically written in C

– Can anyone tell me why that might be?

Page 21: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Device File Permissions

• If you took the liberty of running ls –l on the files, you might see something like this

• The “b” means that this is a “block” device• You could also see a “c”, which would mean it is a

“character” device• The size field has been replaced by a csv field where

– The first value represents the major device number– The second value represents the minor device number

Page 22: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Types of Devices

• Character Devices– Denoted by “c” character at start of permissions– Provide direct, unbuffered access to the hardware– Examples: Serial ports, keyboards, sound cards, modems

• Block Devices– Denoted by “b” character at start of permissions– Provide buffered access to the hardware– Always allowed to read/write any sized block– Buffered => We don’t know when the data will be written

• Pseudo Devices– Fake devices that are useful

Page 23: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Some Pseudo Devices

• /dev/null– Accepts all data written to it and does nothing– http://devnull-as-a-service.com/

• /dev/full– Always full; returns a continuous stream of NULL bytes when

read and returns “disk full” error when written to

• /dev/zero– Produces endless string of zero bits when read

• /dev/random and /dev/urandom– Contains a stream of random bytes

Page 24: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Hard Disk Partitions

• Each computer may have several hard drives attached, and each hard drive can be divided into several partitions– Windows assigns each partition its own drive letter (like C:)– Linux allows you to specify where the data on a given partition

should appear in the filesystem

• Every hard drive is assigned a name in /dev– Like /dev/sda for the first drive, or /dev/sdb for the second– Naming starts at sd followed by a letter

• The nth partition of the drive sdb is sdb(n)– So sdb3 is the third partition on the second hard disk

Page 25: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Mounting and Unmounting

• To use a partition, you can use the mount command– The usage is mount device location– For example, mount /dev/sda2 /media/windows

• The mounted filesystems and devices are tracked in /etc/mtab. You’ll probably need to be root to access it.

• umount unmounts a directory– Note the absence of the ‘n’ in umount

Page 26: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

fstab

• Non-changing filesystem information is written in /etc/fstab– According to the man page, “it is the duty of the system

administrator to properly create and maintain this file”– At boot, fstab tells the system which filesystems should be

loaded– Afterwards, fstab is used (by mount/umount) to describe how to

mount and unmount filesystems

• fstab entries contain the filesystem location, the mount point, the file system type, options, and information about core dumping and checking the filesystem

Page 27: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Outline

Amazingly Short Hardware Brief

A Little More About /dev

rm –rf /

Project Help

Page 29: CIS 191: Linux and Unix Class 9 April 1, 2015 Hardware, Project, and Devices

Outline

Amazingly Short Hardware Brief

A Little More About /dev

rm –rf /

Part Handout