Ruby简单的串口通信

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

def serialport_command(command)
	result = ""
	File.open("COM3","w+") do |sp|
		sp.write(command)
		while char = sp.read(1)
			result += char
			break if result.upcase.include?("ENDEND")
		end
	end
	result
end