Equipment/VinylCutterOld: Difference between revisions

From London Hackspace Wiki

No edit summary
Line 57: Line 57:
  if (!ARGV[0])
  if (!ARGV[0])
  puts "Yo dawg, I need a file."
  puts "Yo dawg, I need a file."
exit
end
begin
inputFile = File.open(ARGV[0], "r")
rescue
puts "Failed to open #{ARGV[0]}"
exit
end
serialData = inputFile.read
if (serialData !=~ /^IN/)
puts "That doesn't seem to be valid HPGL data."
  exit
  exit
  end
  end
Line 75: Line 62:
  plotter = SerialPort.new("/dev/ttyUSB2")
  plotter = SerialPort.new("/dev/ttyUSB2")
  plotter.baud=(9600)
  plotter.baud=(9600)
  plotter.flow_control=(SerialPort::SOFT)
  plotter.flow_control=(SerialPort::HARD)
  plotter.rts=(1)
  plotter.rts=(1)
  plotter.data_bits=(8)
  plotter.data_bits=(8)
  plotter.stop_bits=(1)
  plotter.stop_bits=(1)
   
   
  plotter.write(serialData)
  begin
        File.open(ARGV[0], "r") do |inFile|
                while (line = inFile.gets)
                        puts line
                        plotter.write(line)
                        # sleep(1)
                end
        end
rescue
        puts "Failed to open #{ARGV[0]}"
        exit
end
Anonymous user