本文整理汇总了Python中serial_manager.SerialManager.write方法的典型用法代码示例。如果您正苦于以下问题:Python SerialManager.write方法的具体用法?Python SerialManager.write怎么用?Python SerialManager.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类serial_manager.SerialManager
的用法示例。
在下文中一共展示了SerialManager.write方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: checkErr
# 需要导入模块: from serial_manager import SerialManager [as 别名]
# 或者: from serial_manager.SerialManager import write [as 别名]
def checkErr(* flag):
for index in range(len(flag)):
if flag[index] != 0:
SerialManager.read_existing() #clear rx_buffer
if SerialManager.write('O000'+'\r'):
relayStatus=SerialManager.read_to('\r')
print 'relay status is:',relayStatus
示例2: sendCommand
# 需要导入模块: from serial_manager import SerialManager [as 别名]
# 或者: from serial_manager.SerialManager import write [as 别名]
def sendCommand(command):
#clear rx_buffer
SerialManager.read_existing()
if SerialManager.write(command + '\r'):
return SerialManager.read_to('\r')
else:
return 'error'
示例3: stopBalancing
# 需要导入模块: from serial_manager import SerialManager [as 别名]
# 或者: from serial_manager.SerialManager import write [as 别名]
def stopBalancing(stackNum,cellNum):
balanceCommand='S'+str(stackNum)+str(cellNum)
SerialManager.read_existing() #clear rx_buffer
if SerialManager.write( balanceCommand +'\r'):
balanceStopTime=SerialManager.read_to('\r')
print 'balance stop time is:',balanceStopTime
示例4: commandGenerator
# 需要导入模块: from serial_manager import SerialManager [as 别名]
# 或者: from serial_manager.SerialManager import write [as 别名]
balanceStopTime=SerialManager.read_to('\r')
print 'balance stop time is:',balanceStopTime
if __name__ == '__main__':
#if not SERIAL_PORT:
# SERIAL_PORT = SerialManager.match_device(GUESS_PREFIX, BITSPERSECOND)
commandGenerator();
flag=[]
voltage=[]
temperature=[]
relayStatus=0
SerialManager.connect(SERIAL_PORT, BITSPERSECOND)
#while SerialManager.is_connected():
SerialManager.read_existing() #clear rx_buffer
if SerialManager.write('C000'+'\r'):
relayStatus=SerialManager.read_to('\r')
print 'relay status is:',relayStatus
SerialManager.read_existing() #clear rx_buffer
if SerialManager.write('R000'+'\r'):
totalVoltage=SerialManager.read_to('\r')
print 'total voltage is:',totalVoltage
SerialManager.read_existing() #clear rx_buffer
if SerialManager.write('I000'+'\r'):
totalCurrent=SerialManager.read_to('\r')
print 'total current is:', totalCurrent
SerialManager.read_existing() #clear rx_buffer
if SerialManager.write('F800'+'\r'):
示例5: serialProcessor
# 需要导入模块: from serial_manager import SerialManager [as 别名]
# 或者: from serial_manager.SerialManager import write [as 别名]
def serialProcessor():
global quitFlag
RelayStatus=0
'''
process serial command and send response.
'V' // UART-command for receiving
'T' //UART-command for read temperature
'F' //UART-command for read flag
'R' //UART-command for read total voltage
'I' //UART-command for read total current
'C' //UART-command for close the relay
'O' //UART-command for open the relay
'P' //UART-command for receiving the PWM rate
'J' //UART-command for read time
'K' //UART-command for kill the simulation
'''
while True:
try:
chars = SerialManager.read_to('\r')
if len(chars) > 0:
print('Processing Command:' + chars)
stackNum = int(chars[1])
cellNum = int(chars[2:4])
#cellNum=int(chars[2])*10 + int(chars[3])
index = stackNum*tm.NumberOfCells+cellNum
#print "stackNum %d, cellNum %d, index %d" %(stackNum,cellNum,index)
if chars[0] == 'V':
SerialManager.write(str(tm.status['voltageList'][index])+ '\r')
elif chars[0] == 'B':
tm.bg[index].balanceRate = 1.0 * int(chars[4:])/100.0
#print 'balcenRate is:', tm.bg[index].balanceRate
elif chars[0] == 'T':
SerialManager.write(str(0)+ '\r')
elif chars[0] == 'R':
totalVoltage=sum(tm.status['voltageList'][:])
SerialManager.write(str(totalVoltage)+ '\r')
elif chars[0] == 'I':
totalCurrent=sum(tm.status['voltageList'][:])/tm.load
SerialManager.write(str(totalCurrent)+ '\r')
elif chars[0] == 'C':
RelayStatus=1
SerialManager.write(str(RelayStatus)+ '\r')
elif chars[0] == 'O':
RelayStatus=0
SerialManager.write(str(RelayStatus)+ '\r')
elif chars[0] == 'J':
SerialManager.write(str(tm.clock)+ '\r')
elif chars[0] == 'K':
quitFlag = True
else:
print 'Command Not Defined'
SerialManager.write('Command Not Defined'+ '\r')
time.sleep(0.08)
except:
print("error when processing command")
time.sleep(0.1)
示例6: PololuController
# 需要导入模块: from serial_manager import SerialManager [as 别名]
# 或者: from serial_manager.SerialManager import write [as 别名]
print 'Setting up Pololu 1'
e_elev = PololuController(manager2, 2)
print 'Setting up Pololu 2'
e_elev.move_to(0)
time.sleep(1)
last_voltages = []
hold_counter = 0
s2_array = [2.5, 0.8, 2.5, 4]
s5_array = [2.0, 1, 2.0, 3]
e_rot_array = [0, 30, 0, -30]
e_elev_array = [0, 20, 0, -20]
while(alive):
manager1.write("@MARM?")
if marm.pack_into_received(manager1.serial_io.read(17)):
if not controlled(last_voltages, marm.voltages):
hold_counter += 1
else:
hold_counter = 0
if hold_counter < 50:
s5_angle = (marm.voltages[5] - 2550) / 900.0 + 2
s2_angle = (2350 - marm.voltages[6]) / 300.0 + 2.5
e_rot_angle = (marm.voltages[4] - 2600) / 20
e_elev_angle = (marm.voltages[1] - 2400) / 25
'''else:
if hold_counter >= 250: hold_counter = 50
print 'Starting auto routine'
arr_i = (hold_counter / 50) % 4
print arr_i