Rocking Rasperry Pi

##Keep in mind

  • Use sudo nmap -sP -T4 to detect connected devices.
  • Then use sudo nmap -v -A -T4 get all opened port and services on this machine.
  • Start a vnc server on raspi. vncserver :1 -geometry 1200x700 -depth 24
  • apt update use goagent proxy. sudo apt-get -o Acquire::http::proxy="" update
  • Statistic folder size: du -h --max-depth=1

##View the video over mplayer
Install mplayer: sudo apt-get install mplayer

Rasperry Pi: raspivid -t 999999 -o | omxplayer

##Stream video over a network (Official Doc)
Install related tool (both client & raspi): sudo apt-get install mplayer netcat

Some Linux : nc -l -p 5001 | mplayer -fps 31 -cache 1024 -
(Record on the other side: nc -l -p 5001 | ffmpeg -r 31 -i - out.avi)

Rasperry Pi: raspivid -t 999999 -o - | nc 5001

##Camera Error

$ raspistill -o haha.jpg
mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
mmal: camera component couldn't be enabled
mmal: main: Failed to create camera component
mmal: Failed to run camera app. Please check for firmware updates

Fixed by: Kernels >= 3.10: w1_gpio destroys i2c bus 0, raspicam doesn’t work anymore

##Connect to Wifi

  1. ifconfig: Enable your wireless device.
  2. iwlist: List the available wireless access points.
  3. iwconfig: Configure your wireless connection.
  4. dhclient: Get your IP address via dhcp.
  5. /etc/network/if-up.d/upstart
iwlist wlan0 scan
sudo iwconfig wlan0 essid rk_mint key s:password123
sudo dhclient wlan0

##Load Camera to /dev/video0 HELP

uv4l --driver raspicam --auto-video_nr

##Motion detect HELP

LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/ motion -c ./motion.conf

Python Learning on

###Knowledge Points


creates lists from iterables.

####else Clauses on Loops (python doc equals if no break else do)

When used with a loop, the else clause has more in common with the else clause of a try statement than it does that of if statements: a try statement’s else clause runs when no exception occurs, and a loop’s else clause runs when no break occurs.

for n in range(2, 10):
  for x in range(2, n):
    if n % x == 0:
      print(n, '=', x, '*', n // x)
    print(n, '是素数')

####varible scope (view in python doc)

The execution of a function introduces a new symbol table used for the local variables of the function. More precisely, all variable assignments in a function store the value in the local symbol table; whereas variable references first look in the local symbol table, then in the local symbol tables of enclosing functions, then in the global symbol table, and finally in the table of built-in names. Thus, global variables cannot be directly assigned a value within a function (unless named in a global statement), although they may be referenced.

####default values in function definition (Default Argument Values)

The default values are evaluated(and evaluated only once) at the point of function definition in the defining scope, so that

i = 5

def f(arg=i):

i = 6

will print 5.