M♪o 之學習筆記本《寅》井井︰【紅火夏】刈麥遺穗

派生碼訊

寅 虎

觀刈麥》白居易

田家少閒月,五月人倍忙。
夜來南風起,小麥覆隴黃。
婦姑荷簞食,童稚攜壺槳。
相隨餉田去,丁壯在南岡。
足蒸暑土氣,背灼炎天光。
力盡不知熱,但惜夏日長。
復有貧婦人,抱子在其旁。
右手秉遺穗,左臂懸敝筐。
聽其相顧言,聞者為悲傷。
家田輸稅盡,拾此充饑腸。
今我何功德?曾不事農桑。
吏祿三百石,歲晏有餘糧。
念此私自愧,盡日不能忘。

紅火夏︰雖然俗話說︰禮尚往來。奈何人間憾事,刈麥遺穗現眼前。莫道夏日炎炎正好眠,還祈盡但惜熱暑時。

 

派︰《 畫 》畫傳︰昔有『米勒』者繪作『拾穗』圖,──

拾穗一詞淵源於舊約聖經路得記-路得與波阿斯的記載,路得在波阿斯田裏撿麥穗,以供養她的婆婆拿俄米,指農民需讓貧苦人撿拾收割後遺留穗粒以求溫飽,而該畫除了描繪3名農婦在金黃色麥田撿拾麥穗情景外,其金黃陽光、彎腰等細節,另外呈現「英雄史詩般的崇高意境」。 畫面上三位年紀不同的女性,表現出勞動家庭的命運 ,且畫面遠處可看到農地監督者坐於馬背上觀看,反映出當時資本主義產生的貧富差距。 畫面因遠方地平線處的教堂而流露出一股近似宗教情操的崇高性。──

Jean-François_Millet_-_Gleaners_-_Google_Art_Project_2

,觀之令人紅眼框。無巧不成書,無事難商量,想那《水滸傳》,真真是,官逼民反作強梁。

雖聞物已至,何故改課鋼,應應昨日事,補過先思量。一時講起了《通訊口》!殊不知早是議論紛紛!!

今天小企鵝學堂上,沸沸揚揚,這時那些小企鵝們正熱鬧的議論著昨天被『駭黑』之事的哩!!

有的主張︰怎麽可能被駭黑了呢 ?一定是誤傳。

有的辯證︰一山還比一山高,這回學長們,可好笑了!

有的議論︰駭客分成素客、灰客 、黑客,你怎知他是哪種?

有的搞笑︰『始』嗨ㄏㄞˋ,『終』嘿ㄏㄟ!不過是一音之轉嘛??

那你可有說法?

哦!我唱給你聽︰ㄍㄨㄥ道駭客我真莫宰羊,……

要是講起盜版,我蓋清楚,實在ㄍㄨㄥˋ

‧ㄍㄢˇ款ㄟ

‧ㄌㄨㄥ有目的

‧Maybe 盜亦有道

駭了□?黑了○的呦!!

一定ㄇㄞˋ甲伊喝一杯咖啡??

BabyTux

graphics-tux-638974

sonictux

starbucks_tux_linux_art-555px

長 長︰同學們請安靜。據聞實習的材料已到,課表將略作調整 ,學長告知此事與駭黑之事無涉!請大家按新表操課。

 

☆ 編者言說明

當真應了 M♪o 的『巧』字,恰巧『樹莓派 SAKS 擴展板』上也有『序列埠』,更巧它還有『教程』,此時 M♪o 正巧寫及《通訊口》 ,果然巧遇巧成七巧的耶!!讀她那一句『學長告知……無涉』,真真是此地無銀三百兩,妙哉!妙哉!按新表操課!!

 

生 ︰《 技 》技引入門之徑︰

假使從 RS-232Null ModemUARTSerial PortSystem Console 之發展與變遷的歷史來看,可以知道許多典型『應用』和週邊『裝置』興替的過程,即使在今天也都還非常『有用』。兩台電腦間簡單的『 null modem 』虛數據機連線,可以構成很好的『軟體學習』環境。事實上只有一個

樹莓派』也可以玩些不一樣的事情。由於我們將談談『序列埠』在『軟體學習』上的一些想法, 在此並不介紹基本的 Serial Port 之點點滴滴,特於此篇列出一些參考鏈結︰

Raspberry Pi Serial Port

RPi Serial Connection

What is AMA in /dev/ttyAMA0

Lesson 5. Using a Console Cable ── Adafruit’s Raspberry Pi

How To: Use Minicom on Linux for Serial Port Comunication

希望讀者能夠自行閱讀。

 

☆ 編者言說明

由於《 Physical computing ︰《四》 Serial Port ︰ 1. 開宗明義》文中之

How To: Use Minicom on Linux for Serial Port Comunication 鏈結已僵,校而改之為

11.7 Using minicom and seyon

,故此記。

 

△ 《 文 》文講程式庫使用之法︰

pySerial

Overview

This module encapsulates the access for the serial port. It provides backends for Python running on Windows, Linux, BSD (possibly any POSIX compliant system), Jython and IronPython (.NET and Mono). The module named “serial” automatically selects the appropriate backend.

It is released under a free software license, see LICENSE for more details.

Copyright (C) 2001-2013 Chris Liechti <cliechti(at)gmx.net>

Other pages (online)

 

△  TTL serial 是什麼哩,還請參造︰

RS-232 vs. TTL Serial Communication


One of the tools we use most when debugging our projects is serial input/output. Serial is very easy to implement, and it allows you to send/receive any data you need from your microcontroller to a computer’s serial port so it can be viewed using a terminal emulator. These two devices are compatible from a software perspective, however you can’t just hook a microcontroller up to a computer because the hardware interfaces are not compatible.

Most microcontrollers these days have built in UARTs (universally asynchronous receiver/transmitter) that can be used to receive and transmit data serially. UARTs transmit one bit at a time at a specified data rate (i.e. 9600bps, 115200bps, etc.). This method of serial communication is sometimes referred to as TTL serial (transistor-transistor logic). Serial communication at a TTL level will always remain between the limits of 0V and Vcc, which is often 5V or 3.3V. A logic high (‘1’) is represented by Vcc, while a logic low (‘0’) is 0V.

The serial port on your computer (if it’s lucky enough to have one, they’re quickly becoming a relic) complies with the RS-232 (Recommended Standard 232) telecommunications standard. RS-232 signals are similar to your microcontroller’s serial signals in that they transmit one bit at a time, at a specific baud rate, with or without parity and/or stop bits. The two differ solely at a hardware level. By the RS-232 standard a logic high (‘1’) is represented by a negative voltage – anywhere from -3 to -25V – while a logic low (‘0’) transmits a positive voltage that can be anywhere from +3 to +25V. On most PCs these signals swing from -13 to +13V.

The more extreme voltages of an RS-232 signal help to make it less susceptible to noise, interference, and degradation. This means that an RS-232 signal can generally travel longer physical distances than their TTL counterparts, while still providing a reliable data transmission.

 

This timing diagram shows both a TTL (bottom) and RS-232 signal sending 0b01010101

 

碼 ︰讀 習 。讀碼練習。

#!/usr/bin/env python

# Very simple serial terminal
# (C)2002-2004 Chris Liechti <cliecht@gmx.net>

# Input characters are sent directly (only LF -> CR/LF/CRLF translation is
# done), received characters are displayed as is (or as trough pythons
# repr, useful for debug purposes)
# Baudrate and echo configuartion is done through globals


import sys, os, serial, threading, getopt

EXITCHARCTER = '\x04'   #ctrl+D

#first choose a platform dependant way to read single characters from the console
if os.name == 'nt':
    import msvcrt
    def getkey():
        while 1:
            if echo:
                z = msvcrt.getche()
            else:
                z = msvcrt.getch()
            if z == '\0' or z == '\xe0':    #functions keys
                msvcrt.getch()
            else:
                if z == '\r':
                    return '\n'
                return z

elif os.name == 'posix':
    import termios, sys, os
    fd = sys.stdin.fileno()
    old = termios.tcgetattr(fd)
    new = termios.tcgetattr(fd)
    new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
    new[6][termios.VMIN] = 1
    new[6][termios.VTIME] = 0
    termios.tcsetattr(fd, termios.TCSANOW, new)
    s = ''    # We'll save the characters typed and add them to the pool.
    def getkey():
        c = os.read(fd, 1)
        #~ c = sys.stdin.read(1)
        if echo: sys.stdout.write(c); sys.stdout.flush()
        return c
    def clenaup_console():
        termios.tcsetattr(fd, termios.TCSAFLUSH, old)
    sys.exitfunc = clenaup_console      #terminal modes have to be restored on exit...

else:
    raise "Sorry no implementation for your platform (%s) available." % sys.platform

CONVERT_CRLF = 2
CONVERT_CR   = 1
CONVERT_LF   = 0

def reader():
    """loop forever and copy serial->console"""
    while 1:
        data = s.read()
        if repr_mode:
            sys.stdout.write(repr(data)[1:-1])
        else:
            sys.stdout.write(data)
        sys.stdout.flush()

def writer():
    """loop and copy console->serial until EOF character is found"""
    while 1:
        c = getkey()
        if c == EXITCHARCTER: 
            break                       #exit app
        elif c == '\n':
            if convert_outgoing == CONVERT_CRLF:
                s.write('\r\n')         #make it a CR+LF
            elif convert_outgoing == CONVERT_CR:
                s.write('\r')           #make it a CR
            elif convert_outgoing == CONVERT_LF:
                s.write('\n')           #make it a LF
        else:
            s.write(c)                  #send character


#print a short help message
def usage():
    sys.stderr.write("""USAGE: %s [options]
    Miniterm - A simple terminal program for the serial port.

    options:
    -p, --port=PORT: port, a number, default = 0 or a device name
    -b, --baud=BAUD: baudrate, default 9600
    -r, --rtscts:    enable RTS/CTS flow control (default off)
    -x, --xonxoff:   enable software flow control (default off)
    -e, --echo:      enable local echo (default off)
    -c, --cr:        do not send CR+LF, send CR only
    -n, --newline:   do not send CR+LF, send LF only
    -D, --debug:     debug received data (escape nonprintable chars)

""" % (sys.argv[0], ))

if __name__ == '__main__':
    #initialize with defaults
    port  = 0
    baudrate = 9600
    echo = 0
    convert_outgoing = CONVERT_CRLF
    rtscts = 0
    xonxoff = 0
    repr_mode = 0
    
    #parse command line options
    try:
        opts, args = getopt.getopt(sys.argv[1:],
            "hp:b:rxecnD",
            ["help", "port=", "baud=", "rtscts", "xonxoff", "echo",
            "cr", "newline", "debug"]
        )
    except getopt.GetoptError:
        # print help information and exit:
        usage()
        sys.exit(2)
    
    for o, a in opts:
        if o in ("-h", "--help"):       #help text
            usage()
            sys.exit()
        elif o in ("-p", "--port"):     #specified port
            try:
                port = int(a)
            except ValueError:
                port = a
        elif o in ("-b", "--baud"):     #specified baudrate
            try:
                baudrate = int(a)
            except ValueError:
                raise ValueError, "Baudrate must be a integer number, not %r" % a
        elif o in ("-r", "--rtscts"):
            rtscts = 1
        elif o in ("-x", "--xonxoff"):
            xonxoff = 1
        elif o in ("-e", "--echo"):
            echo = 1
        elif o in ("-c", "--cr"):
            convert_outgoing = CONVERT_CR
        elif o in ("-n", "--newline"):
            convert_outgoing = CONVERT_LF
        elif o in ("-D", "--debug"):
            repr_mode = 1

    #open the port
    try:
        s = serial.Serial(port, baudrate, rtscts=rtscts, xonxoff=xonxoff)
    except:
        sys.stderr.write("Could not open port\n")
        sys.exit(1)
    sys.stderr.write("--- Miniterm --- type Ctrl-D to quit\n")
    #start serial->console thread
    r = threading.Thread(target=reader)
    r.setDaemon(1)
    r.start()
    #and enter console->serial loop
    writer()

    sys.stderr.write("\n--- exit ---\n")

 

行 ︰就這樣一股腦兒的胡倒,不知是教學,還是學教。☿☹只聽過背書,難不成背碼的耶!☿☹☹ 又沒給安裝之法,不知是要怎麼練哪樣習?咦!東西還沒見到,該裝…… ☿☺☿

 

訊 ︰ ☿ 子曰:『學而不思則罔,. 思而不學則殆』