Class: OpenC3::Protocol
- Inherits:
-
Object
show all
- Defined in:
- lib/openc3/interfaces/protocols/protocol.rb,
ext/openc3/ext/burst_protocol/burst_protocol.c
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.
37
38
39
40
41
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 37
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
|
Returns the value of attribute extra.
32
33
34
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 32
def
@extra
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
47
48
49
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 47
def connect_reset
reset()
end
|
#disconnect_reset ⇒ Object
51
52
53
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 51
def disconnect_reset
reset()
end
|
#post_write_interface(packet, data, extra = nil) ⇒ Object
83
84
85
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 83
def post_write_interface(packet, data, = nil)
return packet, data,
end
|
#protocol_cmd(cmd_name, *cmd_args) ⇒ Object
87
88
89
90
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 87
def protocol_cmd(cmd_name, *cmd_args)
return false
end
|
#read_data(data, extra = nil) ⇒ Object
Ensure we have some data in case this is the only protocol
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 56
def read_data(data, = nil)
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
return data,
end
|
#read_packet(packet) ⇒ Object
71
72
73
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 71
def read_packet(packet)
return packet
end
|
43
44
45
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 43
def reset
@extra = nil
end
|
#write_data(data, extra = nil) ⇒ Object
79
80
81
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 79
def write_data(data, = nil)
return data,
end
|
#write_packet(packet) ⇒ Object
75
76
77
|
# File 'lib/openc3/interfaces/protocols/protocol.rb', line 75
def write_packet(packet)
return packet
end
|