cosmos 4.2.3-java → 4.2.4-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/Manifest.txt +14 -1
  4. data/bin/dart_util +4 -0
  5. data/cosmos.gemspec +3 -2
  6. data/data/config/interface_modifiers.yaml +2 -1
  7. data/data/config/item_modifiers.yaml +1 -1
  8. data/data/config/parameter_modifiers.yaml +1 -1
  9. data/data/crc.txt +52 -45
  10. data/demo/config/data/crc.txt +6 -1
  11. data/demo/config/system/system.txt +1 -0
  12. data/demo/config/targets/DART/cmd_tlm/dart_cmds.txt +2 -0
  13. data/demo/config/targets/DART/cmd_tlm/dart_tlm.txt +40 -0
  14. data/demo/config/targets/DART/cmd_tlm_server.txt +6 -0
  15. data/demo/config/targets/DART/screens/status.txt +54 -0
  16. data/demo/config/targets/DART/target.txt +7 -0
  17. data/ext/cosmos/ext/structure/structure.c +16 -4
  18. data/lib/cosmos/dart/app/models/status.rb +2 -0
  19. data/lib/cosmos/dart/db/migrate/20180423205644_create_statuses.rb +22 -0
  20. data/lib/cosmos/dart/db/migrate/20180425211340_add_decom_state_index.rb +5 -0
  21. data/lib/cosmos/dart/db/migrate/20180509204705_remove_indexes.rb +29 -0
  22. data/lib/cosmos/dart/db/migrate/20180510160002_remove_timestamps_from_ples.rb +6 -0
  23. data/lib/cosmos/dart/db/migrate/20180511194944_add_packet_log_id_to_tables.rb +18 -0
  24. data/lib/cosmos/dart/db/schema.rb +15 -9
  25. data/lib/cosmos/dart/db/seeds.rb +8 -0
  26. data/lib/cosmos/dart/lib/dart_common.rb +5 -6
  27. data/lib/cosmos/dart/lib/dart_database_cleaner.rb +56 -5
  28. data/lib/cosmos/dart/lib/dart_decom_query.rb +108 -6
  29. data/lib/cosmos/dart/lib/dart_decommutator.rb +81 -22
  30. data/lib/cosmos/dart/lib/dart_importer.rb +44 -14
  31. data/lib/cosmos/dart/lib/dart_packet_log_writer.rb +73 -55
  32. data/lib/cosmos/dart/lib/dart_reducer_manager.rb +34 -3
  33. data/lib/cosmos/dart/lib/dart_reducer_worker_thread.rb +18 -7
  34. data/lib/cosmos/dart/processes/dart.rb +2 -1
  35. data/lib/cosmos/dart/processes/dart_decom_server.rb +2 -1
  36. data/lib/cosmos/dart/processes/dart_import.rb +1 -0
  37. data/lib/cosmos/dart/processes/dart_ingester.rb +1 -0
  38. data/lib/cosmos/dart/processes/dart_reducer.rb +1 -0
  39. data/lib/cosmos/dart/processes/dart_stream_server.rb +1 -0
  40. data/lib/cosmos/dart/processes/dart_util.rb +147 -0
  41. data/lib/cosmos/dart/processes/dart_worker.rb +1 -0
  42. data/lib/cosmos/dart/spec/dart/dart_database_cleaner_spec.rb +1 -1
  43. data/lib/cosmos/dart/spec/dart/dart_decom_query_spec.rb +1 -0
  44. data/lib/cosmos/dart/spec/dart/dart_decommutator_spec.rb +1 -0
  45. data/lib/cosmos/dart/spec/dart/dart_importer_spec.rb +1 -0
  46. data/lib/cosmos/dart/spec/dart/dart_packet_log_writer_spec.rb +39 -36
  47. data/lib/cosmos/dart/spec/dart/dart_reducer_manager_spec.rb +2 -1
  48. data/lib/cosmos/dart/spec/dart/dart_tcpip_server_interface_spec.rb +1 -2
  49. data/lib/cosmos/gui/widgets/dart_meta_frame.rb +13 -6
  50. data/lib/cosmos/interfaces.rb +1 -0
  51. data/lib/cosmos/interfaces/dart_status_interface.rb +91 -0
  52. data/lib/cosmos/interfaces/serial_interface.rb +5 -1
  53. data/lib/cosmos/io/json_drb.rb +7 -2
  54. data/lib/cosmos/io/json_drb_object.rb +11 -6
  55. data/lib/cosmos/io/json_rpc.rb +1 -0
  56. data/lib/cosmos/io/posix_serial_driver.rb +4 -2
  57. data/lib/cosmos/io/serial_driver.rb +8 -4
  58. data/lib/cosmos/io/win32_serial_driver.rb +4 -3
  59. data/lib/cosmos/packets/packet_config.rb +12 -2
  60. data/lib/cosmos/packets/structure_item.rb +1 -0
  61. data/lib/cosmos/script/extract.rb +4 -2
  62. data/lib/cosmos/streams/serial_stream.rb +10 -5
  63. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_config.rb +15 -15
  64. data/lib/cosmos/tools/cmd_tlm_server/gui/status_tab.rb +1 -1
  65. data/lib/cosmos/tools/table_manager/table_manager.rb +6 -4
  66. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_dart_thread.rb +5 -4
  67. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_logfile_thread.rb +1 -1
  68. data/lib/cosmos/top_level.rb +1 -1
  69. data/lib/cosmos/version.rb +4 -4
  70. data/spec/interfaces/serial_interface_spec.rb +13 -0
  71. data/spec/io/json_rpc_spec.rb +7 -0
  72. data/spec/io/win32_serial_driver_spec.rb +8 -0
  73. data/spec/packets/structure_item_spec.rb +6 -0
  74. data/spec/script/extract_spec.rb +5 -0
  75. data/spec/tools/cmd_tlm_server/cmd_tlm_server_config_spec.rb +10 -0
  76. metadata +17 -3
  77. data/lib/cosmos/dart/app/helpers/application_helper.rb +0 -2
@@ -21,6 +21,7 @@ describe DartReducerManager do
21
21
  before(:each) do
22
22
  DatabaseCleaner.strategy = :truncation
23
23
  DatabaseCleaner.clean
24
+ Rails.application.load_seed
24
25
  end
25
26
 
26
27
  def setup_ples(entries, delta_time)
@@ -48,13 +49,13 @@ describe DartReducerManager do
48
49
  end
49
50
  ples = 0
50
51
  count = 0
52
+ writer.shutdown
51
53
  while ples != (entries + 1) # SYSTEM META is the plus 1
52
54
  ples = PacketLogEntry.count
53
55
  sleep 0.1 # Allow the log writer to work
54
56
  count += 1
55
57
  break if count == 100 # 10s
56
58
  end
57
- writer.shutdown
58
59
  sleep 0.1
59
60
  expect(count).to be < 100
60
61
 
@@ -22,6 +22,7 @@ describe DartTcpipServerInterface do
22
22
  before(:each) do
23
23
  DatabaseCleaner.strategy = :truncation
24
24
  DatabaseCleaner.clean
25
+ Rails.application.load_seed
25
26
  end
26
27
 
27
28
  describe "initialize" do
@@ -48,8 +49,6 @@ describe DartTcpipServerInterface do
48
49
  @request.write('REQUEST', "BLAH")
49
50
  interface.write(@request)
50
51
  sleep 0.1
51
- # TODO: Why is the interface still connected?
52
- # expect(interface.connected?).to be false
53
52
  i.disconnect
54
53
 
55
54
  Dir["#{Cosmos::System.paths['DART_LOGS']}/*"].each do |file|
@@ -82,9 +82,14 @@ module Cosmos
82
82
 
83
83
  setLayout(@layout)
84
84
 
85
- @resize_timer = Qt::Timer.new
86
- @resize_timer.connect(SIGNAL('timeout()')) { update_meta_item_names() }
87
- @resize_timer.start(100)
85
+ Thread.new do
86
+ sleep(0.1)
87
+ Qt.execute_in_main_thread(true) do
88
+ unless self.disposed?
89
+ update_meta_item_names()
90
+ end
91
+ end
92
+ end
88
93
  end
89
94
 
90
95
  def meta_filters
@@ -100,9 +105,11 @@ module Cosmos
100
105
  server = JsonDRbObject.new(System.connect_hosts['DART_DECOM'], System.ports['DART_DECOM'])
101
106
  item_names = server.item_names("SYSTEM", "META")
102
107
  Qt.execute_in_main_thread do
103
- @meta_item_name.clear
104
- item_names.each do |item|
105
- @meta_item_name.addItem(item)
108
+ unless self.disposed?
109
+ @meta_item_name.clear
110
+ item_names.each do |item|
111
+ @meta_item_name.addItem(item)
112
+ end
106
113
  end
107
114
  end
108
115
  @got_meta_item_names = true
@@ -9,6 +9,7 @@ require 'cosmos/interfaces/tcpip_client_interface'
9
9
  require 'cosmos/interfaces/tcpip_server_interface'
10
10
  require 'cosmos/interfaces/udp_interface'
11
11
  require 'cosmos/interfaces/linc_interface'
12
+ require 'cosmos/interfaces/dart_status_interface'
12
13
 
13
14
  require 'cosmos/interfaces/protocols/protocol'
14
15
  require 'cosmos/interfaces/protocols/burst_protocol'
@@ -0,0 +1,91 @@
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2018 Ball Aerospace & Technologies Corp.
4
+ # All Rights Reserved.
5
+ #
6
+ # This program is free software; you can modify and/or redistribute it
7
+ # under the terms of the GNU General Public License
8
+ # as published by the Free Software Foundation; version 3 with
9
+ # attribution addendums as found in the LICENSE.txt
10
+
11
+ require 'cosmos/interfaces/interface'
12
+ require 'cosmos/io/json_drb_object'
13
+ require 'cosmos/utilities/sleeper'
14
+
15
+ module Cosmos
16
+
17
+ # Defines all the attributes and methods common to all interface classes
18
+ # used by COSMOS.
19
+ class DartStatusInterface < Interface
20
+ # Initialize default attribute values
21
+ def initialize(query_period = 20.0)
22
+ super()
23
+ @write_raw_allowed = false
24
+ @dart = nil
25
+ @first = true
26
+ @query_period = query_period.to_f
27
+ @query_time = nil
28
+ end
29
+
30
+ # Connects the interface to its target(s). Must be implemented by a
31
+ # subclass.
32
+ def connect
33
+ super()
34
+ @first = true
35
+ @status_packet = System.telemetry.packet('DART', 'STATUS').clone
36
+ @status_packet.write('PACKET_ID', 1)
37
+ @clear_errors_command = System.commands.packet('DART', 'CLEAR_ERRORS')
38
+ @sleeper = Sleeper.new
39
+ @dart = JsonDRbObject.new(System.connect_hosts['DART_DECOM'], System.ports['DART_DECOM'])
40
+ end
41
+
42
+ # Indicates if the interface is connected to its target(s) or not. Must be
43
+ # implemented by a subclass.
44
+ def connected?
45
+ if @dart
46
+ true
47
+ else
48
+ false
49
+ end
50
+ end
51
+
52
+ # Disconnects the interface from its target(s). Must be implemented by a
53
+ # subclass.
54
+ def disconnect
55
+ super()
56
+ @sleeper.cancel
57
+ @dart.disconnect if @dart
58
+ @dart = nil
59
+ end
60
+
61
+ def read_interface
62
+ canceled = false
63
+ unless @first
64
+ if @query_time
65
+ sleep_time = @query_period - (Time.now - @query_time)
66
+ canceled = @sleeper.sleep(sleep_time) if sleep_time > 0
67
+ end
68
+ @query_time = Time.now
69
+ end
70
+ @first = false
71
+ unless canceled
72
+ data = @dart.dart_status
73
+ write_interface_base(@dart.request_data.to_s)
74
+ read_interface_base(@dart.response_data.to_s)
75
+ data.each do |key, value|
76
+ @status_packet.write(key, value)
77
+ end
78
+ return @status_packet.buffer
79
+ else
80
+ return nil
81
+ end
82
+ end
83
+
84
+ def write_interface(data)
85
+ @dart.clear_errors
86
+ write_interface_base(@dart.request_data.to_s)
87
+ read_interface_base(@dart.response_data.to_s)
88
+ return nil
89
+ end
90
+ end
91
+ end
@@ -51,6 +51,7 @@ module Cosmos
51
51
  @write_raw_allowed = false unless @write_port_name
52
52
  @read_allowed = false unless @read_port_name
53
53
  @flow_control = :NONE
54
+ @data_bits = 8
54
55
  end
55
56
 
56
57
  # Creates a new {SerialStream} using the parameters passed in the constructor
@@ -63,7 +64,8 @@ module Cosmos
63
64
  @stop_bits,
64
65
  @write_timeout,
65
66
  @read_timeout,
66
- @flow_control
67
+ @flow_control,
68
+ @data_bits
67
69
  )
68
70
  super()
69
71
  end
@@ -75,6 +77,8 @@ module Cosmos
75
77
  case option_name.upcase
76
78
  when 'FLOW_CONTROL'
77
79
  @flow_control = option_values[0]
80
+ when 'DATA_BITS'
81
+ @data_bits = option_values[0].to_i
78
82
  end
79
83
  end
80
84
  end
@@ -17,8 +17,13 @@ require 'set'
17
17
  require 'cosmos/io/json_rpc'
18
18
  require 'cosmos/io/json_drb_rack'
19
19
  require 'rack/handler/puma'
20
- if RUBY_ENGINE == 'ruby' and %w(2.2.7 2.2.8 2.3.4 2.4.1).include? RUBY_VERSION
21
- require 'stopgap_13632'
20
+ if RUBY_ENGINE == 'ruby' and %w(2.2.7 2.2.8 2.2.9 2.2.10 2.3.4 2.4.1).include? RUBY_VERSION
21
+ begin
22
+ require 'stopgap_13632'
23
+ rescue Exception => err
24
+ msg = "Error loading stopgap. Make sure gem install stopgap_13632 succeeds: #{err.message}"
25
+ raise $!, msg, $!.backtrace
26
+ end
22
27
  end
23
28
 
24
29
  # Add methods to the Puma::Launcher and Puma::Single class so we can tell
@@ -32,6 +32,9 @@ module Cosmos
32
32
  # server.cmd(*args)
33
33
  #
34
34
  class JsonDRbObject
35
+ attr_reader :request_data
36
+ attr_reader :response_data
37
+
35
38
  # @param hostname [String] The name of the machine which has started
36
39
  # the JSON service
37
40
  # @param port [Integer] The port number of the JSON service
@@ -46,6 +49,8 @@ module Cosmos
46
49
  raise error
47
50
  end
48
51
  end
52
+ @request_data = ""
53
+ @response_data = ""
49
54
  @hostname = hostname
50
55
  @port = port
51
56
  @uri = URI("http://#{@hostname}:#{@port}")
@@ -117,25 +122,25 @@ module Cosmos
117
122
  request = JsonRpcRequest.new(method_name, method_params, @id)
118
123
  @id += 1
119
124
 
120
- request_data = request.to_json(:allow_nan => true)
125
+ @request_data = request.to_json(:allow_nan => true)
121
126
  begin
122
127
  STDOUT.puts "\nRequest:\n" if JsonDRb.debug?
123
- STDOUT.puts request_data if JsonDRb.debug?
128
+ STDOUT.puts @request_data if JsonDRb.debug?
124
129
  @request_in_progress = true
125
130
  headers = {'Content-Type' => 'application/json-rpc'}
126
131
  res = @http.post(@uri,
127
- :body => request_data,
132
+ :body => @request_data,
128
133
  :header => headers)
129
- response_data = res.body
134
+ @response_data = res.body
130
135
  @request_in_progress = false
131
136
  STDOUT.puts "Response:\n" if JsonDRb.debug?
132
- STDOUT.puts response_data if JsonDRb.debug?
137
+ STDOUT.puts @response_data if JsonDRb.debug?
133
138
  rescue => e
134
139
  disconnect()
135
140
  return false if first_try
136
141
  raise DRb::DRbConnError, e.message, e.backtrace
137
142
  end
138
- response_data
143
+ @response_data
139
144
  end
140
145
 
141
146
  def handle_response(response_data)
@@ -175,6 +175,7 @@ module Cosmos
175
175
 
176
176
  # @param other [JsonRpc] Another JsonRpc to compare hash values with
177
177
  def <=>(other)
178
+ return nil unless other.respond_to?(:as_json)
178
179
  self.as_json <=> other.as_json
179
180
  end
180
181
 
@@ -24,7 +24,8 @@ module Cosmos
24
24
  stop_bits = 1,
25
25
  write_timeout = 10.0,
26
26
  read_timeout = nil,
27
- flow_control = :NONE)
27
+ flow_control = :NONE,
28
+ data_bits = 8)
28
29
 
29
30
  # Convert Baud Rate into Termios constant
30
31
  begin
@@ -34,6 +35,7 @@ module Cosmos
34
35
  end
35
36
 
36
37
  # Verify Parameters
38
+ raise(ArgumentError, "Invalid Data Bits: #{data_bits}") unless [5,6,7,8].include?(data_bits)
37
39
  raise(ArgumentError, "Invalid parity: #{parity}") if parity and !SerialDriver::VALID_PARITY.include?(parity)
38
40
  raise(ArgumentError, "Invalid Stop Bits: #{stop_bits}") unless [1,2].include?(stop_bits)
39
41
  @write_timeout = write_timeout
@@ -53,7 +55,7 @@ module Cosmos
53
55
  iflags |= Termios::IGNPAR unless parity
54
56
  cflags = 0
55
57
  cflags |= Termios::CREAD # Enable receiver
56
- cflags |= Termios::CS8 # 8-bit bytes
58
+ cflags |= Termios.const_get("CS#{data_bits}") # data bits
57
59
  cflags |= Termios::CLOCAL # Ignore Modem Control Lines
58
60
  cflags |= Termios::CSTOPB if stop_bits == 2
59
61
  cflags |= Termios::PARENB if parity
@@ -32,14 +32,16 @@ module Cosmos
32
32
  # complete or nil to block
33
33
  # @param read_timeout [Float|nil] Number of seconds to wait for the read to
34
34
  # complete or nil to block
35
- # @param flow_control [Symbol] Currently supported :NONE and :RTSCTS
35
+ # @param flow_control [Symbol] Currently supported :NONE and :RTSCTS (default :NONE)
36
+ # @param data_bits [Integer] Number of data bits (default 8)
36
37
  def initialize(port_name,
37
38
  baud_rate,
38
39
  parity = :NONE,
39
40
  stop_bits = 1,
40
41
  write_timeout = 10.0,
41
42
  read_timeout = nil,
42
- flow_control = :NONE)
43
+ flow_control = :NONE,
44
+ data_bits = 8)
43
45
  raise(ArgumentError, "Invalid parity: #{parity}") unless VALID_PARITY.include? parity
44
46
  if Kernel.is_windows?
45
47
  @driver = Win32SerialDriver.new(port_name,
@@ -50,7 +52,8 @@ module Cosmos
50
52
  read_timeout,
51
53
  0.01,
52
54
  1000,
53
- flow_control)
55
+ flow_control,
56
+ data_bits)
54
57
  elsif RUBY_ENGINE == 'ruby'
55
58
  @driver = PosixSerialDriver.new(port_name,
56
59
  baud_rate,
@@ -58,7 +61,8 @@ module Cosmos
58
61
  stop_bits,
59
62
  write_timeout,
60
63
  read_timeout,
61
- flow_control)
64
+ flow_control,
65
+ data_bits)
62
66
  else
63
67
  @driver = nil # JRuby Serial on Linux not currently supported
64
68
  end
@@ -23,13 +23,14 @@ module Cosmos
23
23
  read_timeout = nil,
24
24
  read_polling_period = 0.01,
25
25
  read_max_length = 1000,
26
- flow_control = :NONE)
26
+ flow_control = :NONE,
27
+ data_bits = 8)
27
28
 
28
29
  # Verify Parameters
29
30
  port_name = '\\\\.\\' + port_name if port_name =~ /^COM[0-9]{2,3}$/
30
31
 
31
32
  raise(ArgumentError, "Invalid baud rate: #{baud_rate}") unless baud_rate.between?(Win32::BAUD_RATES[0], Win32::BAUD_RATES[-1])
32
-
33
+ raise(ArgumentError, "Invalid data bits: #{data_bits}") unless [5,6,7,8].include?(data_bits)
33
34
  raise(ArgumentError, "Invalid parity: #{parity}") if parity and !SerialDriver::VALID_PARITY.include?(parity)
34
35
  case parity
35
36
  when SerialDriver::ODD
@@ -64,7 +65,7 @@ module Cosmos
64
65
  # Configure the Comm Port - See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363214(v=vs.85).aspx
65
66
  dcb = Win32.get_comm_state(@handle)
66
67
  dcb.write('BaudRate', baud_rate)
67
- dcb.write('ByteSize', 8)
68
+ dcb.write('ByteSize', data_bits)
68
69
  dcb.write('Parity', parity)
69
70
  dcb.write('StopBits', stop_bits)
70
71
  if flow_control == :RTSCTS
@@ -395,8 +395,13 @@ module Cosmos
395
395
  # require should be performed in target.txt
396
396
  klass = params[0].filename_to_class_name.to_class
397
397
  raise parser.error("#{params[0].filename_to_class_name} class not found. Did you require the file in target.txt?", usage) unless klass
398
- @current_item.send("#{keyword.downcase}=".to_sym,
399
- klass.new(*params[1..(params.length - 1)]))
398
+ conversion = klass.new(*params[1..(params.length - 1)])
399
+ @current_item.send("#{keyword.downcase}=".to_sym, conversion)
400
+ if klass != ProcessorConversion and (conversion.converted_type.nil? or conversion.converted_bit_size.nil?)
401
+ msg = "Read Conversion #{params[0].filename_to_class_name} on item #{@current_item.name} does not specify converted type or bit size. Will not be supported by DART"
402
+ @warnings << msg
403
+ Logger.instance.warn @warnings[-1]
404
+ end
400
405
  rescue Exception => err
401
406
  raise parser.error(err)
402
407
  end
@@ -445,6 +450,11 @@ module Cosmos
445
450
  raise parser.error("Invalid converted_type: #{@converted_type}.") unless [:INT, :UINT, :FLOAT, :STRING, :BLOCK].include? @converted_type
446
451
  end
447
452
  @converted_bit_size = Integer(params[1]) if params[1]
453
+ if @converted_type.nil? or @converted_bit_size.nil?
454
+ msg = "Generic Conversion on item #{@current_item.name} does not specify converted type or bit size. Will not be supported by DART"
455
+ @warnings << msg
456
+ Logger.instance.warn @warnings[-1]
457
+ end
448
458
 
449
459
  # Define a set of limits for the current telemetry item
450
460
  when 'LIMITS'
@@ -203,6 +203,7 @@ module Cosmos
203
203
  # with different names or bit sizes are equal if they have the same bit
204
204
  # offset.
205
205
  def <=>(other_item)
206
+ return nil unless other_item.kind_of?(StructureItem)
206
207
  other_bit_offset = other_item.bit_offset
207
208
  other_bit_size = other_item.bit_size
208
209
 
@@ -45,7 +45,7 @@ module Cosmos
45
45
  target_name = first_half[0]
46
46
  cmd_name = first_half[1]
47
47
  cmd_params = {}
48
-
48
+
49
49
  begin
50
50
  packet = System.commands.packet(target_name, cmd_name).clone
51
51
  rescue
@@ -129,7 +129,9 @@ module Cosmos
129
129
  comparison_to_eval = nil
130
130
  return [target_name, packet_name, item_name, comparison_to_eval] if split_string.length == 3
131
131
  raise "ERROR: Check improperly specified: #{text}" if split_string.length < 4
132
- comparison_to_eval = split_string[3..(split_string.length - 1)].join(" ")
132
+ split_string = text.split(/ /) # Split on regex spaces to preserve spaces in comparison
133
+ index = split_string.index(item_name)
134
+ comparison_to_eval = split_string[(index + 1)..(split_string.length - 1)].join(" ")
133
135
  raise "ERROR: Use '==' instead of '=': #{text}" if split_string[3] == '='
134
136
  return [target_name, packet_name, item_name, comparison_to_eval]
135
137
  end
@@ -35,7 +35,8 @@ module Cosmos
35
35
  # complete. Pass nil to create no timeout. The {SerialDriver} will
36
36
  # continously try to read data until it has received data or an error
37
37
  # occurs.
38
- # @param flow_control [Symbol] Currently supported :NONE and :RTSCTS
38
+ # @param flow_control [Symbol] Currently supported :NONE and :RTSCTS (default :NONE)
39
+ # @param data_bits [Integer] Number of data bits (default 8)
39
40
  def initialize(write_port_name,
40
41
  read_port_name,
41
42
  baud_rate,
@@ -43,7 +44,8 @@ module Cosmos
43
44
  stop_bits,
44
45
  write_timeout,
45
46
  read_timeout,
46
- flow_control = :NONE)
47
+ flow_control = :NONE,
48
+ data_bits = 8)
47
49
  super()
48
50
 
49
51
  # The SerialDriver class will validate the parameters
@@ -56,7 +58,8 @@ module Cosmos
56
58
  @write_timeout = @write_timeout.to_f if @write_timeout
57
59
  @read_timeout = ConfigParser.handle_nil(read_timeout)
58
60
  @read_timeout = @read_timeout.to_f if @read_timeout
59
- @flow_control = flow_control.to_s.intern
61
+ @flow_control = flow_control.to_s.intern
62
+ @data_bits = data_bits.to_i
60
63
 
61
64
  if @write_port_name
62
65
  @write_serial_port = SerialDriver.new(@write_port_name,
@@ -65,7 +68,8 @@ module Cosmos
65
68
  @stop_bits,
66
69
  @write_timeout,
67
70
  @read_timeout,
68
- @flow_control)
71
+ @flow_control,
72
+ @data_bits)
69
73
  else
70
74
  @write_serial_port = nil
71
75
  end
@@ -79,7 +83,8 @@ module Cosmos
79
83
  @stop_bits,
80
84
  @write_timeout,
81
85
  @read_timeout,
82
- @flow_control)
86
+ @flow_control,
87
+ @data_bits)
83
88
  end
84
89
  else
85
90
  @read_serial_port = nil