Class: WiringPi::Serial

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

Instance Method Summary collapse

Constructor Details

#initialize(device = '/dev/ttyAMA0', baud = 9600) ⇒ Serial

Returns a new instance of Serial.



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

def initialize(device='/dev/ttyAMA0', baud=9600)

  @device = device
  @baud = baud

  @id = Wiringpi2.serialOpen(@device, @baud)

end

Instance Method Details

#serial_closeObject



17
18
19
20
21
22
# File 'lib/wiringpi/serial.rb', line 17

def serial_close

  Wiringpi2.serialClose(@id)
  @id = 0

end

#serial_data_availObject



36
37
38
39
40
# File 'lib/wiringpi/serial.rb', line 36

def serial_data_avail

  Wiringpi2.serialDataAvail(@id)

end

#serial_get_charObject



42
43
44
45
46
# File 'lib/wiringpi/serial.rb', line 42

def serial_get_char

  Wiringpi2.serialGetchar(@id)

end

#serial_put_char(char) ⇒ Object



24
25
26
27
28
# File 'lib/wiringpi/serial.rb', line 24

def serial_put_char(char)

  Wiringpi2.serialPutchar(@id, char)

end

#serial_puts(string) ⇒ Object



30
31
32
33
34
# File 'lib/wiringpi/serial.rb', line 30

def serial_puts(string)

  Wiringpi2.serialPuts(@id, string)

end