开源改变世界

Stream.py 删除 c_line #296

推推 grbl 3年前 (2023-01-21) 208次浏览

关闭
saul530 打开了这个问题 2017 年 10 月 22 日 · 1条评论
关闭

Stream.py 删除 c_line#296

saul530 打开了这个问题 2017 年 10 月 22 日 · 1条评论

注释

Stream.py 删除 c_line #296

在树莓派上将 stream.py 代码用作单独的线程时,我遇到了以下代码的问题。

	while sum(c_line) >= RX_BUFFER_SIZE-1 | s.inWaiting() :
		out_temp = s.readline().strip() # Wait for grbl response
		if out_temp.find('ok') < 0 and out_temp.find('error') < 0 :
			print "    MSG: \""+out_temp+"\"" # Debug response
		else :
			if out_temp.find('error') >= 0 : error_count += 1
			g_count += 1 # Iterate g-code counter
			if verbose: print "  REC<"+str(g_count)+": \""+out_temp+"\""
			del c_line[0] # Delete the block character count corresponding to the last 'ok'

我不是 100% 确定发生了什么,但我怀疑有时程序会因为 s.inWaiting() 进入 while 循环并且会崩溃,因为它在那里的时间比 c_line 中的条目长。

不确定这是否是正确的解决方法,但在确保有删除机会之前有一个条目后,我没有遇到任何问题。

	while sum(c_line) >= RX_BUFFER_SIZE-1 | s.inWaiting() :
		out_temp = s.readline().strip() # Wait for grbl response
		if out_temp.find('ok') < 0 and out_temp.find('error') < 0 :
			print "    MSG: \""+out_temp+"\"" # Debug response
		else :
			if(c_line):
				if out_temp.find('error') >= 0 : error_count += 1
				g_count += 1 # Iterate g-code counter
				if verbose: print "  REC<"+str(g_count)+": \""+out_temp+"\""
				del c_line[0] # Delete the block character count corresponding to the last 'ok'
Stream.py 删除 c_line #296 saul530 更改了标题 Stream.py del c_line 问题 Stream.py 删除 c_line 2017 年 10 月 22 日
Stream.py 删除 c_line #296
贡献者

@saul530:我经常使用流式脚本进行测试甚至工作。在 RPis、Mac 和其他 Linux PC 上。我从未遇到过流式脚本的性能或可靠性问题。我怀疑你的问题与试图改变它的工作方式和在线程中使用有关。我在这里帮不了你,因为我无意让流媒体脚本更复杂。它有意设计得简单,因此它删除了用于测试的变量。

喜欢 (0)