Equipment/VinylCutterOld: Difference between revisions
From London Hackspace Wiki
→Example code
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 | 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:: | 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( | 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 |