Class: Msp430Bsl::Uart::Ack

Inherits:
Object
  • Object
show all
Defined in:
lib/msp430_bsl/uart/ack.rb

Constant Summary collapse

MESSAGES =
{
  0x00 => { code: :ack, reason: 'ACK - Command correctly received' },
  0x51 => { code: :header_nok, reason: 'Header incorrect. The packet did not begin with the required 0x80 value' },
  0x52 => { code: :crc_nok, reason: 'Checksum incorrect. The packet did not have the correct checksum value' },
  0x53 => { code: :packet_size_zero, reason: 'Packet size zero. The size for the BSL core command was given as 0' },
  0x54 => { code: :packet_size_exceeds, reason: 'Packet size exceeds buffer. The packet size given is too big for the RX buffer' },
  0x55 => { code: :unkown_error, reason: 'Unknown error' },
  0x56 => { code: :unkown_baudrate, reason: 'Unknown baud rate. The supplied data for baud rate change is not a known value' }
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Ack

Returns a new instance of Ack.



19
20
21
22
23
24
# File 'lib/msp430_bsl/uart/ack.rb', line 19

def initialize(value)
  raise Exceptions::Ack::MessageNotSupported, value unless MESSAGES.include?(value)

  @value = value
  @message = MESSAGES[@value]
end

Instance Attribute Details

#messageObject

Returns the value of attribute message.



17
18
19
# File 'lib/msp430_bsl/uart/ack.rb', line 17

def message
  @message
end

#valueObject

Returns the value of attribute value.



17
18
19
# File 'lib/msp430_bsl/uart/ack.rb', line 17

def value
  @value
end

Instance Method Details

#ok?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/msp430_bsl/uart/ack.rb', line 26

def ok?
  value == 0x00
end

#reasonObject



30
31
32
# File 'lib/msp430_bsl/uart/ack.rb', line 30

def reason
  message[:reason]
end