xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 0.01M
    文件類型: .zip
    金幣: 2
    下載: 1 次
    發(fā)布日期: 2021-06-07
  • 語言: Python
  • 標簽: 其他??

資源簡介

Python串口操作.zip

資源截圖

代碼片段和文件信息

#!/usr/bin/python
#?coding=UTF-8

import?serial

###################################################
#
#?功?能:?將接收到的數(shù)據(jù)已hex顯示
#?參?數(shù):?串口接受到的數(shù)據(jù)
#?返?回:?轉(zhuǎn)換后的數(shù)據(jù)
#
###################################################

def?hexshow(data):
????hex_data?=?‘‘
????hLen?=?len(data)
????for?i?in?xrange(hLen):
????????hvol?=?ord(data[i])
????????hhex?=?‘%02x‘?%?hvol
????????hex_data?+=?hhex+‘?‘
????print?‘hexshow:‘?hex_data


###################################################
#
#?功?能:?將需要發(fā)送的字符串以hex形式發(fā)送
#?參?數(shù):?待發(fā)送的數(shù)據(jù)
#?返?回:?轉(zhuǎn)換后的數(shù)據(jù)
#
###################################################

def?hexsend(string_data=‘‘):
????hex_data?=?string_data.decode(“hex“)
????return?hex_data



if?__name__?==?‘__main__‘:
????serial?=?serial.Serial(‘/dev/ttyS0‘?115200)
????print?serial
????if?serial.isOpen():
???????print(“open?success“)
????else:
????????print(“open?failed“)


????try:
????????while?True:
????????????count?=?serial.inWaiting()
????????????if?count?>?0:
????????????????data?=?serial.read(count)
????????????????if?data?!=?b‘‘:
????????????????????print(“receive:“?data)
????????????????????serial.write(data)
????????????????else:
????????????????????serial.write(hexsend(data))
????except?KeyboardInterrupt:
????????if?serial?!=?None:
????????????serial.close()

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-07-20?01:06??Python串口操作\
?????目錄???????????0??2018-07-20?00:39??Python串口操作\usart\
?????目錄???????????0??2018-07-20?01:05??Python串口操作\usart\.idea\
?????目錄???????????0??2018-08-04?09:57??Python串口操作\usart\.idea\inspectionProfiles\
?????文件?????????205??2018-07-19?23:03??Python串口操作\usart\.idea\misc.xml
?????文件?????????262??2018-07-19?23:03??Python串口操作\usart\.idea\modules.xml
?????文件?????????459??2018-07-19?23:03??Python串口操作\usart\.idea\usart.iml
?????文件???????15999??2018-07-20?01:05??Python串口操作\usart\.idea\workspace.xml
?????文件????????1384??2018-07-20?00:39??Python串口操作\usart\uarttest.py

評論

共有 條評論