added a simple ruby-script to stream gcode and made serial protocol more reprap-like

This commit is contained in:
Simen Svale Skogsrud 2010-01-06 23:49:33 +01:00
parent c669a7562c
commit 65b696f2f9
4 changed files with 153 additions and 1 deletions

2
script/stream Executable file
View File

@ -0,0 +1,2 @@
#!/opt/local/bin/ruby
require 'stream'

38
script/stream.rb Normal file
View File

@ -0,0 +1,38 @@
require 'rubygems'
require 'optparse'
require 'serialport'
options_parser = OptionParser.new do |opts|
opts.banner = "Usage: stream [options] gcode-file"
opts.on('-v', '--verbose', 'Output more information') do
$verbose = true
end
opts.on('-h', '--help', 'Display this screen') do
puts opts
exit
end
end
options_parser.parse!
if ARGV.empty?
puts options_parser
exit
end
SerialPort.open('/dev/tty.usbserial-A4001o6L', 9600) do |sp|
ARGV.each do |file|
puts "Processing file #{file}"
prebuffer = 5
File.readlines(file).each do |line|
sp.write("#{line.strip}\r\n");
puts line.strip
if prebuffer == 0
result = sp.gets
puts result unless result.strip == 'ok'
else
prebuffer -= 1
end
end
end
end

112
script/test.gcode Normal file
View File

@ -0,0 +1,112 @@
G90
F1000
G1 X-27.7814 Y11.3222
G1 X-13.7952 Y1.99803
G1 X-27.7814 Y11.3222
G1 X-27.7814 Y1.99803
G1 X-27.7814 Y11.3222
G1 X-27.7814 Y1.99803
G1 X-13.7952 Y1.99803
G1 X-13.7952 Y11.3222
G1 X-13.7952 Y1.99803
G1 X-10.8055 Y21.1219
G1 X-11.3961 Y19.7548
G1 X-11.558 Y17.878
G1 X-10.7814 Y15.9202
G1 X-9.92396 Y14.9009
G1 X-8.12809 Y13.8007
G1 X-6.25129 Y13.6388
G1 X-4.80324 Y13.9866
G1 X-3.27425 Y15.2728
G1 X-2.68367 Y16.64
G1 X-2.52182 Y18.5168
G1 X-3.29837 Y20.4745
G1 X-4.15584 Y21.4938
G1 X-5.95171 Y22.5941
G1 X-7.8285 Y22.7559
G1 X-9.27656 Y22.4081
G1 X-10.8055 Y21.1219
G1 X4.27576 Y18.746
G1 X12.2103 Y17.788
G1 X12.3699 Y19.1104
G1 X11.8684 Y20.5127
G1 X11.287 Y21.2537
G1 X10.0444 Y22.0746
G1 X8.06077 Y22.3141
G1 X6.65853 Y21.8125
G1 X5.17645 Y20.6498
G1 X4.27576 Y18.746
G1 X4.1161 Y17.4235
G1 X4.53783 Y15.3601
G1 X5.70059 Y13.878
G1 X6.94317 Y13.0572
G1 X8.9268 Y12.8177
G1 X10.329 Y13.3192
G1 X11.8111 Y14.482
G1 X23.6509 Y14.951
G1 X14.8687 Y7.80509
G1 X13.7392 Y6.02745
G1 X14.0633 Y4.5739
G1 X14.904 Y3.5407
G1 X18.7737 Y13.5584
G1 X21.7161 Y9.94214
G1 X18.7737 Y13.5584
G1 X23.2352 Y1.31533
G1 X14.0474 Y-0.273848
G1 X23.2352 Y1.31533
G1 X19.2976 Y0.634252
G1 X21.3799 Y0.318524
G1 X22.9194 Y-0.766981
G1 X23.8027 Y-1.966
G1 X24.1433 Y-3.9348
G1 X18.6913 Y-14.6127
G1 X18.6517 Y-13.1239
G1 X18.0086 Y-11.3533
G1 X16.4803 Y-9.90425
G1 X15.2734 Y-9.34046
G1 X13.1813 Y-9.0982
G1 X11.4107 Y-9.74125
G1 X10.2435 Y-10.6662
G1 X9.39784 Y-12.4764
G1 X9.43747 Y-13.9651
G1 X10.0805 Y-15.7357
G1 X11.6089 Y-17.1848
G1 X12.8157 Y-17.7486
G1 X14.9078 Y-17.9909
G1 X16.6784 Y-17.3478
G1 X17.8456 Y-16.4229
G1 X18.6913 Y-14.6127
G1 X4.61246 Y-22.8107
G1 X0.289415 Y-9.50937
G1 X0.289415 YG1 X-9.50937
G1 X4.61246 Y-22.8107
G1 X3.99488 Y-20.9105
G1 X3.13981 Y-22.589
G1 X2.07887 Y-23.6341
G1 X0.178684 Y-24.2517
G1 X-1.29397 Y-24.03
G1 X-2.97248 Y-23.175
G1 X-4.22345 Y-21.4806
G1 X-4.63517 Y-20.2138
G1 X-4.61935 Y-18.1078
G1 X-3.76428 Y-16.4293
G1 X-2.70335 Y-15.3842
G1 X-0.803156 Y-14.7666
G1 X0.669496 Y-14.9883
G1 X2.34801 Y-15.8433
G1 X-10.9479 Y-15.8062
G1 X-17.9553 Y-11.9629
G1 X-18.5959 Y-13.1308
G1 X-18.6525 Y-14.619
G1 X-18.3888 Y-15.5232
G1 X-17.5412 Y-16.7477
G1 X-15.7893 Y-17.7085
G1 X-14.3011 Y-17.7651
G1 X-12.4927 Y-17.2378
G1 X-10.9479 Y-15.8062
G1 X-10.3074 Y-14.6383
G1 X-9.93052 Y-12.5662
G1 X-10.4579 Y-10.7577
G1 X-11.3055 Y-9.53325
G1 X-13.0573 Y-8.57243
G1 X-14.5455 Y-8.51583

View File

@ -32,7 +32,7 @@ char line[BLOCK_BUFFER_SIZE];
uint8_t line_counter; uint8_t line_counter;
void prompt() { void prompt() {
printString("\r\n@"); printString("ok\r\n");
line_counter = 0; line_counter = 0;
} }