lined from 'blobmsg_new' at /home/ebyte/TX2063/openwrt/build_dir/hostpkg/libubox-2018-07-25-c83a84af/blobmsg.c:198:2:
时间: 2023-09-28 12:12:49 浏览: 48
这个错误信息提供的不够完整,只有一行代码。但是根据这行代码可以猜测可能是在使用某个函数时出错了,函数名可能是 `blobmsg_new`,文件路径可能是 `/home/ebyte/TX2063/openwrt/build_dir/hostpkg/libubox-2018-07-25-c83a84af/blobmsg.c`,行号可能是 `198`。需要查看更多的代码和错误信息才能确定问题的具体原因。
相关问题
代码输出的结果declare lines number :=5; begin FOR i IN 1..lines LOOP if i< lines /2+1 then dbms_output.put_line( lpad('*', 2*i -1, '*')); else dbms_output.put_line(lpad(' ', 2*(i -1)-(lined/2+1)|| lpad('*', 2*(lines - i)+1, '*')); end if; END LOOP; end;
抱歉,这段代码存在语法错误,无法执行。其中的 `lined` 变量未定义,应该是 `lines`。此外,第 6 行的 `lpad(' ', 2*(i -1)-(lined/2+1)|| lpad('*', 2*(lines - i)+1, '*')` 也存在错误,应该改为 `lpad(' ', 2*(i -1)-(lines/2+1)) || lpad('*', 2*(lines - i)+1, '*')`。修改后的代码如下:
```
declare
lines number := 5;
begin
for i in 1..lines loop
if i < lines / 2 + 1 then
dbms_output.put_line(lpad('*', 2*i - 1, '*'));
else
dbms_output.put_line(lpad(' ', 2*(i - 1) - (lines/2 + 1)) || lpad('*', 2*(lines - i) + 1, '*'));
end if;
end loop;
end;
```
这段代码的功能是输出一个菱形图案,示例输出如下:
```
*
***
*****
***
*
```
这个代码我可以添加一个列表,并且在画图时显示,用户通过一个下拉式的项目栏点击可以确定field_name的值,完整代码
好的,你可以试试下面的代码,我添加了一个列表 `field_name_list`,用户可以通过下拉式的项目栏来选择 `field_name` 的值。代码中还添加了一些注释方便理解。如果有问题可以随时问我。
```python
import os
import math
import json
import operator
import matplotlib.pyplot as plt
import re
from tkinter import *
def get_filenames(folder_path):
"""get filename"""
json_files = []
for file in os.listdir(folder_path):
if file.endswith('.json'):
json_files.append(file)
return json_files
def get_id_velocity(json_files, id_num, field_name):
"""Read the json file to find the value corresponding to the field name"""
x_list=[]
y_list=[]
name_list = []
for file in json_files:
with open(os.path.join(folder_path, file), 'r') as f:
data = json.load(f)
obstacles = data.get('obstacles')
if obstacles:
for obstacle in obstacles:
if obstacle['id']== id_num:
field_value = obstacle.get(field_name)
if field_value == None:
return x_list,y_list,name_list
x_list.append(field_value['x'])
y_list.append(field_value['y'])
name_list.append(file)
return x_list,y_list,name_list
def get_field_name(event):
"""get field name from dropdown list"""
global field_name
field_name = variable.get()
if __name__ == '__main__':
# create tkinter window
root = Tk()
root.title("Display based on user input")
# create dropdown list for field name
field_name_list = ['field_name1', 'field_name2', 'field_name3', 'field_name4']
variable = StringVar(root)
variable.set(field_name_list[0])
variable.trace("w", get_field_name)
w = OptionMenu(root, variable, *field_name_list)
w.pack()
# create plot figure
fig, ax = plt.subplots()
plt.title("display based on user input")
while True:
folder_path = 'front_middle_obs'
id_num = int(input('请输入要显示的id号,输入0退出:'))
if id_num == 0:
print("exit")
break
# get field name from dropdown list
field_name = variable.get()
json_files = get_filenames(folder_path=folder_path)
json_files.sort(key=operator.methodcaller("lower"))
x_list,y_list,name_list=get_id_velocity(json_files=json_files, id_num=id_num, field_name=field_name)
if len(x_list)==0:
print(f'请确定你的输入无误,我没有找到你输入的id:{id_num}对应的字段名:{field_name}')
continue
# calculate velocity
list3 = []
for i in range(len(x_list)):
value = math.sqrt(x_list[i] ** 2 + y_list[i] ** 2)
list3.append(value)
new_name_lst = list(range(len(name_list)))
x=[]
for file_name in name_list:
num = re.findall(r'\d+', file_name)[0]
x.append(num)
# plot curves
ax.plot(new_name_lst, x_list,label='velocity_x',linewidth=2)
ax.plot(new_name_lst, y_list, label='velocity_y',linewidth=2)
ax.plot(new_name_lst, list3, label='velocity',linewidth=2)
# set x-axis label
ax.set_xticks(new_name_lst)
ax.set_xticklabels(x)
# set legend
leg = ax.legend(loc='upper left', fancybox=True, shadow=True)
leg.get_frame().set_alpha(0.5)
# set line picker
lines = [l for l in ax.lines]
lined = dict()
for legline, origline in zip(leg.get_lines(), lines):
legline.set_picker(True)
lined[legline] = origline
def onpick(event):
"""visibility"""
legline = event.artist
origline = lined[legline]
visible = not origline.get_visible()
origline.set_visible(visible)
if visible:
legline.set_alpha(1.0)
else:
legline.set_alpha(0.2)
fig.canvas.draw()
fig.canvas.mpl_connect('pick_event', onpick)
# show plot
plt.show()
# close tkinter window
root.destroy()
```