2016년 11월 18일 금요일

Install Pygame for Windows


Download pygame
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame

Step 2: Install Pygame for Windows


pygame-1.9.2b1-cp35-cp35m-win32.whl
C:\Users\name\> cd Downloads
C:\Users\name\Downloads> pip install pygame-1.9.2b1-cp35-cp35m-win32.whl



원본 http://kidscancode.org/blog/2015/09/pygame_install/




2016년 11월 9일 수요일

MFRC522-python

Dump RFID Tag data using mxgxw/MFRC522-python

pi@raspberrypi ~ $ mkdir mxgxw
pi@raspberrypi ~ $ cd mxgxw
pi@raspberrypi ~/ mxgxw $ git clone https://github.com/mxgxw/MFRC522-python
pi@raspberrypi ~/ mxgxw $ cd MFRC522-python
pi@raspberrypi ~/ mxgxw/MFRC522-python $  sudo python Read.py    <-- then read rfrc522
pi@raspberrypi ~/ mxgxw/MFRC522-python $  sudo python Dump.py    <-- read & dump

Pins

You can use this image for reference.
NamePin #Pin name
SDA24GPIO8
SCK23GPIO11
MOSI19GPIO10
MISO21GPIO9
IRQNoneNone
GNDAnyAny Ground
RST22GPIO25
3.3V13V3

Enable SPI using Raspberry Pi Configuration

pi@raspberrypi ~ $ ls /dev/spidev0.*
ls:cannot access bla~
pi@raspberrypi ~ $ ls /etc/modprobe.d/raspi-blacklist.conf



























Install python-dev and SPI-Py

pi@raspberrypi ~ $ sudo apt-get install python-dev
pi@raspberrypi ~ $ git clone https://github.com/lthiery/SPI-Py
pi@raspberrypi ~ $ cd SPI-Py
pi@raspberrypi ~ /SPI-Py $ sudo python setup.py install


download MFRC522-python

pi@raspberrypi ~ $ git clone https://github.com/rasplay/MFRC522-python.git
pi@raspberrypi ~ $ cd MFRC522-python
pi@raspberrypi ~ /MFRC522-python $


Enable device tree

pi@raspberrypi ~ $ ls /boot/config.txt
pi@raspberrypi ~ $ sudo nano /boot/config.txt
device_tree=on <--append

Install latest version of bcm2835

The version of the package that this documentation refers to can be downloaded from http://www.airspayce.com/mikem/bcm2835/bcm2835-1.50.tar.gz
--http://www.airspayce.com/mikem/bcm2835/

pi@raspberrypi ~ $ mv ~/Downloads/bcm2835-1.50.tar.gz ~
pi@raspberrypi ~ $ tar zxvf bcm2835-1.50.tar.gz
pi@raspberrypi ~ $ cd bcm2835-1.50
pi@raspberrypi ~ bcm2835-1.50 $
pi@raspberrypi ~ bcm2835-1.50 $ ./configure
pi@raspberrypi ~ bcm2835-1.50 $ make
pi@raspberrypi ~ bcm2835-1.50 $ sudo make check
pi@raspberrypi ~ bcm2835-1.50 $ sudo make install
pi@raspberrypi ~ bcm2835-1.50 $ sudo reboot


read RFID tags using RFID Reader, RFID-RC522.

pi@raspberrypi ~ $ cd MFRC522-python
pi@raspberrypi ~ /MFRC522-python $ sudo python read.py

Dump RFID Tag data one-by-one

pi@raspberrypi ~ $ cd /mxgxw/MFRC522-python
pi@raspberrypi ~ /mxgxw/MFRC522-python $ sudo python pyDump1.py


출처 https://www.youtube.com/channel/UCUC46OBgd9H1gmQIpNp4_uw

2016년 11월 5일 토요일

python namedtuple - array

파이썬 배열을 이렇게도 사용합니다.....

namedtuple 을 사용하면 class보다 간편하게 사용가능합니다.
TUPLE 말뜻대로 배열에 이름표를 붙여서 사용하는데
c의 structure 같다는 느낌입니다.

 
from collections import namedtuple


class Fruit(object):    def __init__(self, name, colour, shape):        self.name = name        self.colour = colour        self.shape = shape
variables1 = {}
variables2 = {}
Fruitlist = [
            ['Apple', 'red', 'circle'],
            ['Banana', 'yellow', 'abnormal'],
            ['Pear', 'green', 'abnormal']
           ]
Fruits = namedtuple(
  "Fruit", 
  ["name", "colour", "shape"]
  )


Fruitlist.append(["","노랑","동그라미"])

for args in Fruitlist:    fruit1 = Fruit(*args)
    fruit2 = Fruits(*args)
    variables1[fruit1.name] = fruit1
    variables2[fruit2.name] = fruit2

print("Apple shape: " + variables1[""].shape)
print("Apple shape: " + variables2[""].shape)

http://stackoverflow.com/questions/11118486/python-list-as-variable-name




vsftpd FTP 서버 접속은 성공하였으나, "디렉토리 목록 조회 실패" 현상 발생시

FTP Passive 모드를 활성화 필요. 1. vsftpd 설정 변경 /etc/vsftpd/vsftpd.conf 상에 아래 내용 추가 기입 #passive modpasv_enable=YES pasv_min_port=5001 pasv...