add unlock codes before and second object probing

This commit is contained in:
King Kévin 2015-08-24 16:11:49 +02:00
parent 157f15629d
commit 9e22fa618f
1 changed files with 27 additions and 24 deletions

View File

@ -7,34 +7,37 @@ require './telegram'
@serial = SerialPort.open("/dev/ttyACM0",{ baud: 115200, databits: 8, parity: SerialPort::ODD, stop_bit: 1, flow_control: SerialPort::NONE})
@serial.dtr = 1
=begin
# start queries
[0,1,6,8,9,19,71,2,3,4,38,39,50,51,54,71,72].each do |query|
telegram = Telegram.new(query)
puts telegram
@serial.write(telegram.pack)
data = @serial.readpartial(16+1+5)
def send(object,data=nil)
telegram_out = Telegram.new(object,data)
@serial.write(telegram_out.pack)
data = @serial.readpartial(1024)
telegram_in = nil
if data and !data.empty? then
telegram = Telegram.parse(data)
puts telegram
else
puts "empty"
end
end
=end
256.times do |object|
telegram = Telegram.new(object)
@serial.write(telegram.pack)
data = @serial.readpartial(16+1+5)
if data and !data.empty? then
#puts data.unpack("C*").collect { |b| sprintf("%02X ",b) }.join
telegram = Telegram.parse(data)
if telegram.object==0xff and telegram.data[0]!=0x07 then
puts "#{object}: #{telegram.to_s}"
begin
telegram_in = Telegram.parse(data)
if telegram_in.object==0xff and telegram_in.data[0]==0x07 then
puts "object not defined"
else
puts "< "+telegram_out.pack.unpack("C*").collect { |b| sprintf("%02X ",b) }.join
puts telegram_out
puts "> "+data.unpack("C*").collect { |b| sprintf("%02X ",b) }.join
puts telegram_in
end
rescue Exception => e
puts "> "+data.unpack("C*").collect { |b| sprintf("%02X ",b) }.join
puts e.to_s
end
else
puts "empty"
end
end
send(54,[0x10,0x10]) # enable remote control
send(150,[0x1F,0x35,0x57,0xBC]) # give access permissions (hidden command)
send(151,[0xFF,0xAA,0x88,0x44]) # give access permissions (hidden command)
256.times do |object|
puts "object: #{object}"
send(object)
end