add reversed objects
This commit is contained in:
parent
b65846fbc4
commit
157f15629d
22
telegram.rb
22
telegram.rb
|
@ -27,6 +27,10 @@ class Telegram
|
||||||
OBJECTS[54] = "power supply control"
|
OBJECTS[54] = "power supply control"
|
||||||
OBJECTS[71] = "status and actual values"
|
OBJECTS[71] = "status and actual values"
|
||||||
OBJECTS[72] = "status and set values"
|
OBJECTS[72] = "status and set values"
|
||||||
|
OBJECTS[149] = "switch to bootlaoder?"
|
||||||
|
OBJECTS[150] = "unlock code 1?"
|
||||||
|
OBJECTS[151] = "unlock code 2?"
|
||||||
|
OBJECTS[152] = "write/check memory?"
|
||||||
OBJECTS[255] = "error"
|
OBJECTS[255] = "error"
|
||||||
# length of the object type
|
# length of the object type
|
||||||
LENGTHS = []
|
LENGTHS = []
|
||||||
|
@ -46,6 +50,10 @@ class Telegram
|
||||||
LENGTHS[54] = 2
|
LENGTHS[54] = 2
|
||||||
LENGTHS[71] = 6
|
LENGTHS[71] = 6
|
||||||
LENGTHS[72] = 6
|
LENGTHS[72] = 6
|
||||||
|
LENGTHS[149] = 4
|
||||||
|
LENGTHS[150] = 4
|
||||||
|
LENGTHS[151] = 4
|
||||||
|
LENGTHS[152] = 8
|
||||||
LENGTHS[255] = 1
|
LENGTHS[255] = 1
|
||||||
# possibles errors
|
# possibles errors
|
||||||
ERRORS = []
|
ERRORS = []
|
||||||
|
@ -256,7 +264,19 @@ class Telegram
|
||||||
status << ((@data[1]&(1<<7))==0 ? "over-temperature protection off" : "over-temperature protection on")
|
status << ((@data[1]&(1<<7))==0 ? "over-temperature protection off" : "over-temperature protection on")
|
||||||
str += status.compact*", "
|
str += status.compact*", "
|
||||||
str += ", voltage %: "+(@data[2,2].pack("C*").unpack("n")[0]/256.0).round(3).to_s
|
str += ", voltage %: "+(@data[2,2].pack("C*").unpack("n")[0]/256.0).round(3).to_s
|
||||||
str += ", current %: "+(@data[4,2].pack("C*").unpack("n")[0]/256.0).round(3).to_s
|
str += ", current01 %: "+(@data[4,2].pack("C*").unpack("n")[0]/256.0).round(3).to_s
|
||||||
|
when 152 # write memory
|
||||||
|
case @data[0]
|
||||||
|
when 0x33
|
||||||
|
str += "select section #{@data[1]}"
|
||||||
|
when 0x34
|
||||||
|
str += "flush?"
|
||||||
|
when 0x30
|
||||||
|
str += "end of write?"
|
||||||
|
else
|
||||||
|
str += "page #{@data[0]}: "
|
||||||
|
str += @data[1..-1].collect { |b| sprintf("%02X ",b) }.join
|
||||||
|
end
|
||||||
when 255
|
when 255
|
||||||
str += (ERRORS[@data[0]] or "unknown")
|
str += (ERRORS[@data[0]] or "unknown")
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue