Class: BetaBrite::Serial

Inherits:
Base
  • Object
show all
Defined in:
lib/betabrite/serial.rb

Constant Summary

Constants inherited from Base

Base::CR, Base::DLE, Base::EOT, Base::ESC, Base::ETX, Base::HEADER, Base::MEMORY_CODE, Base::SIGN_TYPE, Base::STRING, Base::STX

Instance Attribute Summary

Attributes inherited from Base

#dots_files, #memory, #sleep_time, #string_files, #text_files

Instance Method Summary collapse

Methods inherited from Base

#allocate, #clear_memory!, #dotsfile, #memory_message, #message, #stringfile, #textfile

Constructor Details

#initialize(serialport) ⇒ Serial

Returns a new instance of Serial.



3
4
5
6
# File 'lib/betabrite/serial.rb', line 3

def initialize(serialport)
  @serialport = serialport
  super()
end

Instance Method Details

#write!Object



18
19
20
21
22
23
24
25
26
# File 'lib/betabrite/serial.rb', line 18

def write!
  sp = SerialPort.new(@serialport, 9600, 8, 1, SerialPort::NONE)
  characters = 0
  message.split(//).each do |chr|
    sleep 1 if characters < 6
    sp.write chr
    characters += 1
  end
end

#write_memory!Object



8
9
10
11
12
13
14
15
16
# File 'lib/betabrite/serial.rb', line 8

def write_memory!
  sp = SerialPort.new(@serialport, 9600, 8, 1, SerialPort::NONE)
  characters = 0
  memory_message.split(//).each do |chr|
    sleep 1 if characters < 6
    sp.write chr
    characters += 1
  end
end