资源简介

http://blog.csdn.net/u012520966/article/details/50755669

资源截图

代码片段和文件信息

# -*- coding: utf-8 -*-
#this is the server
import socket
import RPi.GPIO as GPIO
import time

def ctrlpi(oppinhz):
    GPIO.setmode(GPIO.BOARD)
    GPIO.setwarnings(False)
    if(op == “ON“):
        GPIO.setup(pinGPIO.OUT)
        print(oppin)
        for i in range (02):
            GPIO.output(pinGPIO.LOW)
            time.sleep(1)
    elif(op == “OFF“):
        print(oppin)
        GPIO.setup(pinGPIO.OUT)
        GPIO.output(pinGPIO.LOW)
    elif(op == “HZ“):
        print(oppin)
        GPIO.setup(pinGPIO.OUT)
        for i in range (08):
            GPIO.output(pinGPIO.HIGH)
            time.sleep(0.05)
            GPIO.output(pinGPIO.LOW)
            time.sleep(0.05)
    GPIO.cleanup()
try:
    sock = socket.socket(socket.AF_INETsocket.SOCK_STREAM)
#    sock.setblocking(0)
    print(“create socket suc!“)
    
    sock.bind((‘192.168.1.123‘18076))
    print(‘bind socket suc!‘)

    sock.listen(5)
    print(‘listen socket suc!‘)  
    
    
except:
    print(“init socket err!“)

STOP_CHAT = False
while not STOP_CHAT:
    print(‘listren for command...‘)
    connaddr = sock.accept()
    print(‘get client:‘addr)
    
#    conn.settimeout(300)

    while True:
        try:
            data = conn.recv(512)
        except:
            conn.close()
            break;
        commond = data.decode(‘utf-8‘)
        print(commond)
        if not data:
            break
        u1u2u3 = commond.split()
        if (u1 == ‘exit‘):
            STOP_CHAT=True
            break;
        elif(u1 == ‘ON‘or u1 == ‘OFF‘ or u1 == “HZ“):
            conn.send(‘start commond!\r\n‘.encode(encoding=‘utf-8‘))
            ctrlpi(u1int(u2)u3)
        else:
            print(“unknow commond“)
        conn.send(‘commond done!\r\n‘.encode(encoding=‘utf-8‘))

conn.send(‘exit\r\n‘.encode(encoding=‘utf-8‘))
conn.close()
print(‘shutdown service‘)
exit()



 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-02-27 16:07  PI\
     文件         105  2016-02-26 17:19  PI\.gitignore
     目录           0  2016-02-27 16:07  PI\.gradle\
     目录           0  2016-02-27 16:07  PI\.gradle\2.10\
     目录           0  2016-02-27 16:07  PI\.gradle\2.10\taskArtifacts\
     文件          31  2016-02-26 17:20  PI\.gradle\2.10\taskArtifacts\cache.properties
     文件          17  2016-02-27 15:37  PI\.gradle\2.10\taskArtifacts\cache.properties.lock
     文件      144008  2016-02-27 15:37  PI\.gradle\2.10\taskArtifacts\fileHashes.bin
     文件     2543692  2016-02-27 15:37  PI\.gradle\2.10\taskArtifacts\fileSnapshots.bin
     文件       20162  2016-02-27 14:24  PI\.gradle\2.10\taskArtifacts\outputFileStates.bin
     文件      100155  2016-02-27 15:37  PI\.gradle\2.10\taskArtifacts\taskArtifacts.bin
     目录           0  2016-02-27 16:07  PI\.idea\
     文件           2  2016-02-26 17:19  PI\.idea\.name
     文件         686  2016-02-26 17:19  PI\.idea\compiler.xml
     目录           0  2016-02-27 16:07  PI\.idea\copyright\
     文件          76  2016-02-26 17:19  PI\.idea\copyright\profiles_settings.xml
     文件         159  2016-02-26 17:19  PI\.idea\encodings.xml
     文件         811  2016-02-26 17:20  PI\.idea\gradle.xml
     目录           0  2016-02-27 16:07  PI\.idea\libraries\
     文件         769  2016-02-27 10:22  PI\.idea\libraries\appcompat_v7_23_1_1.xml
     文件         733  2016-02-27 10:22  PI\.idea\libraries\design_23_1_1.xml
     文件         526  2016-02-26 17:20  PI\.idea\libraries\hamcrest_core_1_3.xml
     文件         477  2016-02-26 17:20  PI\.idea\libraries\junit_4_12.xml
     文件         787  2016-02-27 10:22  PI\.idea\libraries\recyclerview_v7_23_1_1.xml
     文件         511  2016-02-26 17:20  PI\.idea\libraries\support_annotations_23_1_1.xml
     文件         911  2016-02-27 10:22  PI\.idea\libraries\support_v4_23_1_1.xml
     文件        2226  2016-02-26 17:21  PI\.idea\misc.xml
     文件         341  2016-02-26 17:20  PI\.idea\modules.xml
     文件         564  2016-02-26 17:20  PI\.idea\runConfigurations.xml
     文件      158897  2016-02-27 16:01  PI\.idea\workspace.xml
     文件         933  2016-02-26 17:20  PI\PI.iml
............此处省略1911个文件信息

评论

共有 条评论