本文整理汇总了Python中serial.flush函数的典型用法代码示例。如果您正苦于以下问题:Python flush函数的具体用法?Python flush怎么用?Python flush使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了flush函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: summary
def summary():
trace("SUMMARY:",log_trace)
trace("Errors : " + str(s_error),log_trace)
if s_error==0:
trace("Result : No errors occurred.",log_trace)
else:
trace("Self Test FAILED",log_trace)
if online==1:
print "Saving results on remote server"
url = 'http://plm.fabtotum.com/reports/add_report.php'
files = {'file': open(log_trace, 'rb')}
info={'ID':controller_serial_id, 'result':s_error}
try:
r = requests.post(url,info, files=files)
trace("Self Test results saved online",log_trace)
except:
#print "Response: " + r.text
trace("Could not contact remote support server, is Internet connectivity available?",log_trace)
if s_error>0:
#clean the buffer and leave
#shutdown temps
serial.write("M104 S0\r\n") #shutdown extruder (fast)
serial.write("M140 S0\r\n") #shudown bed (fast)
serial.flush()
serial.close()
write_json('1', status_json)
call (['sudo php /var/www/fabui/script/finalize.php '+str(task_id)+" self_test"], shell=True)
sys.exit()
开发者ID:Fensterbank,项目名称:FAB-UI,代码行数:33,代码来源:self_test.py
示例2: write_packet
def write_packet(i, val):
i = int(i)
val = int(val)
msb = (int(val) & 0xFF00) >> 8
lsb = int(val) & 0xFF
p = bytearray([i, msb, lsb])
serial.write(p)
serial.flush()
开发者ID:RutgersFormulaRacing,项目名称:LCDController,代码行数:10,代码来源:DAQsim.py
示例3: write_packet
def write_packet(i, val):
i = int(i)
val = int(val)
print ("SENDING {} {}".format(i, val))
msb = (int(val) & 0xFF00) >> 8
lsb = int(val) & 0xFF
p = bytearray([i, msb, lsb])
serial.write(p)
serial.flush()
开发者ID:RutgersFormulaRacing,项目名称:LCDController,代码行数:11,代码来源:DAQsim-physical-tty.py
示例4: initSerial
def initSerial(port, baudrate):
serial.port = port
serial.baudrate = baudrate
serial.timeout = 1
serial.writeTimeout = 1
serial.open()
serial.flush()
logd( 'Opening port %s - %s' %(port, baudrate) )
if serial.isOpen():
logd('Success')
else:
logd('Failed')
exit(2)
开发者ID:007Marcos,项目名称:ramanSpectrometer,代码行数:14,代码来源:controlBoard_test_02.py
示例5: put
def put(self, address, type, value):
with self.__lock:
result = None
while result is None:
serial = self.serial()
try:
serial.write([address, 0, type, int(value)])
serial.flush()
result = True
except Exception as e:
print e
self.__clean()
开发者ID:champo,项目名称:embebidos-2014C1,代码行数:17,代码来源:serial_interface.py
示例6: get
def get(self, address, type):
with self.__lock:
result = None
while result is None:
serial = self.serial()
try:
print type
serial.write([address, 1, type])
serial.flush()
result = struct.unpack('B', serial.read(1))[0]
except Exception as e:
print e
self.__clean()
return result
开发者ID:champo,项目名称:embebidos-2014C1,代码行数:18,代码来源:serial_interface.py
示例7: tagRead
def tagRead():
import serial
try:
serial= serial.Serial("/dev/ttyACM0", baudrate=9600)
n=0
serial.flushInput()
serial.flushOutput()
while True:
data=serial.readline()
n=n+1
if data[0:3]=="ISO" and n>3:
myString1=data.find('[')+1
myString2=data.find(',')
serial.flush()
serial.close()
return data[myString1:myString2]
except Exception as e:
return 0
开发者ID:rener2,项目名称:BuildIT,代码行数:18,代码来源:Simple_reader.py
示例8: getDistanceArray
def getDistanceArray():
# flush the buffer
serial.flush()
# This constant will request the values for all of the sensors
sensorValsArray = []
# Write that value to the Arduinos serial monitor
amountOfSensors = 5
# set inital value of i to the first sensor
i = 1
# set inital value of sensor val to 1 so the while loop is entered
sensorVal = 1
# while loop that asks for sensor values sequentially, converts them to an integer and adds them to an array
while(sensorVal > -1):
# ask for the sensor value from the arduino
serial.write(str.encode(str(i)))
# read the sensor value, conert it to an integer and store it in the temp variable
sensorVal = int(serial.readline())
# if the sensor was actually there store the value in the array
if(sensorVal > -1):
sensorValsArray.append(sensorVal)
# delay
time.sleep(0.01)
# increment i to check for next sensor
i += 1
return sensorValsArray
开发者ID:kfujii12,项目名称:PulsedLight,代码行数:39,代码来源:tkInter.py
示例9: writeToTape
def writeToTape(serial, array, maxvalue):
print("Writing")
print(array)
data = ""
if array[0] > 1e1:
for x in array:
towrite = [0, 0, 0] #rgb
towrite[0] = x
towrite[1] = 60
towrite[2] = 254 - x
for x in towrite:
capped = int(min(254,max(0,x)))
data += chr(capped)
else:
# cleartape(serial)
return
# write control
serial.write(data)
serial.write(CONTROL)
serial.flushInput()
serial.flush()
开发者ID:Narfinger,项目名称:blinkysound,代码行数:23,代码来源:visual.py
示例10: microcontroller
udp_socket = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
udp_socket.bind(udp_server_address)
if BROADCAST_MODE:
udp_socket.setsockopt(socket.SOL_SOCKET,socket.SO_BROADCAST,1)
slip_processor=slip.slip()
while True:
(rlist, wlist, xlist) = select.select([udp_socket,serial], [], [])
if serial in rlist:
serial_data = serial.read(1)
slip_processor.append(serial_data)
slip_packets=slip_processor.decode()
for packet in slip_packets:
if BROADCAST_MODE:
udp_socket.sendto(packet,udp_broadcast)
else:
udp_socket.sendto(packet,udp_client_address)
if udp_socket in rlist:
udp_data,udp_client = udp_socket.recvfrom(MAX_UDP_PACKET)
slip_data=slip_processor.encode(udp_data)
serial.write(slip_data)
serial.flush()
udp_client_address=(udp_client[0],UDP_PORT_OUT)
time.sleep(0.001) #avoid flooding the microcontroller (to be controlled)
开发者ID:avilleret,项目名称:udp2serial,代码行数:26,代码来源:udp2serial.py
示例11: snd_bytearray_uart
def snd_bytearray_uart(msg):
global serial
byte = serial.write(msg)
serial.flush()
return byte
开发者ID:lcdsdream,项目名称:pySerial,代码行数:5,代码来源:plotSerial.py
注:本文中的serial.flush函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论