def main():
try:
init() # Grid Eye 初期化
while True:
try:
temp = read_block(0x0e, 2) # サーミスタ温度(0x0e から 2バイト)
s_temp = calc_temp1(temp)[0] # サーミスタ温度計算
data0 = 'Thermistor:{0}'.format(s_temp) # サーミスタ温度(℃)
time.sleep(0.5)
temp0 = read_block(0x80) # 0x80 から 32バイト読込
temp1 = read_block(0xa0) # 0xa0 から 32バイト読込
temp2 = read_block(0xc0) # 0xc0 から 32バイト読込
temp3 = read_block(0xe0) # 0xe0 から 32バイト読込
temp = temp3 + temp2 + temp1 + temp0 # 受信データリスト連結
d0 = calc_temp2(temp0) # 温度計算
d1 = calc_temp2(temp1)
d2 = calc_temp2(temp2)
d3 = calc_temp2(temp3)
data1 = d3 + d2 + d1 + d0 # 温度レジスタ(℃)
wData = '{0}\n{1}'.format(data0, data1)
list01 = data1.split(",+")
del list01[63]
del list01[0]
list02 = list(map(float,list01))
time.sleep(0.1)
temp = read_block(0x0e, 2) # サーミスタ温度(0x0e から 2バイト) s_temp = calc_temp1(temp)[0] # サーミスタ温度計算 data0 = 'Thermistor:{0}'.format(s_temp) # サーミスタ温度(℃) time.sleep(0.5) temp0 = read_block(0x80) # 0x80 から 32バイト読込 temp1 = read_block(0xa0) # 0xa0 から 32バイト読込 temp2 = read_block(0xc0) # 0xc0 から 32バイト読込 temp3 = read_block(0xe0) # 0xe0 から 32バイト読込 temp = temp3 + temp2 + temp1 + temp0 # 受信データリスト連結 d0 = calc_temp2(temp0) # 温度計算 d1 = calc_temp2(temp1) d2 = calc_temp2(temp2) d3 = calc_temp2(temp3) data1 = d3 + d2 + d1 + d0 # 温度レジスタ(℃) wData = '{0}\n{1}'.format(data0, data1) list03 = data1.split(",+") del list03[63] del list03[0] list04 = list(map(float,list03)) print(list02) print(list04) i = 0 sabun = list() for i in range(len(list04)): if list02[i] > list04[i]: sabun[i] = list02[i] - list04[i] i += 1 elif list02[i] <= list04[i]: sabun[i] = list04[i] - list02[i] i += 1 print(sabun) goukei = sum(sabun) print(goukei) time.sleep(0.1) except Exception as e: print('main:{0}'.format(e)) time.sleep(5) except Exception as e: print('main:{0}'.format(e))
==============================================
if name=='main':
main()
これを実行するとmain:list assignment index out of rangeというエラーが出ます
解決方法を教えてください
回答3件
あなたの回答
tips
プレビュー