pyP2Monitor  1.0.0
Monitor a P2 furnace activity reading data on serial port
 All Data Structures Namespaces Functions Variables Groups Pages
Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes
P2Furn Class Reference

Class implementing and handling the communication protocol with the furnace. More...

Public Member Functions

def __init__
 Instanciate a new P2Furn.
def restartSerialPort
 Restart the serial port.
def readMsg
 Read a message from the furnace.
def sendMsg
 Send a message to the furnace.
def runAuth
 Begin the authentication stage.
def runInit
 Run the initialisation stage.
def readData
 Run the data retrieve function.
def stop
 Close the serial port and reset stage lag.

Static Public Member Functions

def userId
 Return user hex value used to auth, given a user name.

Data Fields

 port
 The serial port filename.
 com
 The Associated P2Com object.
 curStage
 Stores the current stage.

Static Public Attributes

int STAGE_PREINIT = 0
 Before initialisation stage.
int STAGE_LOGIN = 1
 Authentication stage.
int STAGE_INIT = 2
 Initialisation exchange stage.
int STAGE_POST_INIT = 3
 After initialisation stage.
int STAGE_XCHG = 4
 Data exchange stage.
string USER_PLUMBER = "52610300007B"
 Plumber user.
string USER_NORMAL = "526103000001"
 Normal user.
string USER_NORMAL_ALT = "5261030000F3"
 Alternate normal user.
string USER_SERVICE = "52610300FFF9"
 Service user.

Detailed Description

Class implementing and handling the communication protocol with the furnace.

Definition at line 42 of file p2proto.py.

Constructor & Destructor Documentation

def __init__ (   self,
  serial_port 
)

Instanciate a new P2Furn.

Parameters
serial_portThe serial port filename (eg : /dev/ttyS0 )

Definition at line 83 of file p2proto.py.

Member Function Documentation

def readData (   self,
  waitdata = 0.5,
  storage = [("sqlite", "p2.db",
  dateFromP2 = False 
)

Run the data retrieve function.

Parameters
storageis a dict storing each data storage. Possible keys values are "sqlite" for sqlite db (value is the db file) or "file" for ascii dump (value is the dump file)
dateFromP2is True when we want the furnace date and time, if false we take the date and time from the computer
Exceptions
TypeErrorOn invalid type for parameter storage

Definition at line 299 of file p2proto.py.

def readMsg (   self)

Read a message from the furnace.

Simply call P2Com::read()

Returns
A P2Msg object
See Also
P2Com::read()

Definition at line 126 of file p2proto.py.

def runAuth (   self,
  user = USER_SERVICE,
  maxRetry = 3,
  retryWait = 10 
)

Begin the authentication stage.

Parameters
userIs the hexadecimal representation of the message to send to authenticate
maxRetryThe maximum number of retry before exit and consider as failed
retryWaitThe number of seconds between two authentication try
See Also
Furnace user's value
Exceptions
ExceptionOn invalid type for parameters

Definition at line 147 of file p2proto.py.

References P2Furn.curStage.

def runInit (   self)

Run the initialisation stage.

Exceptions
P2ComErrorOn protocol error

Definition at line 172 of file p2proto.py.

References P2Furn.curStage.

def sendMsg (   self,
  msg 
)

Send a message to the furnace.

Simply call P2Com::sendMsg()

Parameters
msgA P2Msg object
See Also
P2Com::sendMsg()

Definition at line 135 of file p2proto.py.

def userId (   user)
static

Return user hex value used to auth, given a user name.

Parameters
userthe user name
Returns
An hex string representing the user id

Definition at line 101 of file p2proto.py.

Field Documentation

curStage

Stores the current stage.

WARNING HERE WE SET OUR REPLY HEADER FROM AN INVALID/INCOMPLETE MESSAGE.

See Also
Communication stages

Definition at line 91 of file p2proto.py.

Referenced by P2Furn.runAuth(), P2Furn.runInit(), and P2Furn.stop().


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