stub for simulating serial port
parent
97de45eeb2
commit
46ac94cfac
|
@ -16,7 +16,7 @@ class DbAccessLogs
|
|||
def initialize(db)
|
||||
@dbaccess = db
|
||||
@log_to_screen = true
|
||||
@max_nr_log_lines = 10000
|
||||
@max_nr_log_lines = 1000
|
||||
end
|
||||
|
||||
## logs
|
||||
|
|
|
@ -7,13 +7,15 @@
|
|||
|
||||
require 'serialport'
|
||||
|
||||
require_relative 'ramps_serial_port_sim'
|
||||
require_relative 'ramps_arduino_values_received.rb'
|
||||
require_relative 'ramps_arduino_write_status.rb'
|
||||
|
||||
class HardwareInterfaceArduino
|
||||
|
||||
attr_accessor :ramps_param, :ramps_main
|
||||
attr_accessor :test_serial_read, :test_serial_write
|
||||
#attr_accessor :test_serial_read, :test_serial_write
|
||||
attr_accessor :serial_port
|
||||
attr_accessor :external_info
|
||||
|
||||
# initialize the interface
|
||||
|
@ -25,8 +27,6 @@ class HardwareInterfaceArduino
|
|||
@status_debug_msg = $status_debug_msg
|
||||
|
||||
@test_mode = test_mode
|
||||
@test_serial_read = ""
|
||||
@test_serial_write = ""
|
||||
|
||||
# connect to arduino
|
||||
connect_board()
|
||||
|
@ -53,6 +53,7 @@ class HardwareInterfaceArduino
|
|||
|
||||
comm_port = '/dev/ttyACM0'
|
||||
@serial_port = SerialPort.new(comm_port, parameters) if @test_mode == false
|
||||
@serial_port = SerialPortSim.new(comm_port, parameters) if @test_mode == true
|
||||
|
||||
end
|
||||
|
||||
|
@ -62,7 +63,9 @@ class HardwareInterfaceArduino
|
|||
begin
|
||||
|
||||
write_status = create_write_status(text, log, onscreen)
|
||||
#puts @serial_port.test_serial_read
|
||||
prepare_serial_port(write_status)
|
||||
#puts @serial_port.test_serial_read
|
||||
|
||||
# wait until the arduino responds
|
||||
while(write_status.is_busy())
|
||||
|
@ -89,25 +92,23 @@ class HardwareInterfaceArduino
|
|||
end
|
||||
|
||||
def handle_execution_exception(e)
|
||||
if @test_mode == false
|
||||
puts("ST: serial error\n#{e.message}\n#{e.backtrace.inspect}")
|
||||
end
|
||||
|
||||
puts("ST: serial error\n#{e.message}\n#{e.backtrace.inspect}")
|
||||
|
||||
@bot_dbaccess.write_to_log(4,"ST: serial error\n#{e.message}\n#{e.backtrace.inspect}")
|
||||
if @test_mode == false
|
||||
@serial_port.rts = 1
|
||||
connect_board
|
||||
sleep 5
|
||||
end
|
||||
sleep 5 if @test_mode == false
|
||||
end
|
||||
|
||||
def log_result_of_execution(write_status)
|
||||
|
||||
# log things if needed
|
||||
if write_status.done == 1
|
||||
puts 'ST: done' if write_status.onscreen and @test_mode == false
|
||||
puts 'ST: done' if write_status.onscreen
|
||||
@bot_dbaccess.write_to_log(4, 'ST: done') if write_status.log
|
||||
else
|
||||
puts 'ST: timeout' if @test_mode == false
|
||||
puts 'ST: timeout'
|
||||
@bot_dbaccess.write_to_log(4, 'ST: timeout')
|
||||
|
||||
sleep 5 if @test_mode == false
|
||||
|
@ -117,13 +118,10 @@ class HardwareInterfaceArduino
|
|||
# receive all characters coming from the serial port
|
||||
#
|
||||
def process_feedback(write_status)
|
||||
i = @serial_port.read(1)
|
||||
|
||||
if @test_mode == false
|
||||
i = @serial_port.read(1)
|
||||
else
|
||||
i = @test_serial_read[0]
|
||||
@test_serial_read = @test_serial_read[1..-1]
|
||||
end
|
||||
#print "-#{i}"
|
||||
#print "#{i}"
|
||||
|
||||
if i != nil
|
||||
i.each_char do |c|
|
||||
|
@ -132,7 +130,8 @@ class HardwareInterfaceArduino
|
|||
|
||||
end
|
||||
else
|
||||
sleep 0.001
|
||||
sleep 0.001 if @test_mode == false
|
||||
#write_status.done = 1 if @test_mode == true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -190,7 +189,7 @@ class HardwareInterfaceArduino
|
|||
def prepare_serial_port(write_status)
|
||||
puts "WR: #{write_status.text}" if write_status.onscreen
|
||||
@bot_dbaccess.write_to_log(4, "WR: #{write_status.text}") if write_status.log
|
||||
@serial_port.read_timeout = 2 if @test_mode == false
|
||||
@serial_port.read_timeout = 2
|
||||
clean_serial_buffer() if @test_mode == false
|
||||
serial_port_write( "#{write_status.text}\n" )
|
||||
end
|
||||
|
@ -198,21 +197,13 @@ class HardwareInterfaceArduino
|
|||
# empty the input buffer so no old data is processed
|
||||
#
|
||||
def clean_serial_buffer
|
||||
if @test_mode == false
|
||||
while (@serial_port.read(1) != nil)
|
||||
end
|
||||
else
|
||||
@test_serial_read = ''
|
||||
while (@serial_port.read(1) != nil)
|
||||
end
|
||||
end
|
||||
|
||||
# write something to the serial port
|
||||
def serial_port_write(text)
|
||||
if @test_mode == false
|
||||
@serial_port.write( text )
|
||||
else
|
||||
@test_serial_write = text
|
||||
end
|
||||
@serial_port.write( text )
|
||||
end
|
||||
|
||||
# if there is an emergency stop, immediately write it to the arduino
|
||||
|
@ -358,7 +349,7 @@ class HardwareInterfaceArduino
|
|||
#
|
||||
def process_value_process_R99(code,text)
|
||||
if code == 'R99'
|
||||
puts ">#{text}<" if @test_mode == false
|
||||
puts ">#{text}<"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -191,6 +191,7 @@ class HardwareInterfaceParam
|
|||
def update_param_version_ar
|
||||
# read the parameter version in the database and in the device
|
||||
read_parameter_from_device(0)
|
||||
|
||||
params.each do |p|
|
||||
if p['id'] == 0
|
||||
@param_version_ar = p['value_ar']
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
## SERIAL PORT SIMULATION
|
||||
## **********************
|
||||
|
||||
# Used for unit tests
|
||||
|
||||
|
||||
class SerialPortSim
|
||||
|
||||
attr_accessor :rts
|
||||
attr_accessor :read_timeout
|
||||
attr_accessor :test_serial_read, :test_serial_write
|
||||
|
||||
def initialize(comm_port, parameters)
|
||||
@test_serial_read = ""
|
||||
@test_serial_write = ""
|
||||
end
|
||||
|
||||
def write(text)
|
||||
@test_serial_write = text
|
||||
end
|
||||
|
||||
def read(characters)
|
||||
i = nil
|
||||
@test_serial_read = nil if @test_serial_read == ""
|
||||
|
||||
if @test_serial_read != nil
|
||||
i = @test_serial_read[0]
|
||||
@test_serial_read = @test_serial_read[1..-1]
|
||||
end
|
||||
i
|
||||
end
|
||||
|
||||
end
|
|
@ -38,13 +38,15 @@ describe ControllerCommandProc do
|
|||
command_line.coord_y = y
|
||||
command_line.coord_z = z
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
@controller.move_absolute(command_line)
|
||||
|
||||
part_x = "X#{x * @ramps.ramps_param.axis_x_steps_per_unit}"
|
||||
part_y = "Y#{y * @ramps.ramps_param.axis_y_steps_per_unit}"
|
||||
part_z = "Z#{z * @ramps.ramps_param.axis_z_steps_per_unit}"
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
end
|
||||
|
||||
# def move_relative(command_line)
|
||||
|
@ -68,45 +70,51 @@ describe ControllerCommandProc do
|
|||
command_line.coord_y = y
|
||||
command_line.coord_z = z
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
@controller.move_relative(command_line)
|
||||
|
||||
part_x = "X#{x * @ramps.ramps_param.axis_x_steps_per_unit + current_x}"
|
||||
part_y = "Y#{y * @ramps.ramps_param.axis_y_steps_per_unit + current_y}"
|
||||
part_z = "Z#{z * @ramps.ramps_param.axis_z_steps_per_unit + current_z}"
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
end
|
||||
|
||||
# def home_x(command_line)
|
||||
|
||||
it "home x" do
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
command_line = CommandLine.new
|
||||
@controller.home_x(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F11\n")
|
||||
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F11\n")
|
||||
end
|
||||
|
||||
# def home_y(command_line)
|
||||
|
||||
it "home y" do
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
command_line = CommandLine.new
|
||||
@controller.home_y(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F12\n")
|
||||
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F12\n")
|
||||
end
|
||||
|
||||
# def home_z(command_line)
|
||||
|
||||
it "home z" do
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
command_line = CommandLine.new
|
||||
@controller.home_z(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F13\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F13\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -114,10 +122,12 @@ describe ControllerCommandProc do
|
|||
|
||||
it "calibrate x" do
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
command_line = CommandLine.new
|
||||
@controller.calibration_x(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F14\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F14\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -125,10 +135,12 @@ describe ControllerCommandProc do
|
|||
|
||||
it "calibrate y" do
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
command_line = CommandLine.new
|
||||
@controller.calibration_y(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F15\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F15\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -136,10 +148,12 @@ describe ControllerCommandProc do
|
|||
|
||||
it "calibrate z" do
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
command_line = CommandLine.new
|
||||
@controller.calibration_z(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F16\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F16\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -149,11 +163,13 @@ describe ControllerCommandProc do
|
|||
|
||||
amount = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
command_line = CommandLine.new
|
||||
command_line.amount = amount
|
||||
@controller.dose_water(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F01 Q#{amount}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F01 Q#{amount}\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -170,9 +186,11 @@ describe ControllerCommandProc do
|
|||
command_line.pin_value_1 = value
|
||||
command_line.pin_mode = mode
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
@controller.pin_write(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F41 P#{pin} V#{value} M#{mode}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F41 P#{pin} V#{value} M#{mode}\n")
|
||||
end
|
||||
|
||||
# def pin_read(command_line)
|
||||
|
@ -190,9 +208,11 @@ describe ControllerCommandProc do
|
|||
command_line.pin_mode = mode
|
||||
command_line.external_info = ext_info
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
@controller.pin_read(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F42 P#{pin} M#{mode}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F42 P#{pin} M#{mode}\n")
|
||||
end
|
||||
|
||||
# def pin_mode(command_line)
|
||||
|
@ -206,9 +226,11 @@ describe ControllerCommandProc do
|
|||
command_line.pin_nr = pin
|
||||
command_line.pin_mode = mode
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
@controller.pin_mode(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F43 P#{pin} M#{mode}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F43 P#{pin} M#{mode}\n")
|
||||
end
|
||||
|
||||
|
||||
|
@ -229,9 +251,11 @@ describe ControllerCommandProc do
|
|||
command_line.pin_value_2 = value_2
|
||||
command_line.pin_time = time
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
@controller.pin_pulse(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F44 P#{pin} V#{value_1} W#{value_2} T#{time} M#{mode}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F44 P#{pin} V#{value_1} W#{value_2} T#{time} M#{mode}\n")
|
||||
end
|
||||
|
||||
# def servo_move(command_line)
|
||||
|
@ -241,12 +265,14 @@ describe ControllerCommandProc do
|
|||
pin = rand(9999999).to_i
|
||||
value = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
command_line = CommandLine.new
|
||||
command_line.pin_nr = pin
|
||||
command_line.pin_value_1 = value
|
||||
@controller.servo_move(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F61 P#{pin} V#{value}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F61 P#{pin} V#{value}\n")
|
||||
end
|
||||
|
||||
# def send_command(command_line)
|
||||
|
@ -256,19 +282,21 @@ describe ControllerCommandProc do
|
|||
pin = rand(9999999).to_i
|
||||
value = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
command_line = CommandLine.new
|
||||
command_line.action = 'SERVO MOVE'
|
||||
command_line.pin_nr = pin
|
||||
command_line.pin_value_1 = value
|
||||
@controller.send_command(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F61 P#{pin} V#{value}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F61 P#{pin} V#{value}\n")
|
||||
|
||||
$hardware_sim = 1
|
||||
|
||||
@ramps.ramps_arduino.test_serial_write = ""
|
||||
@ramps.ramps_arduino.serial_port.test_serial_write = ""
|
||||
@controller.send_command(command_line)
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("")
|
||||
|
||||
$hardware_sim = 0
|
||||
end
|
||||
|
@ -288,9 +316,11 @@ describe ControllerCommandProc do
|
|||
cmd = Command.new
|
||||
cmd.command_lines << command_line
|
||||
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
@controller.process_command( cmd )
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F61 P#{pin} V#{value}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F61 P#{pin} V#{value}\n")
|
||||
end
|
||||
|
||||
# def process_command( cmd )
|
||||
|
|
|
@ -30,10 +30,10 @@ describe HardwareInterfaceArduino do
|
|||
|
||||
command = "TEST"
|
||||
|
||||
@ramps.test_serial_read = "R01\nR02\n"
|
||||
@ramps.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.execute_command(command, false, false)
|
||||
|
||||
expect(@ramps.test_serial_write).to eq("#{command}\n")
|
||||
expect(@ramps.serial_port.test_serial_write).to eq("#{command}\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -76,7 +76,7 @@ describe HardwareInterfaceArduino do
|
|||
log = rand(9999999).to_s
|
||||
onscreen = false
|
||||
|
||||
@ramps.test_serial_read = "R02\n"
|
||||
@ramps.serial_port.test_serial_read = "R02\n"
|
||||
|
||||
write_status = @ramps.create_write_status(text, log, onscreen)
|
||||
|
||||
|
@ -200,30 +200,30 @@ describe HardwareInterfaceArduino do
|
|||
end
|
||||
|
||||
it "clean serial buffer" do
|
||||
@ramps.test_serial_read = rand(9999999).to_s
|
||||
@ramps.serial_port.test_serial_read = rand(9999999).to_s
|
||||
@ramps.clean_serial_buffer
|
||||
expect(@ramps.test_serial_read).to eq("")
|
||||
expect(@ramps.serial_port.test_serial_read).to eq(nil)
|
||||
|
||||
end
|
||||
|
||||
it "serial port write" do
|
||||
text = rand(9999999).to_s
|
||||
@ramps.serial_port_write(text)
|
||||
expect(@ramps.test_serial_write).to eq(text)
|
||||
expect(@ramps.serial_port.test_serial_write).to eq(text)
|
||||
end
|
||||
|
||||
it "emergency stop off" do
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
$status.emergency_stop = false
|
||||
@ramps.check_emergency_stop
|
||||
expect(@ramps.test_serial_write).to eq("")
|
||||
expect(@ramps.serial_port.test_serial_write).to eq("")
|
||||
end
|
||||
|
||||
it "emergency stop on" do
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
$status.emergency_stop = true
|
||||
@ramps.check_emergency_stop
|
||||
expect(@ramps.test_serial_write).to eq("E\n")
|
||||
expect(@ramps.serial_port.test_serial_write).to eq("E\n")
|
||||
end
|
||||
|
||||
it "log incoming text" do
|
||||
|
|
|
@ -238,10 +238,9 @@ describe HardwareInterfaceArduino do
|
|||
value = rand(9999999).to_i
|
||||
|
||||
@ramps.clean_serial_buffer()
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = "R21 P#{id} V#{value}\n"
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = "R01\nR21 P#{id} V#{value}\nR02\n"
|
||||
@ramps_param.read_parameter_from_device(id)
|
||||
|
||||
param = @ramps_param.get_param(id, :by_id)
|
||||
|
||||
expect(param['id']).to eq(id)
|
||||
|
@ -259,12 +258,12 @@ describe HardwareInterfaceArduino do
|
|||
@ramps_param.save_param_value(id, :by_id, :from_db, value)
|
||||
|
||||
@ramps.clean_serial_buffer()
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = "R01\nR02\n"
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = "R01\nR02\n"
|
||||
|
||||
@ramps_param.write_parameter_to_device(id, value)
|
||||
|
||||
expect(@ramps.test_serial_write).to eq("F22 P#{id} V#{value}\n")
|
||||
expect(@ramps.serial_port.test_serial_write).to eq("F22 P#{id} V#{value}\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -276,8 +275,9 @@ describe HardwareInterfaceArduino do
|
|||
value = rand(9999999).to_i
|
||||
|
||||
@ramps.clean_serial_buffer()
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = "R21 P#{id} V#{value}\n"
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = "R01\nR21 P#{id} V#{value}\nR02\n"
|
||||
|
||||
@ramps_param.update_param_version_ar()
|
||||
|
||||
expect(@ramps_param.param_version_ar).to eq(value)
|
||||
|
@ -287,8 +287,12 @@ describe HardwareInterfaceArduino do
|
|||
|
||||
it "parameters different false" do
|
||||
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = ""
|
||||
|
||||
@ramps_param.params.each do |p|
|
||||
p['value_ar'] = p['value_db']
|
||||
@ramps.serial_port.test_serial_read = @ramps.serial_port.test_serial_read + "R02\n"
|
||||
end
|
||||
|
||||
different = @ramps_param.parameters_different()
|
||||
|
@ -301,8 +305,12 @@ describe HardwareInterfaceArduino do
|
|||
id = 11
|
||||
value = rand(9999999).to_i
|
||||
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = ""
|
||||
|
||||
@ramps_param.params.each do |p|
|
||||
p['value_ar'] = p['value_db']
|
||||
@ramps.serial_port.test_serial_read = @ramps.serial_port.test_serial_read + "R02\n"
|
||||
end
|
||||
|
||||
@ramps_param.save_param_value(id, :by_id, :from_db, value)
|
||||
|
@ -316,7 +324,6 @@ describe HardwareInterfaceArduino do
|
|||
|
||||
it "check and write one parameter, test with similar" do
|
||||
|
||||
|
||||
name = 'TESTING'
|
||||
id = 1
|
||||
value = rand(9999999).to_i
|
||||
|
@ -325,8 +332,9 @@ describe HardwareInterfaceArduino do
|
|||
$bot_dbaccess.write_parameter(name,value)
|
||||
|
||||
param = @ramps_param.get_param(id, :by_id)
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = "R21 P#{id} V#{value}\n"
|
||||
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = "R01\nR21 P#{id} V#{value}\nR02\nR02\n"
|
||||
|
||||
differences_found = @ramps_param.check_and_write_parameter(param)
|
||||
|
||||
|
@ -335,7 +343,6 @@ describe HardwareInterfaceArduino do
|
|||
|
||||
it "check and write one parameter, test with different" do
|
||||
|
||||
|
||||
name = 'TESTING'
|
||||
id = 1
|
||||
value = rand(9999999).to_i
|
||||
|
@ -344,15 +351,16 @@ describe HardwareInterfaceArduino do
|
|||
$bot_dbaccess.write_parameter(name,value)
|
||||
|
||||
param = @ramps_param.get_param(id, :by_id)
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = "R21 P#{id} V#{value2}\n"
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = "R01\nR21 P#{id} V#{value2}\nR02\nR02\n"
|
||||
|
||||
differences_found = @ramps_param.check_and_write_parameter(param)
|
||||
|
||||
expect(differences_found).to eq(true)
|
||||
expect(@ramps.test_serial_write).to eq("F22 P#{id} V#{value}\n")
|
||||
expect(@ramps.serial_port.test_serial_write).to eq("F22 P#{id} V#{value}\n")
|
||||
end
|
||||
|
||||
|
||||
# def compare_and_write_parameters
|
||||
|
||||
it "compare and write paramters, different" do
|
||||
|
@ -366,6 +374,9 @@ describe HardwareInterfaceArduino do
|
|||
value3 = rand(9999999).to_i
|
||||
value4 = rand(9999999).to_i
|
||||
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = ""
|
||||
|
||||
$bot_dbaccess.write_parameter(name,value0)
|
||||
|
||||
@ramps_param.param_version_db = value3
|
||||
|
@ -383,12 +394,21 @@ describe HardwareInterfaceArduino do
|
|||
end
|
||||
|
||||
#@ramps_param.save_param_value(id, :by_id, :from_db, value)
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = ""
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = ""
|
||||
|
||||
feedback = ""
|
||||
@ramps_param.params.each do |p|
|
||||
if p['id'] != 0
|
||||
feedback = feedback + "R01\nR02\n"
|
||||
end
|
||||
end
|
||||
feedback = feedback + "R01\nR02\n"
|
||||
@ramps.serial_port.test_serial_read = feedback
|
||||
|
||||
@ramps_param.compare_and_write_parameters()
|
||||
|
||||
expect(@ramps.test_serial_write).to eq("F22 P#{id} V#{value0}\n")
|
||||
expect(@ramps.serial_port.test_serial_write).to eq("F22 P#{id} V#{value0}\n")
|
||||
expect(@ramps_param.params_in_sync).to eq(false)
|
||||
end
|
||||
|
||||
|
@ -399,15 +419,23 @@ describe HardwareInterfaceArduino do
|
|||
|
||||
value = rand(9999999).to_i
|
||||
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = ""
|
||||
|
||||
@ramps_param.param_version_db = value
|
||||
@ramps_param.param_version_ar = value
|
||||
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = ""
|
||||
feedback = ""
|
||||
@ramps_param.params.each do |p|
|
||||
if p['id'] != 0
|
||||
feedback = feedback + "R01\nR02\n"
|
||||
end
|
||||
end
|
||||
@ramps.serial_port.test_serial_read = feedback
|
||||
|
||||
@ramps_param.compare_and_write_parameters()
|
||||
|
||||
expect(@ramps.test_serial_write).to eq("")
|
||||
expect(@ramps.serial_port.test_serial_write).to eq("")
|
||||
expect(@ramps_param.params_in_sync).to eq(true)
|
||||
end
|
||||
|
||||
|
@ -418,6 +446,9 @@ describe HardwareInterfaceArduino do
|
|||
|
||||
value = rand(9999999).to_i
|
||||
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = ""
|
||||
|
||||
@ramps_param.params.each do |p|
|
||||
p['value_ar'] = p['value_db']
|
||||
end
|
||||
|
@ -427,12 +458,19 @@ describe HardwareInterfaceArduino do
|
|||
|
||||
$bot_dbaccess.write_parameter('PARAM_VERSION',@ramps_param.param_version_db)
|
||||
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = ""
|
||||
feedback = ""
|
||||
@ramps_param.params.each do |p|
|
||||
if p['id'] != 0
|
||||
feedback = feedback + "R01\nR02\n"
|
||||
end
|
||||
end
|
||||
feedback = feedback + "R01\nR02\n"
|
||||
@ramps.serial_port.test_serial_read = feedback
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
|
||||
@ramps_param.compare_and_write_parameters()
|
||||
|
||||
expect(@ramps.test_serial_write).to eq("F22 P0 V#{value}\n")
|
||||
expect(@ramps.serial_port.test_serial_write).to eq("F22 P0 V#{value}\n")
|
||||
expect(@ramps_param.params_in_sync).to eq(true)
|
||||
end
|
||||
|
||||
|
@ -448,8 +486,19 @@ describe HardwareInterfaceArduino do
|
|||
|
||||
$bot_dbaccess.write_parameter('PARAM_VERSION',db_version)
|
||||
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = "R21 P0 V#{db_version}\n"
|
||||
feedback = ""
|
||||
feedback = feedback + "R01\nR21 P0 V#{db_version}\nR02\n"
|
||||
@ramps_param.params.each do |p|
|
||||
if p['id'] != 0
|
||||
feedback = feedback + "R01\nR02\n"
|
||||
end
|
||||
end
|
||||
#feedback = feedback + "R01\nR02\n"
|
||||
|
||||
@ramps.serial_port.test_serial_read = feedback
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
|
||||
#@ramps.serial_port.test_serial_read =
|
||||
|
||||
@ramps_param.check_parameters()
|
||||
|
||||
|
@ -469,11 +518,23 @@ describe HardwareInterfaceArduino do
|
|||
value1 = rand(9999999).to_i
|
||||
value2 = rand(9999999).to_i
|
||||
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = ""
|
||||
|
||||
$bot_dbaccess.write_parameter(name,value0)
|
||||
$bot_dbaccess.write_parameter('PARAM_VERSION',db_version)
|
||||
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = "R21 P0 V#{ar_version}\n"
|
||||
|
||||
feedback = ""
|
||||
feedback = feedback + "R01\nR21 P0 V#{ar_version}\nR02\n"
|
||||
@ramps_param.params.each do |p|
|
||||
if p['id'] != 0
|
||||
feedback = feedback + "R01\nR02\n"
|
||||
end
|
||||
end
|
||||
feedback = feedback + "R01\nR02\n"
|
||||
@ramps.serial_port.test_serial_write = ""
|
||||
@ramps.serial_port.test_serial_read = feedback
|
||||
|
||||
# make sure all parameters in device and database are equal
|
||||
@ramps_param.params.each do |p|
|
||||
|
@ -491,7 +552,7 @@ describe HardwareInterfaceArduino do
|
|||
@ramps_param.check_parameters()
|
||||
|
||||
expect(@ramps_param.params_in_sync).to eq(false)
|
||||
expect(@ramps.test_serial_write).to eq("F22 P#{id} V#{value0}\n")
|
||||
expect(@ramps.serial_port.test_serial_write).to eq("F22 P#{id} V#{value0}\n")
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -23,10 +23,10 @@ describe HardwareInterface do
|
|||
pin = rand(9999999).to_i
|
||||
value = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.servo_std_move(pin, value)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F61 P#{pin} V#{value}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F61 P#{pin} V#{value}\n")
|
||||
end
|
||||
|
||||
# def pin_std_set_value(pin, value, mode)
|
||||
|
@ -37,10 +37,10 @@ describe HardwareInterface do
|
|||
value = rand(9999999).to_i
|
||||
mode = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.pin_std_set_value(pin, value, mode)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F41 P#{pin} V#{value} M#{mode}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F41 P#{pin} V#{value} M#{mode}\n")
|
||||
end
|
||||
|
||||
# def pin_std_read_value(pin, mode, external_info)
|
||||
|
@ -52,7 +52,7 @@ describe HardwareInterface do
|
|||
value = rand(9999999).to_i
|
||||
ext_info = rand(9999999).to_s
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR41 P#{pin} V#{value}\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR41 P#{pin} V#{value}\nR02\n"
|
||||
@ramps.pin_std_read_value(pin, mode, ext_info)
|
||||
|
||||
pin_value = 0
|
||||
|
@ -65,7 +65,7 @@ describe HardwareInterface do
|
|||
end
|
||||
|
||||
expect(pin_value.to_i).to eq(value.to_i)
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F42 P#{pin} M#{mode}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F42 P#{pin} M#{mode}\n")
|
||||
end
|
||||
|
||||
# def pin_std_set_mode(pin, mode)
|
||||
|
@ -75,10 +75,10 @@ describe HardwareInterface do
|
|||
pin = rand(9999999).to_i
|
||||
mode = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.pin_std_set_mode(pin, mode)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F43 P#{pin} M#{mode}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F43 P#{pin} M#{mode}\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -92,10 +92,10 @@ describe HardwareInterface do
|
|||
time = rand(9999999).to_i
|
||||
mode = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.pin_std_pulse(pin, value1, value2, time, mode)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F44 P#{pin} V#{value1} W#{value2} T#{time} M#{mode}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F44 P#{pin} V#{value1} W#{value2} T#{time} M#{mode}\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -105,10 +105,10 @@ describe HardwareInterface do
|
|||
|
||||
amount = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.dose_water(amount)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F01 Q#{amount}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F01 Q#{amount}\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -123,10 +123,10 @@ describe HardwareInterface do
|
|||
za = (rand(2) >= 1) ? 1 : 0
|
||||
zb = (rand(2) >= 1) ? 1 : 0
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR81 XA#{xa} XB#{xb} YA#{ya} YB#{yb} ZA#{za} ZB#{zb}\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR81 XA#{xa} XB#{xb} YA#{ya} YB#{yb} ZA#{za} ZB#{zb}\nR02\n"
|
||||
@ramps.read_end_stops()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F81\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F81\n")
|
||||
expect($status.info_end_stop_x_a).to eq(xa == 1)
|
||||
expect($status.info_end_stop_x_b).to eq(xb == 1)
|
||||
expect($status.info_end_stop_y_a).to eq(ya == 1)
|
||||
|
@ -144,10 +144,10 @@ describe HardwareInterface do
|
|||
z = rand(9999999).to_i
|
||||
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR82 X#{x} Y#{y} Z#{z}\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR82 X#{x} Y#{y} Z#{z}\nR02\n"
|
||||
@ramps.read_postition()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F82\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F82\n")
|
||||
expect($status.info_current_x_steps).to eq(x)
|
||||
expect($status.info_current_y_steps).to eq(y)
|
||||
expect($status.info_current_z_steps).to eq(z)
|
||||
|
@ -159,10 +159,10 @@ describe HardwareInterface do
|
|||
|
||||
version = rand(9999999).to_s
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR83 #{version}\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR83 #{version}\nR02\n"
|
||||
@ramps.read_device_version()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F83\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F83\n")
|
||||
expect($status.device_version).to eq(version)
|
||||
end
|
||||
|
||||
|
@ -170,10 +170,10 @@ describe HardwareInterface do
|
|||
|
||||
it "home all" do
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.move_home_all()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("G28\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("G28\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -181,10 +181,10 @@ describe HardwareInterface do
|
|||
|
||||
it "home x" do
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.move_home_x()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F11\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F11\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -192,10 +192,10 @@ describe HardwareInterface do
|
|||
|
||||
it "home y" do
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.move_home_y()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F12\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F12\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -203,10 +203,10 @@ describe HardwareInterface do
|
|||
|
||||
it "home z" do
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.move_home_z()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F13\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F13\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -214,10 +214,10 @@ describe HardwareInterface do
|
|||
|
||||
it "calibrate x" do
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.calibrate_x()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F14\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F14\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -225,10 +225,10 @@ describe HardwareInterface do
|
|||
|
||||
it "calibrate y" do
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.calibrate_y()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F15\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F15\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -236,10 +236,10 @@ describe HardwareInterface do
|
|||
|
||||
it "calibrate z" do
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.calibrate_z()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F16\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F16\n")
|
||||
|
||||
end
|
||||
|
||||
|
@ -251,14 +251,14 @@ describe HardwareInterface do
|
|||
y = rand(9999999).to_i
|
||||
z = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.move_absolute( x, y, z)
|
||||
|
||||
part_x = "X#{x * @ramps.ramps_param.axis_x_steps_per_unit}"
|
||||
part_y = "Y#{y * @ramps.ramps_param.axis_y_steps_per_unit}"
|
||||
part_z = "Z#{z * @ramps.ramps_param.axis_z_steps_per_unit}"
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
end
|
||||
|
||||
|
||||
|
@ -278,14 +278,14 @@ describe HardwareInterface do
|
|||
$status.info_current_y_steps = current_y
|
||||
$status.info_current_z_steps = current_z
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.move_relative( x, y, z)
|
||||
|
||||
part_x = "X#{x * @ramps.ramps_param.axis_x_steps_per_unit + current_x}"
|
||||
part_y = "Y#{y * @ramps.ramps_param.axis_y_steps_per_unit + current_y}"
|
||||
part_z = "Z#{z * @ramps.ramps_param.axis_z_steps_per_unit + current_z}"
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
end
|
||||
|
||||
# def move_steps(steps_x, steps_y, steps_z)
|
||||
|
@ -296,14 +296,14 @@ describe HardwareInterface do
|
|||
y = rand(9999999).to_i
|
||||
z = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.move_steps( x, y, z)
|
||||
|
||||
part_x = "X#{x}"
|
||||
part_y = "Y#{y}"
|
||||
part_z = "Z#{z}"
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("G01 #{part_x} #{part_y} #{part_z}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("G01 #{part_x} #{part_y} #{part_z}\n")
|
||||
end
|
||||
|
||||
# def move_to_coord(steps_x, steps_y, steps_z)
|
||||
|
@ -314,14 +314,14 @@ describe HardwareInterface do
|
|||
y = rand(9999999).to_i
|
||||
z = rand(9999999).to_i
|
||||
|
||||
@ramps.ramps_arduino.test_serial_read = "R01\nR02\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R01\nR02\n"
|
||||
@ramps.move_to_coord( x, y, z)
|
||||
|
||||
part_x = "X#{x}"
|
||||
part_y = "Y#{y}"
|
||||
part_z = "Z#{z}"
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("G00 #{part_x} #{part_y} #{part_z}\n")
|
||||
end
|
||||
|
||||
# def check_parameters
|
||||
|
@ -332,11 +332,11 @@ describe HardwareInterface do
|
|||
|
||||
$bot_dbaccess.write_parameter('PARAM_VERSION',db_version)
|
||||
|
||||
@ramps.ramps_arduino.test_serial_write = ""
|
||||
@ramps.ramps_arduino.test_serial_read = "R21 P0 V#{db_version}\n"
|
||||
@ramps.ramps_arduino.serial_port.test_serial_write = ""
|
||||
@ramps.ramps_arduino.serial_port.test_serial_read = "R21 P0 V#{db_version}\n"
|
||||
@ramps.check_parameters()
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F21 P0\n")
|
||||
expect(@ramps.ramps_arduino.serial_port.test_serial_write).to eq("F21 P0\n")
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue