i2c  1.4.2
RoadNarrows Robotics I2C Package
rnr.i2c.i2c Class Reference

I2C class. More...

Public Member Functions

def __init__ (self)
 Class constructor.
 
def __del__ (self)
 Destructor.
 
def open (self, device)
 Open a I2C bus device. More...
 
def close (self)
 Close an open I2C bus device. More...
 
def is_open (self)
 Test if I2C bus is open. More...
 
def read (self, addr, count)
 Read data from an attached device connected to the open I2C bus. More...
 
def write (self, addr, buf)
 Write data to an attached device connected to the open I2C bus. More...
 
def transfer (self, addr, buf, count)
 Transfer data to an attached device connected to the open I2C bus and receive response. More...
 
def write_read (self, addr, buf, count)
 Write/read data to/from an attached device connected to the open I2C bus. More...
 
def check (self, addr)
 Test for the existence of a device with the given address. More...
 
def scan (self)
 Scan I2C bus for all attached devices. More...
 
def __init__ (self)
 Class constructor.
 
def __del__ (self)
 Destructor.
 
def open (self, device)
 Open a I2C bus device. More...
 
def close (self)
 Close an open I2C bus device. More...
 
def is_open (self)
 Test if I2C bus is open. More...
 
def read (self, addr, count)
 Read data from an attached device connected to the open I2C bus. More...
 
def write (self, addr, buf)
 Write data to an attached device connected to the open I2C bus. More...
 
def transfer (self, addr, buf, count)
 Transfer data to an attached device connected to the open I2C bus and receive response. More...
 
def write_read (self, addr, buf, count)
 Write/read data to/from an attached device connected to the open I2C bus. More...
 
def check (self, addr)
 Test for the existence of a device with the given address. More...
 
def scan (self)
 Scan I2C bus for all attached devices. More...
 
def __init__ (self)
 Class constructor.
 
def __del__ (self)
 Destructor.
 
def open (self, device)
 Open a I2C bus device. More...
 
def close (self)
 Close an open I2C bus device. More...
 
def is_open (self)
 Test if I2C bus is open. More...
 
def read (self, addr, count)
 Read data from an attached device connected to the open I2C bus. More...
 
def write (self, addr, buf)
 Write data to an attached device connected to the open I2C bus. More...
 
def transfer (self, addr, buf, count)
 Transfer data to an attached device connected to the open I2C bus and receive response. More...
 
def write_read (self, addr, buf, count)
 Write/read data to/from an attached device connected to the open I2C bus. More...
 
def check (self, addr)
 Test for the existence of a device with the given address. More...
 
def scan (self)
 Scan I2C bus for all attached devices. More...
 

Public Attributes

 m_device
 
 m_fd
 
 m_addr
 

Detailed Description

I2C class.

Definition at line 107 of file i2c.py.

Member Function Documentation

def rnr.i2c.i2c.check (   self,
  addr 
)

Test for the existence of a device with the given address.

Parameters
addrDevice address to check.
Returns
True or False.

Definition at line 278 of file i2c.py.

References rnr.i2c.i2c.m_addr, and rnr.i2c.i2c.m_fd.

Referenced by rnr.i2c.i2c.check(), and rnr.i2c.i2c.scan().

278  def check(self, addr):
279  rc = i2ccore.i2ccore_check(self.m_fd, self.m_addr, addr)
280  self.m_addr = addr
281  if rc == 1:
282  return True
283  else:
284  return False
285 
def check(self, addr)
Test for the existence of a device with the given address.
Definition: i2c.py:278
def rnr.i2c.i2c.check (   self,
  addr 
)

Test for the existence of a device with the given address.

Parameters
addrDevice address to check.
Returns
True or False.

Definition at line 278 of file i2c.py.

References rnr.i2c.i2c.check(), rnr.i2c.i2c.m_addr, and rnr.i2c.i2c.m_fd.

278  def check(self, addr):
279  rc = i2ccore.i2ccore_check(self.m_fd, self.m_addr, addr)
280  self.m_addr = addr
281  if rc == 1:
282  return True
283  else:
284  return False
285 
def check(self, addr)
Test for the existence of a device with the given address.
Definition: i2c.py:278
def rnr.i2c.i2c.check (   self,
  addr 
)

Test for the existence of a device with the given address.

Parameters
addrDevice address to check.
Returns
True or False.

Definition at line 278 of file i2c.py.

References rnr.i2c.i2c.check(), rnr.i2c.i2c.m_addr, and rnr.i2c.i2c.m_fd.

278  def check(self, addr):
279  rc = i2ccore.i2ccore_check(self.m_fd, self.m_addr, addr)
280  self.m_addr = addr
281  if rc == 1:
282  return True
283  else:
284  return False
285 
def check(self, addr)
Test for the existence of a device with the given address.
Definition: i2c.py:278
def rnr.i2c.i2c.close (   self)

Close an open I2C bus device.

Raises I2CException on error.

Definition at line 144 of file i2c.py.

References rnr.i2c.i2c.m_addr, rnr.i2c.i2c.m_device, and rnr.i2c.i2c.m_fd.

Referenced by rnr.i2c.i2c.__del__(), and rnr.i2c.i2c.close().

144  def close(self):
145  if self.m_fd >= 0:
146  rc = i2ccore.i2ccore_close(self.m_fd)
147  if rc < 0:
148  e = -rc
149  raise I2CException("%s: close(): %s: (errno=%d)." % \
150  (self.m_device, os.strerror(e), e))
151  self.m_device = ""
152  self.m_fd = -1
153  self.m_addr = I2C_ADDR_NONE
154 
m_device
Definition: i2c.py:112
def close(self)
Close an open I2C bus device.
Definition: i2c.py:144
no address
Definition: i2c.py:83
def rnr.i2c.i2c.close (   self)

Close an open I2C bus device.

Raises I2CException on error.

Definition at line 144 of file i2c.py.

References rnr.i2c.i2c.close(), rnr.i2c.i2c.m_addr, rnr.i2c.i2c.m_device, and rnr.i2c.i2c.m_fd.

144  def close(self):
145  if self.m_fd >= 0:
146  rc = i2ccore.i2ccore_close(self.m_fd)
147  if rc < 0:
148  e = -rc
149  raise I2CException("%s: close(): %s: (errno=%d)." % \
150  (self.m_device, os.strerror(e), e))
151  self.m_device = ""
152  self.m_fd = -1
153  self.m_addr = I2C_ADDR_NONE
154 
m_device
Definition: i2c.py:112
def close(self)
Close an open I2C bus device.
Definition: i2c.py:144
no address
Definition: i2c.py:83
def rnr.i2c.i2c.close (   self)

Close an open I2C bus device.

Raises I2CException on error.

Definition at line 144 of file i2c.py.

References rnr.i2c.i2c.close(), rnr.i2c.i2c.m_addr, rnr.i2c.i2c.m_device, and rnr.i2c.i2c.m_fd.

144  def close(self):
145  if self.m_fd >= 0:
146  rc = i2ccore.i2ccore_close(self.m_fd)
147  if rc < 0:
148  e = -rc
149  raise I2CException("%s: close(): %s: (errno=%d)." % \
150  (self.m_device, os.strerror(e), e))
151  self.m_device = ""
152  self.m_fd = -1
153  self.m_addr = I2C_ADDR_NONE
154 
m_device
Definition: i2c.py:112
def close(self)
Close an open I2C bus device.
Definition: i2c.py:144
no address
Definition: i2c.py:83
def rnr.i2c.i2c.is_open (   self)

Test if I2C bus is open.

Returns
True or False.

Definition at line 160 of file i2c.py.

References rnr.i2c.i2c.is_open(), and rnr.i2c.i2c.m_fd.

160  def is_open(self):
161  if self.m_fd < 0:
162  return False
163  else:
164  return True
165 
def is_open(self)
Test if I2C bus is open.
Definition: i2c.py:160
def rnr.i2c.i2c.is_open (   self)

Test if I2C bus is open.

Returns
True or False.

Definition at line 160 of file i2c.py.

References rnr.i2c.i2c.m_fd.

Referenced by rnr.i2c.i2c.is_open().

160  def is_open(self):
161  if self.m_fd < 0:
162  return False
163  else:
164  return True
165 
def is_open(self)
Test if I2C bus is open.
Definition: i2c.py:160
def rnr.i2c.i2c.is_open (   self)

Test if I2C bus is open.

Returns
True or False.

Definition at line 160 of file i2c.py.

References rnr.i2c.i2c.is_open(), and rnr.i2c.i2c.m_fd.

160  def is_open(self):
161  if self.m_fd < 0:
162  return False
163  else:
164  return True
165 
def is_open(self)
Test if I2C bus is open.
Definition: i2c.py:160
def rnr.i2c.i2c.open (   self,
  device 
)

Open a I2C bus device.

Raises I2CException on error.

Parameters
deviceI2C device name (e.g. /dev/i2c-3).

Definition at line 130 of file i2c.py.

References rnr.i2c.i2c.m_device, and rnr.i2c.i2c.m_fd.

Referenced by rnr.i2c.i2c.open().

130  def open(self, device):
131  fd = i2ccore.i2ccore_open(device)
132  if fd < 0:
133  e = -fd
134  raise I2CException("%s: open(): %s: (errno=%d)." % \
135  (device, os.strerror(e), e))
136  self.m_device = device
137  self.m_fd = fd;
138 
m_device
Definition: i2c.py:112
def open(self, device)
Open a I2C bus device.
Definition: i2c.py:130
no address
Definition: i2c.py:83
def rnr.i2c.i2c.open (   self,
  device 
)

Open a I2C bus device.

Raises I2CException on error.

Parameters
deviceI2C device name (e.g. /dev/i2c-3).

Definition at line 130 of file i2c.py.

References rnr.i2c.i2c.m_device, rnr.i2c.i2c.m_fd, and rnr.i2c.i2c.open().

130  def open(self, device):
131  fd = i2ccore.i2ccore_open(device)
132  if fd < 0:
133  e = -fd
134  raise I2CException("%s: open(): %s: (errno=%d)." % \
135  (device, os.strerror(e), e))
136  self.m_device = device
137  self.m_fd = fd;
138 
m_device
Definition: i2c.py:112
def open(self, device)
Open a I2C bus device.
Definition: i2c.py:130
no address
Definition: i2c.py:83
def rnr.i2c.i2c.open (   self,
  device 
)

Open a I2C bus device.

Raises I2CException on error.

Parameters
deviceI2C device name (e.g. /dev/i2c-3).

Definition at line 130 of file i2c.py.

References rnr.i2c.i2c.m_device, rnr.i2c.i2c.m_fd, and rnr.i2c.i2c.open().

130  def open(self, device):
131  fd = i2ccore.i2ccore_open(device)
132  if fd < 0:
133  e = -fd
134  raise I2CException("%s: open(): %s: (errno=%d)." % \
135  (device, os.strerror(e), e))
136  self.m_device = device
137  self.m_fd = fd;
138 
m_device
Definition: i2c.py:112
def open(self, device)
Open a I2C bus device.
Definition: i2c.py:130
no address
Definition: i2c.py:83
def rnr.i2c.i2c.read (   self,
  addr,
  count 
)

Read data from an attached device connected to the open I2C bus.

Raises I2CException on error.

Parameters
addrAttached device address.
countNumber of bytes to read.
Returns
List of bytes.

Definition at line 176 of file i2c.py.

References rnr.i2c.i2c.m_addr, rnr.i2c.i2c.m_device, and rnr.i2c.i2c.m_fd.

Referenced by rnr.i2c.i2c.read(), and rnr.i2c.i2c.write_read().

176  def read(self, addr, count):
177  try:
178  rbuf = basetypes.ByteBuf(count)
179  except AssertionError, inst:
180  raise I2CException("%s: read(0x%02x, ...): %s" % \
181  (self.m_device, addr, inst.message))
182  n = i2ccore.i2ccore_read(self.m_fd, self.m_addr, addr,
183  rbuf.getSwigObj(), basetypes.sizeof(rbuf))
184  if n < 0:
185  e = -n
186  raise I2CException("%s: read(0x%02x, ...): %s: (errno=%d)." % \
187  (self.m_device, addr, os.strerror(e), e))
188  self.m_addr = addr
189  try:
190  rbuf.copyFromSwigObj(n)
191  except AssertionError, inst:
192  raise I2CException("%s: read(0x%02x, ...): %s" % \
193  (self.m_device, addr, inst.message))
194  return rbuf.buf
195 
m_device
Definition: i2c.py:112
def read(self, addr, count)
Read data from an attached device connected to the open I2C bus.
Definition: i2c.py:176
no address
Definition: i2c.py:83
def rnr.i2c.i2c.read (   self,
  addr,
  count 
)

Read data from an attached device connected to the open I2C bus.

Raises I2CException on error.

Parameters
addrAttached device address.
countNumber of bytes to read.
Returns
List of bytes.

Definition at line 176 of file i2c.py.

References rnr.i2c.i2c.m_addr, rnr.i2c.i2c.m_device, rnr.i2c.i2c.m_fd, and rnr.i2c.i2c.read().

176  def read(self, addr, count):
177  try:
178  rbuf = basetypes.ByteBuf(count)
179  except AssertionError, inst:
180  raise I2CException("%s: read(0x%02x, ...): %s" % \
181  (self.m_device, addr, inst.message))
182  n = i2ccore.i2ccore_read(self.m_fd, self.m_addr, addr,
183  rbuf.getSwigObj(), basetypes.sizeof(rbuf))
184  if n < 0:
185  e = -n
186  raise I2CException("%s: read(0x%02x, ...): %s: (errno=%d)." % \
187  (self.m_device, addr, os.strerror(e), e))
188  self.m_addr = addr
189  try:
190  rbuf.copyFromSwigObj(n)
191  except AssertionError, inst:
192  raise I2CException("%s: read(0x%02x, ...): %s" % \
193  (self.m_device, addr, inst.message))
194  return rbuf.buf
195 
m_device
Definition: i2c.py:112
def read(self, addr, count)
Read data from an attached device connected to the open I2C bus.
Definition: i2c.py:176
no address
Definition: i2c.py:83
def rnr.i2c.i2c.read (   self,
  addr,
  count 
)

Read data from an attached device connected to the open I2C bus.

Raises I2CException on error.

Parameters
addrAttached device address.
countNumber of bytes to read.
Returns
List of bytes.

Definition at line 176 of file i2c.py.

References rnr.i2c.i2c.m_addr, rnr.i2c.i2c.m_device, rnr.i2c.i2c.m_fd, and rnr.i2c.i2c.read().

176  def read(self, addr, count):
177  try:
178  rbuf = basetypes.ByteBuf(count)
179  except AssertionError, inst:
180  raise I2CException("%s: read(0x%02x, ...): %s" % \
181  (self.m_device, addr, inst.message))
182  n = i2ccore.i2ccore_read(self.m_fd, self.m_addr, addr,
183  rbuf.getSwigObj(), basetypes.sizeof(rbuf))
184  if n < 0:
185  e = -n
186  raise I2CException("%s: read(0x%02x, ...): %s: (errno=%d)." % \
187  (self.m_device, addr, os.strerror(e), e))
188  self.m_addr = addr
189  try:
190  rbuf.copyFromSwigObj(n)
191  except AssertionError, inst:
192  raise I2CException("%s: read(0x%02x, ...): %s" % \
193  (self.m_device, addr, inst.message))
194  return rbuf.buf
195 
m_device
Definition: i2c.py:112
def read(self, addr, count)
Read data from an attached device connected to the open I2C bus.
Definition: i2c.py:176
no address
Definition: i2c.py:83
def rnr.i2c.i2c.scan (   self)

Scan I2C bus for all attached devices.

Returns
List of addresses of found devices.

Definition at line 291 of file i2c.py.

References rnr.i2c.i2c.check(), and rnr.i2c.i2c.scan().

291  def scan(self):
292  found = []
293  for addr in range(I2C_ADDR_LOW, I2C_ADDR_HIGH+1):
294  if self.check(addr):
295  found += [addr]
296  return found
297 
def check(self, addr)
Test for the existence of a device with the given address.
Definition: i2c.py:278
def scan(self)
Scan I2C bus for all attached devices.
Definition: i2c.py:291
def rnr.i2c.i2c.scan (   self)

Scan I2C bus for all attached devices.

Returns
List of addresses of found devices.

Definition at line 291 of file i2c.py.

References rnr.i2c.i2c.check().

Referenced by rnr.i2c.i2c.scan().

291  def scan(self):
292  found = []
293  for addr in range(I2C_ADDR_LOW, I2C_ADDR_HIGH+1):
294  if self.check(addr):
295  found += [addr]
296  return found
297 
def check(self, addr)
Test for the existence of a device with the given address.
Definition: i2c.py:278
def scan(self)
Scan I2C bus for all attached devices.
Definition: i2c.py:291
def rnr.i2c.i2c.scan (   self)

Scan I2C bus for all attached devices.

Returns
List of addresses of found devices.

Definition at line 291 of file i2c.py.

References rnr.i2c.i2c.check(), and rnr.i2c.i2c.scan().

291  def scan(self):
292  found = []
293  for addr in range(I2C_ADDR_LOW, I2C_ADDR_HIGH+1):
294  if self.check(addr):
295  found += [addr]
296  return found
297 
def check(self, addr)
Test for the existence of a device with the given address.
Definition: i2c.py:278
def scan(self)
Scan I2C bus for all attached devices.
Definition: i2c.py:291
def rnr.i2c.i2c.transfer (   self,
  addr,
  buf,
  count 
)

Transfer data to an attached device connected to the open I2C bus and receive response.

Note
Not all devices support optimize transfer. Use write_read() as an alternate is these cases.

Raises I2CException on error.

Parameters
addrAttached device address.
bufBuffer to transfer.
countNumber of bytes to read back.

Definition at line 232 of file i2c.py.

References rnr.i2c.i2c.m_addr, rnr.i2c.i2c.m_device, rnr.i2c.i2c.m_fd, and rnr.i2c.i2c.transfer().

232  def transfer(self, addr, buf, count):
233  try:
234  wbuf = basetypes.ByteBuf.Clone(buf)
235  wbuf.copyToSwigObj(len(wbuf))
236  rbuf = basetypes.ByteBuf(count)
237  except AssertionError, inst:
238  raise I2CException("%s: transfer(0x%02x, ...): %s" % \
239  (self.m_device, addr, inst.message))
240  rc = i2ccore.i2ccore_transfer(self.m_fd, self.m_addr, addr,
241  wbuf.getSwigObj(), len(wbuf),
242  rbuf.getSwigObj(), basetypes.sizeof(rbuf))
243  if rc < 0:
244  e = -rc
245  raise I2CException("%s: transfer(0x%02x, ...): %s: (errno=%d)." % \
246  (self.m_device, addr, os.strerror(e), e))
247  self.m_addr = addr
248  try:
249  rbuf.copyFromSwigObj(n)
250  except AssertionError, inst:
251  raise I2CException("%s: read(0x%02x, ...): %s" % \
252  (self.m_device, addr, inst.message))
253  return rbuf.buf
254 
m_device
Definition: i2c.py:112
def transfer(self, addr, buf, count)
Transfer data to an attached device connected to the open I2C bus and receive response.
Definition: i2c.py:232
no address
Definition: i2c.py:83
def rnr.i2c.i2c.transfer (   self,
  addr,
  buf,
  count 
)

Transfer data to an attached device connected to the open I2C bus and receive response.

Note
Not all devices support optimize transfer. Use write_read() as an alternate is these cases.

Raises I2CException on error.

Parameters
addrAttached device address.
bufBuffer to transfer.
countNumber of bytes to read back.

Definition at line 232 of file i2c.py.

References rnr.i2c.i2c.m_addr, rnr.i2c.i2c.m_device, and rnr.i2c.i2c.m_fd.

Referenced by rnr.i2c.i2c.transfer().

232  def transfer(self, addr, buf, count):
233  try:
234  wbuf = basetypes.ByteBuf.Clone(buf)
235  wbuf.copyToSwigObj(len(wbuf))
236  rbuf = basetypes.ByteBuf(count)
237  except AssertionError, inst:
238  raise I2CException("%s: transfer(0x%02x, ...): %s" % \
239  (self.m_device, addr, inst.message))
240  rc = i2ccore.i2ccore_transfer(self.m_fd, self.m_addr, addr,
241  wbuf.getSwigObj(), len(wbuf),
242  rbuf.getSwigObj(), basetypes.sizeof(rbuf))
243  if rc < 0:
244  e = -rc
245  raise I2CException("%s: transfer(0x%02x, ...): %s: (errno=%d)." % \
246  (self.m_device, addr, os.strerror(e), e))
247  self.m_addr = addr
248  try:
249  rbuf.copyFromSwigObj(n)
250  except AssertionError, inst:
251  raise I2CException("%s: read(0x%02x, ...): %s" % \
252  (self.m_device, addr, inst.message))
253  return rbuf.buf
254 
m_device
Definition: i2c.py:112
def transfer(self, addr, buf, count)
Transfer data to an attached device connected to the open I2C bus and receive response.
Definition: i2c.py:232
no address
Definition: i2c.py:83
def rnr.i2c.i2c.transfer (   self,
  addr,
  buf,
  count 
)

Transfer data to an attached device connected to the open I2C bus and receive response.

Note
Not all devices support optimize transfer. Use write_read() as an alternate is these cases.

Raises I2CException on error.

Parameters
addrAttached device address.
bufBuffer to transfer.
countNumber of bytes to read back.

Definition at line 232 of file i2c.py.

References rnr.i2c.i2c.m_addr, rnr.i2c.i2c.m_device, rnr.i2c.i2c.m_fd, and rnr.i2c.i2c.transfer().

232  def transfer(self, addr, buf, count):
233  try:
234  wbuf = basetypes.ByteBuf.Clone(buf)
235  wbuf.copyToSwigObj(len(wbuf))
236  rbuf = basetypes.ByteBuf(count)
237  except AssertionError, inst:
238  raise I2CException("%s: transfer(0x%02x, ...): %s" % \
239  (self.m_device, addr, inst.message))
240  rc = i2ccore.i2ccore_transfer(self.m_fd, self.m_addr, addr,
241  wbuf.getSwigObj(), len(wbuf),
242  rbuf.getSwigObj(), basetypes.sizeof(rbuf))
243  if rc < 0:
244  e = -rc
245  raise I2CException("%s: transfer(0x%02x, ...): %s: (errno=%d)." % \
246  (self.m_device, addr, os.strerror(e), e))
247  self.m_addr = addr
248  try:
249  rbuf.copyFromSwigObj(n)
250  except AssertionError, inst:
251  raise I2CException("%s: read(0x%02x, ...): %s" % \
252  (self.m_device, addr, inst.message))
253  return rbuf.buf
254 
m_device
Definition: i2c.py:112
def transfer(self, addr, buf, count)
Transfer data to an attached device connected to the open I2C bus and receive response.
Definition: i2c.py:232
no address
Definition: i2c.py:83
def rnr.i2c.i2c.write (   self,
  addr,
  buf 
)

Write data to an attached device connected to the open I2C bus.

Raises I2CException on error.

Parameters
addrAttached device address.
bufBuffer to write.

Definition at line 204 of file i2c.py.

References rnr.i2c.i2c.m_addr, rnr.i2c.i2c.m_device, rnr.i2c.i2c.m_fd, and rnr.i2c.i2c.write().

204  def write(self, addr, buf):
205  try:
206  wbuf = basetypes.ByteBuf.Clone(buf)
207  wbuf.copyToSwigObj(len(wbuf))
208  except AssertionError, inst:
209  raise I2CException("%s: write(0x%02x, ...): %s" % \
210  (self.m_device, addr, inst.message))
211  n = i2ccore.i2ccore_write(self.m_fd, self.m_addr, addr,
212  wbuf.getSwigObj(), len(wbuf))
213  if n < 0:
214  e = -n
215  raise I2CException("%s: write(0x%02x, ...): %s: (errno=%d)." % \
216  (self.m_device, addr, os.strerror(e), e))
217  self.m_addr = addr
218 
m_device
Definition: i2c.py:112
def write(self, addr, buf)
Write data to an attached device connected to the open I2C bus.
Definition: i2c.py:204
no address
Definition: i2c.py:83
def rnr.i2c.i2c.write (   self,
  addr,
  buf 
)

Write data to an attached device connected to the open I2C bus.

Raises I2CException on error.

Parameters
addrAttached device address.
bufBuffer to write.

Definition at line 204 of file i2c.py.

References rnr.i2c.i2c.m_addr, rnr.i2c.i2c.m_device, rnr.i2c.i2c.m_fd, and rnr.i2c.i2c.write().

204  def write(self, addr, buf):
205  try:
206  wbuf = basetypes.ByteBuf.Clone(buf)
207  wbuf.copyToSwigObj(len(wbuf))
208  except AssertionError, inst:
209  raise I2CException("%s: write(0x%02x, ...): %s" % \
210  (self.m_device, addr, inst.message))
211  n = i2ccore.i2ccore_write(self.m_fd, self.m_addr, addr,
212  wbuf.getSwigObj(), len(wbuf))
213  if n < 0:
214  e = -n
215  raise I2CException("%s: write(0x%02x, ...): %s: (errno=%d)." % \
216  (self.m_device, addr, os.strerror(e), e))
217  self.m_addr = addr
218 
m_device
Definition: i2c.py:112
def write(self, addr, buf)
Write data to an attached device connected to the open I2C bus.
Definition: i2c.py:204
no address
Definition: i2c.py:83
def rnr.i2c.i2c.write (   self,
  addr,
  buf 
)

Write data to an attached device connected to the open I2C bus.

Raises I2CException on error.

Parameters
addrAttached device address.
bufBuffer to write.

Definition at line 204 of file i2c.py.

References rnr.i2c.i2c.m_addr, rnr.i2c.i2c.m_device, and rnr.i2c.i2c.m_fd.

Referenced by rnr.i2c.i2c.write(), and rnr.i2c.i2c.write_read().

204  def write(self, addr, buf):
205  try:
206  wbuf = basetypes.ByteBuf.Clone(buf)
207  wbuf.copyToSwigObj(len(wbuf))
208  except AssertionError, inst:
209  raise I2CException("%s: write(0x%02x, ...): %s" % \
210  (self.m_device, addr, inst.message))
211  n = i2ccore.i2ccore_write(self.m_fd, self.m_addr, addr,
212  wbuf.getSwigObj(), len(wbuf))
213  if n < 0:
214  e = -n
215  raise I2CException("%s: write(0x%02x, ...): %s: (errno=%d)." % \
216  (self.m_device, addr, os.strerror(e), e))
217  self.m_addr = addr
218 
m_device
Definition: i2c.py:112
def write(self, addr, buf)
Write data to an attached device connected to the open I2C bus.
Definition: i2c.py:204
no address
Definition: i2c.py:83
def rnr.i2c.i2c.write_read (   self,
  addr,
  buf,
  count 
)

Write/read data to/from an attached device connected to the open I2C bus.

Raises I2CException on error.

Parameters
addrAttached device address.
bufBuffer to transfer.
countNumber of bytes to read back.
Returns
List of bytes.

Definition at line 267 of file i2c.py.

References rnr.i2c.i2c.read(), rnr.i2c.i2c.write(), and rnr.i2c.i2c.write_read().

267  def write_read(self, addr, buf, count):
268  self.write(addr, buf)
269  return self.read(addr, count)
270 
def write(self, addr, buf)
Write data to an attached device connected to the open I2C bus.
Definition: i2c.py:204
def read(self, addr, count)
Read data from an attached device connected to the open I2C bus.
Definition: i2c.py:176
def write_read(self, addr, buf, count)
Write/read data to/from an attached device connected to the open I2C bus.
Definition: i2c.py:267
def rnr.i2c.i2c.write_read (   self,
  addr,
  buf,
  count 
)

Write/read data to/from an attached device connected to the open I2C bus.

Raises I2CException on error.

Parameters
addrAttached device address.
bufBuffer to transfer.
countNumber of bytes to read back.
Returns
List of bytes.

Definition at line 267 of file i2c.py.

References rnr.i2c.i2c.read(), rnr.i2c.i2c.write(), and rnr.i2c.i2c.write_read().

267  def write_read(self, addr, buf, count):
268  self.write(addr, buf)
269  return self.read(addr, count)
270 
def write(self, addr, buf)
Write data to an attached device connected to the open I2C bus.
Definition: i2c.py:204
def read(self, addr, count)
Read data from an attached device connected to the open I2C bus.
Definition: i2c.py:176
def write_read(self, addr, buf, count)
Write/read data to/from an attached device connected to the open I2C bus.
Definition: i2c.py:267
def rnr.i2c.i2c.write_read (   self,
  addr,
  buf,
  count 
)

Write/read data to/from an attached device connected to the open I2C bus.

Raises I2CException on error.

Parameters
addrAttached device address.
bufBuffer to transfer.
countNumber of bytes to read back.
Returns
List of bytes.

Definition at line 267 of file i2c.py.

References rnr.i2c.i2c.read(), and rnr.i2c.i2c.write().

Referenced by rnr.i2c.i2c.write_read().

267  def write_read(self, addr, buf, count):
268  self.write(addr, buf)
269  return self.read(addr, count)
270 
def write(self, addr, buf)
Write data to an attached device connected to the open I2C bus.
Definition: i2c.py:204
def read(self, addr, count)
Read data from an attached device connected to the open I2C bus.
Definition: i2c.py:176
def write_read(self, addr, buf, count)
Write/read data to/from an attached device connected to the open I2C bus.
Definition: i2c.py:267

The documentation for this class was generated from the following file:
  • pyModules/build.x86_64/lib.linux-x86_64-2.7/rnr/i2c.py