- 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
- #该片段来自于http://www.codesnippet.cn/detail/090720134511.html
来源: http://www.codesnippet.cn/detail/090720134511.html