Sha256: 85f1aaa7e81d93a0316bde77f5c0bb3e88f638a61f50999ef1124f9248d2c4cb

Contents?: true

Size: 741 Bytes

Versions: 8

Compression:

Stored size: 741 Bytes

Contents

module Extface
  class Driver::RawSerial < Extface::RawDriver
    NAME = 'RAW Serial'.freeze
    has_serial_config
    
    def push(buffer)
      Extface.redis.rpush(:key, buffer)
      Extface.redis.subscribe(:extface) do |on|
        on.message do |event, data|
          @return = "event: #{event} data: #{data}\n\n"
          Extface.redis.unsubscribe
        end
      end
    end
    
    def receive(timeout = nil)
      list, element = Extface.redis.blpop(:key, :timeout => timeout)
      # Extface.redis.subscribe(:extface) do |on|
        # on.message do |event, data|
          # @return = "event: #{event} data: #{data}\n\n"
          # Extface.redis.unsubscribe
        # end
      # end
      return element
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
extface-0.1.0 app/models/extface/driver/raw_serial.rb
extface-0.0.8 app/models/extface/driver/raw_serial.rb
extface-0.0.7 app/models/extface/driver/raw_serial.rb
extface-0.0.6 app/models/extface/driver/raw_serial.rb
extface-0.0.5 app/models/extface/driver/raw_serial.rb
extface-0.0.3 app/models/extface/driver/raw_serial.rb
extface-0.0.2 app/models/extface/driver/raw_serial.rb
extface-0.0.1 app/models/extface/driver/raw_serial.rb