#!/mnt/run/tools/loran
print("-- Test i2c tools --")
local tmp = nil
local detect_bus = function(bus)
for chip = 0x0, 0x7F do
tmp = driver.i2cdev(bus, chip)
if tmp:init() == 0 then
if tmp:read_byte() >= 0 then
print(string.format("find i2c chip device %x ack: %d", chip,tmp:read_byte()))
tmp:release()
end
end
end
end
for bus = 0,1 do
bus = "/dev/i2c-"..bus
print("detect bus: "..bus)
detect_bus(bus)
end
#!/mnt/run/tools/loran
print("-- Test i2c tools --")
local tmp = nil
local detect_bus = function(bus)
for chip = 0x0, 0x7F do
tmp = driver.i2cdev(bus, chip)
if tmp:init() == 0 then
if tmp:read_byte() >= 0 then
print(string.format("find i2c chip device %x ack: %d", chip,tmp:read_byte()))
tmp:release()
end
end
end
end
for bus = 0,1 do
bus = "/dev/i2c-"..bus
print("detect bus: "..bus)
detect_bus(bus)
end