Class: Transmitter

Inherits:
Object
  • Object
show all
Defined in:
lib/javonet-ruby-sdk/core/transmitter/transmitter.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/transmitter/transmitter.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/transmitter/transmitter.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/Windows/X64/core/transmitter/transmitter.rb

Class Method Summary collapse

Class Method Details

.activate(license_key) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/javonet-ruby-sdk/core/transmitter/transmitter.rb', line 25

def self.activate(license_key)
  activation_result = TransmitterWrapper.Activate(license_key, "", "", "")
  if activation_result < 0
    error_message = get_native_error
    raise Exception.new "Javonet activation result: " + activation_result.to_s + ". Native error message: " + error_message
  else
    return activation_result
  end
end

.get_native_errorObject



35
36
37
# File 'lib/javonet-ruby-sdk/core/transmitter/transmitter.rb', line 35

def self.get_native_error
  TransmitterWrapper.GetNativeError
end

.send_command(message_byte_array, message_byte_array_len) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/javonet-ruby-sdk/core/transmitter/transmitter.rb', line 7

def self.send_command(message_byte_array, message_byte_array_len)
  message = FFI::MemoryPointer.new(:uchar, message_byte_array_len, true)
  message.put_array_of_uchar(0, message_byte_array)
  response_byte_array_len = TransmitterWrapper.SendCommand(message, message_byte_array_len)
  if response_byte_array_len > 0
    response = FFI::MemoryPointer.new(:uchar, response_byte_array_len, true)
    TransmitterWrapper.ReadResponse(response, response_byte_array_len)
    response_byte_array = response.get_array_of_uchar(0, response_byte_array_len)
    return response_byte_array
  elsif response_byte_array_len == 0
    error_message = "Response is empty"
    raise Exception.new error_message
  else
    error_message = get_native_error
    raise Exception.new "Javonet native error code: " + response_byte_array_len.to_s + ". " + error_message
  end
end

.set_config_source(config_path) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/javonet-ruby-sdk/core/transmitter/transmitter.rb', line 39

def self.set_config_source(config_path)
  set_config_result = TransmitterWrapper.SetConfigSource(config_path)
  if set_config_result < 0
    error_message = get_native_error
    raise Exception.new "Javonet set config source result: " + set_config_result.to_s + ". Native error message: " + error_message
  else
    return set_config_result
  end
end