Remove '\r' from serial datastream
This commit is contained in:
@@ -13,7 +13,11 @@ ActiveRecord::Base.establish_connection(connection_details)
|
||||
|
||||
# # Open connection to serial port
|
||||
ser = SerialPort.new("/dev/ttyUSB1", 9600, 7, 1, SerialPort::EVEN)
|
||||
#
|
||||
lines = ""
|
||||
for i in 0..22
|
||||
lines = lines+ser.readline("\n").gsub(/\r/, '')
|
||||
end
|
||||
|
||||
# # read until newline
|
||||
# response = ser.readline("\r")
|
||||
# response.chomp!
|
||||
@@ -21,8 +25,8 @@ ser = SerialPort.new("/dev/ttyUSB1", 9600, 7, 1, SerialPort::EVEN)
|
||||
|
||||
sync = Synchronizer.new
|
||||
#lines = File.read("example_blurp.txt")[rand(1500)..-1]
|
||||
lines = ser.readpartial(4096) # read max 4k of data
|
||||
p "There are #{lines.length} characters"
|
||||
p lines
|
||||
while (!lines.nil? && lines.length > 0)
|
||||
lines = sync.handle_byte_stream(lines)
|
||||
#p lines
|
||||
|
||||
Reference in New Issue
Block a user