Public Member Functions | Public Attributes | Private Member Functions | List of all members
I2C_sniffer.sniffer Class Reference

Public Member Functions

def __init__ (self, pi, SCL, SDA, set_as_inputs=True)
 
def cancel (self)
 

Public Attributes

 bit
 
 byte
 
 cbA
 
 cbB
 
 FALLING
 
 gSCL
 
 gSDA
 
 in_data
 
 oldSCL
 
 oldSDA
 
 pi
 
 RISING
 
 STEADY
 
 transact
 

Private Member Functions

def _cb (self, gpio, level, tick)
 
def _parse (self, SCL, SDA)
 

Detailed Description

A class to passively monitor activity on an I2C bus.  This should
work for an I2C bus running at 100kbps or less.  You are unlikely
to get any usable results for a bus running any faster.

Definition at line 7 of file I2C_sniffer.py.

Constructor & Destructor Documentation

def I2C_sniffer.sniffer.__init__ (   self,
  pi,
  SCL,
  SDA,
  set_as_inputs = True 
)
Instantiate with the Pi and the gpios for the I2C clock
and data lines.

If you are monitoring one of the Raspberry Pi buses you
must set set_as_inputs to False so that they remain in
I2C mode.

The pigpio daemon should have been started with a higher
than default sample rate.

For an I2C bus rate of 100Kbps sudo pigpiod -s 2 should work.

A message is printed for each I2C transaction formatted with
"[" for the START
"XX" two hex characters for each data byte
"+" if the data is ACKd, "-" if the data is NACKd
"]" for the STOP

E.g. Reading the X, Y, Z values from an ADXL345 gives:

[A6+32+]
[A7+01+FF+F2+FF+06+00-]

Definition at line 14 of file I2C_sniffer.py.

Member Function Documentation

def I2C_sniffer.sniffer._cb (   self,
  gpio,
  level,
  tick 
)
private
Check which line has altered state (ignoring watchdogs) and
call the parser with the new state.

Definition at line 119 of file I2C_sniffer.py.

def I2C_sniffer.sniffer._parse (   self,
  SCL,
  SDA 
)
private
Accumulate all the data between START and STOP conditions
into a string and output when STOP is detected.

Definition at line 63 of file I2C_sniffer.py.

def I2C_sniffer.sniffer.cancel (   self)
Cancel the I2C callbacks.

Definition at line 141 of file I2C_sniffer.py.

Member Data Documentation

I2C_sniffer.sniffer.bit

Definition at line 50 of file I2C_sniffer.py.

I2C_sniffer.sniffer.byte

Definition at line 49 of file I2C_sniffer.py.

I2C_sniffer.sniffer.cbA

Definition at line 60 of file I2C_sniffer.py.

I2C_sniffer.sniffer.cbB

Definition at line 61 of file I2C_sniffer.py.

I2C_sniffer.sniffer.FALLING

Definition at line 44 of file I2C_sniffer.py.

I2C_sniffer.sniffer.gSCL

Definition at line 41 of file I2C_sniffer.py.

I2C_sniffer.sniffer.gSDA

Definition at line 42 of file I2C_sniffer.py.

I2C_sniffer.sniffer.in_data

Definition at line 48 of file I2C_sniffer.py.

I2C_sniffer.sniffer.oldSCL

Definition at line 51 of file I2C_sniffer.py.

I2C_sniffer.sniffer.oldSDA

Definition at line 52 of file I2C_sniffer.py.

I2C_sniffer.sniffer.pi

Definition at line 40 of file I2C_sniffer.py.

I2C_sniffer.sniffer.RISING

Definition at line 45 of file I2C_sniffer.py.

I2C_sniffer.sniffer.STEADY

Definition at line 46 of file I2C_sniffer.py.

I2C_sniffer.sniffer.transact

Definition at line 54 of file I2C_sniffer.py.


The documentation for this class was generated from the following file:


cob_hand_bridge
Author(s): Mathias Lüdtke
autogenerated on Tue Oct 20 2020 03:35:58