Class: OpenC3::Protocol
- Inherits:
-
Object
show all
- Defined in:
- lib/openc3/interfaces/protocols/protocol.rb
Overview
Base class for all OpenC3 protocols which defines a framework which must be implemented by a subclass.
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(allow_empty_data = nil) ⇒ Protocol
to be passed down to later Protocols (instead of returning :STOP). Can be true, false, or nil, where nil is interpreted as true unless the Protocol is the last Protocol of the chain.
36
37
38
39
40
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 36
def initialize(allow_empty_data = nil)
@interface = nil
@allow_empty_data = ConfigParser.handle_true_false_nil(allow_empty_data)
reset()
end
|
Instance Attribute Details
#allow_empty_data ⇒ Object
Returns the value of attribute allow_empty_data.
31
32
33
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 31
def allow_empty_data
@allow_empty_data
end
|
#interface ⇒ Object
Returns the value of attribute interface.
30
31
32
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 30
def interface
@interface
end
|
Instance Method Details
#connect_reset ⇒ Object
45
46
47
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 45
def connect_reset
reset()
end
|
#disconnect_reset ⇒ Object
49
50
51
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 49
def disconnect_reset
reset()
end
|
#post_write_interface(packet, data) ⇒ Object
81
82
83
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 81
def post_write_interface(packet, data)
return packet, data
end
|
#protocol_cmd(cmd_name, *cmd_args) ⇒ Object
85
86
87
88
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 85
def protocol_cmd(cmd_name, *cmd_args)
return false
end
|
#read_data(data) ⇒ Object
Ensure we have some data in case this is the only protocol
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 54
def read_data(data)
if data.length <= 0
if @allow_empty_data.nil?
if @interface and @interface.read_protocols[-1] == self
return :STOP
end
elsif !@allow_empty_data
return :STOP
end
end
data
end
|
#read_packet(packet) ⇒ Object
69
70
71
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 69
def read_packet(packet)
return packet
end
|
42
43
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 42
def reset
end
|
#write_data(data) ⇒ Object
77
78
79
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 77
def write_data(data)
return data
end
|
#write_packet(packet) ⇒ Object
73
74
75
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 73
def write_packet(packet)
return packet
end
|