botsense  3.2.0
RoadNarrows Client-Server Proxied Services Framework
BotSense.bsI2C Namespace Reference

BotSense Swigged I2C Python Interface Module. More...

Classes

class  _object
 

Functions

def swig_import_helper ()
 
def bsI2CGetMsgName (pClient, hndVConn, uMsgId)
 
def bsI2CReqOpen (pClient, sDevName, bInitTrace)
 
def bsI2CReqClose (pClient, hndVConn)
 
def bsI2CReqRead (pClient, hndVConn, i2cAddr, uReadLen, rbuf)
 
def bsI2CReqWrite (pClient, hndVConn, i2cAddr, wbuf, uWriteLen)
 
def bsI2CReqTrans (pClient, hndVConn, i2cAddr, wbuf, uWriteLen, uReadLen, rbuf)
 
def bsI2CReqScan (pClient, hndVConn, bufScan, sizeScanBuf)
 
def new_i2cAddrArray (nelements)
 
def delete_i2cAddrArray (ary)
 
def i2cAddrArray_getitem (ary, index)
 
def i2cAddrArray_setitem (ary, index, value)
 
def I2CGetMsgName (client, hndVConn, msgId)
 
def I2CReqOpen (client, devName, trace=False)
 
def I2CReqClose (client, hndVConn)
 
def I2CReqRead (client, hndVConn, i2cAddr, readLen)
 
def I2CReqWrite (client, hndVConn, i2cAddr, wbuf)
 
def I2CReqTrans (client, hndVConn, i2cAddr, wbuf, readLen)
 
def I2CReqScan (client, hndVConn)
 

Variables

 BS_I2C_DEV_NAME_DFT = _bsI2C.BS_I2C_DEV_NAME_DFT
 
 BS_I2C_SERVER_MOD = _bsI2C.BS_I2C_SERVER_MOD
 
 BS_I2C_CLIENT_LIB = _bsI2C.BS_I2C_CLIENT_LIB
 
 bsI2CGetMsgName = _bsI2C.bsI2CGetMsgName
 
 bsI2CReqOpen = _bsI2C.bsI2CReqOpen
 
 bsI2CReqClose = _bsI2C.bsI2CReqClose
 
 bsI2CReqRead = _bsI2C.bsI2CReqRead
 
 bsI2CReqWrite = _bsI2C.bsI2CReqWrite
 
 bsI2CReqTrans = _bsI2C.bsI2CReqTrans
 
 bsI2CReqScan = _bsI2C.bsI2CReqScan
 
 new_i2cAddrArray = _bsI2C.new_i2cAddrArray
 
 delete_i2cAddrArray = _bsI2C.delete_i2cAddrArray
 
 i2cAddrArray_getitem = _bsI2C.i2cAddrArray_getitem
 
 i2cAddrArray_setitem = _bsI2C.i2cAddrArray_setitem
 
int I2CMaxNumOfScannedAddrs = 256
 

Detailed Description

BotSense Swigged I2C Python Interface Module.

Author
Robin Knight (robin.nosp@m..kni.nosp@m.ght@r.nosp@m.oadn.nosp@m.arrow.nosp@m.s.co.nosp@m.m)
Copyright:
(C) 2010. RoadNarrows LLC.
(http://www.roadnarrows.com)
All Rights Reserved

Function Documentation

def BotSense.bsI2C.I2CGetMsgName (   client,
  hndVConn,
  msgId 
)
Get the I2C message name.

    For each (virtual connection, message id) 2-tuple, there can be a known
    name string (provided the id is valid and an application provides the
    information).

    Parameters:
      client    - BotSenseTypes.BsClient instance.
      hndVConn  - Virtual connection handle (ignored).
      msgId     - I2C message id.

    Return:
      Returns message name string if it can be determined.
      Otherwise returns 'unknown'.

Definition at line 176 of file bsI2C.py.

176 def I2CGetMsgName(client, hndVConn, msgId):
177  """ Get the I2C message name.
178 
179  For each (virtual connection, message id) 2-tuple, there can be a known
180  name string (provided the id is valid and an application provides the
181  information).
182 
183  Parameters:
184  client - BotSenseTypes.BsClient instance.
185  hndVConn - Virtual connection handle (ignored).
186  msgId - I2C message id.
187 
188  Return:
189  Returns message name string if it can be determined.
190  Otherwise returns 'unknown'.
191  """
192  bsTypes.BsClient.ChkClient(client)
193  return bsI2CGetMsgName(client.pClient, hndVConn, msgId)
194 
def I2CGetMsgName(client, hndVConn, msgId)
Definition: bsI2C.py:176
def BotSense.bsI2C.I2CReqClose (   client,
  hndVConn 
)
Proxy server request to close client's proxied I2C bus device virtual
    connection.

    Raises a BotSenseError exception on failure.

    Parameters:
      client    - BotSenseTypes.BsClient instance.
      hndVConn  - Virtual connection handle.

Definition at line 215 of file bsI2C.py.

215 def I2CReqClose(client, hndVConn):
216  """ Proxy server request to close client's proxied I2C bus device virtual
217  connection.
218 
219  Raises a BotSenseError exception on failure.
220 
221  Parameters:
222  client - BotSenseTypes.BsClient instance.
223  hndVConn - Virtual connection handle.
224  """
225  bsTypes.BsClient.ChkClient(client)
226  rc = bsI2CReqClose(client.pClient, hndVConn)
227  bsError.ChkReturnIsOk(rc,
228  "Client %s: I2C Close request failed." % (client.AttrGetName()))
229 
def I2CReqClose(client, hndVConn)
Definition: bsI2C.py:215
def BotSense.bsI2C.I2CReqOpen (   client,
  devName,
  trace = False 
)
Proxy server request to establish a virtual connection to an 
    I2C bus device.

    Raises a BotSenseError exception on failure.

    Parameters:
      client    - BotSenseTypes.BsClient instance.
      devName   - Proxied I2C device name (e.g. /dev/i2c-0).
      trace     - Initial message tracing enable(true)/disable(false) state.

    Return
      New virtual connection handle.

Definition at line 195 of file bsI2C.py.

195 def I2CReqOpen(client, devName, trace=False):
196  """ Proxy server request to establish a virtual connection to an
197  I2C bus device.
198 
199  Raises a BotSenseError exception on failure.
200 
201  Parameters:
202  client - BotSenseTypes.BsClient instance.
203  devName - Proxied I2C device name (e.g. /dev/i2c-0).
204  trace - Initial message tracing enable(true)/disable(false) state.
205 
206  Return
207  New virtual connection handle.
208  """
209  bsTypes.BsClient.ChkClient(client)
210  hndVConn = bsI2CReqOpen(client.pClient, devName, trace)
211  bsError.ChkReturnIsNonNeg(hndVConn,
212  "Client %s: I2C Open request failed." % (client.AttrGetName()))
213  return hndVConn
214 
def I2CReqOpen(client, devName, trace=False)
Definition: bsI2C.py:195
def BotSense.bsI2C.I2CReqRead (   client,
  hndVConn,
  i2cAddr,
  readLen 
)
I2C request to read from a device attached to a proxied I2C bus.

    Raises a BotSenseError exception on failure.

    Parameters:
      client    - BotSenseTypes.BsClient instance.
      hndVConn  - Virtual connection handle.
      i2cAddr   - Address of attached device on the I2C bus.
      readLen   - Number of bytes to read.

    Return:
      Buffer list of read bytes.

Definition at line 230 of file bsI2C.py.

230 def I2CReqRead(client, hndVConn, i2cAddr, readLen):
231  """ I2C request to read from a device attached to a proxied I2C bus.
232 
233  Raises a BotSenseError exception on failure.
234 
235  Parameters:
236  client - BotSenseTypes.BsClient instance.
237  hndVConn - Virtual connection handle.
238  i2cAddr - Address of attached device on the I2C bus.
239  readLen - Number of bytes to read.
240 
241  Return:
242  Buffer list of read bytes.
243  """
244  bsTypes.BsClient.ChkClient(client)
245  rbytebuf = bsTypes.ByteBuf(readLen)
246  n = bsI2CReqRead(client.pClient, hndVConn, i2cAddr, readLen,
247  rbytebuf.getSwigObj())
248  bsError.ChkReturnIsNonNeg(n,
249  "Client %s: I2C Read request failed." % (client.AttrGetName()))
250  rbytebuf.copyFromSwigObj(n)
251  return rbytebuf.buf
252 
def I2CReqRead(client, hndVConn, i2cAddr, readLen)
Definition: bsI2C.py:230
def BotSense.bsI2C.I2CReqScan (   client,
  hndVConn 
)
I2C request to scan a proxied I2C bus for attached devices.

    Raises a BotSenseError exception on failure.

    Parameters:
      client    - BotSenseTypes.BsClient instance.
      hndVConn  - Virtual connection handle.

    Return:
      List of I2C address of discovered attached devices.

Definition at line 304 of file bsI2C.py.

304 def I2CReqScan(client, hndVConn):
305  """ I2C request to scan a proxied I2C bus for attached devices.
306 
307  Raises a BotSenseError exception on failure.
308 
309  Parameters:
310  client - BotSenseTypes.BsClient instance.
311  hndVConn - Virtual connection handle.
312 
313  Return:
314  List of I2C address of discovered attached devices.
315  """
316  bsTypes.BsClient.ChkClient(client)
317  swigObj = new_i2cAddrArray(I2CMaxNumOfScannedAddrs)
318  n = bsI2CReqScan(client.pClient, hndVConn, swigObj, I2CMaxNumOfScannedAddrs)
319  bsError.ChkReturnIsNonNeg(n,
320  "Client %s: I2C Read request failed." % (client.AttrGetName()))
321  addrs = []
322  for i in xrange(n):
323  addrs += [ i2cAddrArray_getitem(swigObj, i) ]
324  return addrs
325 
326 
327 # This file is compatible with both classic and new-style classes.
328 
329 
330 
def I2CReqScan(client, hndVConn)
Definition: bsI2C.py:304
def BotSense.bsI2C.I2CReqTrans (   client,
  hndVConn,
  i2cAddr,
  wbuf,
  readLen 
)
I2C request to execute a write-read transaction to a device
    attached to a proxied I2C bus.

    Raises a BotSenseError exception on failure.

    Parameters:
      client    - BotSenseTypes.BsClient instance.
      hndVConn  - Virtual connection handle.
      i2cAddr   - Address of attached device on the I2C bus.
      wbuf      - Write buffer.
      readLen   - Number of bytes to read.

    Return:
      Buffer list of read bytes.

Definition at line 276 of file bsI2C.py.

276 def I2CReqTrans(client, hndVConn, i2cAddr, wbuf, readLen):
277  """ I2C request to execute a write-read transaction to a device
278  attached to a proxied I2C bus.
279 
280  Raises a BotSenseError exception on failure.
281 
282  Parameters:
283  client - BotSenseTypes.BsClient instance.
284  hndVConn - Virtual connection handle.
285  i2cAddr - Address of attached device on the I2C bus.
286  wbuf - Write buffer.
287  readLen - Number of bytes to read.
288 
289  Return:
290  Buffer list of read bytes.
291  """
292  bsTypes.BsClient.ChkClient(client)
293  wbytebuf = bsTypes.ByteBuf.Clone(wbuf)
294  wbytebuf.copyToSwigObj(len(wbytebuf))
295  rbytebuf = bsTypes.ByteBuf(readLen)
296  n = bsI2CReqTrans(client.pClient, hndVConn, i2cAddr,
297  wbytebuf.getSwigObj(), len(wbytebuf),
298  readLen, rbytebuf.getSwigObj())
299  bsError.ChkReturnIsNonNeg(n,
300  "Client %s: I2C Transaction request failed." % (client.AttrGetName()))
301  rbytebuf.copyFromSwigObj(n)
302  return rbytebuf.buf
303 
def I2CReqTrans(client, hndVConn, i2cAddr, wbuf, readLen)
Definition: bsI2C.py:276
def BotSense.bsI2C.I2CReqWrite (   client,
  hndVConn,
  i2cAddr,
  wbuf 
)
I2C request to write to a device attached to a proxied I2C bus.

    Raises a BotSenseError exception on failure.

    Parameters:
      client    - BotSenseTypes.BsClient instance.
      hndVConn  - Virtual connection handle.
      i2cAddr   - Address of attached device on the I2C bus.
      wbuf      - Write buffer.

    Return:
      Number of bytes written.

Definition at line 253 of file bsI2C.py.

253 def I2CReqWrite(client, hndVConn, i2cAddr, wbuf):
254  """ I2C request to write to a device attached to a proxied I2C bus.
255 
256  Raises a BotSenseError exception on failure.
257 
258  Parameters:
259  client - BotSenseTypes.BsClient instance.
260  hndVConn - Virtual connection handle.
261  i2cAddr - Address of attached device on the I2C bus.
262  wbuf - Write buffer.
263 
264  Return:
265  Number of bytes written.
266  """
267  bsTypes.BsClient.ChkClient(client)
268  wbytebuf = bsTypes.ByteBuf.Clone(wbuf)
269  wbytebuf.copyToSwigObj(len(wbytebuf))
270  n = bsI2CReqWrite(client.pClient, hndVConn, i2cAddr, wbytebuf.getSwigObj(),
271  len(wbytebuf))
272  bsError.ChkReturnIsNonNeg(n,
273  "Client %s: I2C Write request failed." % (client.AttrGetName()))
274  return n
275 
def I2CReqWrite(client, hndVConn, i2cAddr, wbuf)
Definition: bsI2C.py:253