Main Page | Class Hierarchy | Class List | File List | Class Members

MipBus Class Reference

Models a Mip bus. More...

#include <MipBus.h>

Inheritance diagram for MipBus:

IOInterfaceSerial EventInterface IOInterface List of all members.

Public Member Functions

 MipBus (IOInterfaceList *iolist, EventInterfaceList *evlist, const std::string &device, int baudrate=19200)
 Constructor.
virtual void OnDataArrival (unsigned char *data, int len)
 (abstract) This is called by OnInputAvailable() to process data that arrived.
virtual void OnClose ()
 (abstract) This is called when the filehandle is closed.
virtual void OnBeforeClose ()
 Called before a reset.
virtual void OnAfterOpen ()
 Called after a reset.
virtual void OnAfterOpenError ()
 Called after a reset.
void OnEvent ()
 This is called when the event timer expires.
void SetLogInterface (MipLogInterface *miplog)
 Sets the mip log interface.
MipLogInterfaceGetLogInterface ()
 Returns the mip log interface.
int GetMipDeviceMax ()
 Returns the maximum number of MipBus objects.
MipDeviceGetMipDevice (int i)
 Returns a Mip device.
bool AddMipDevice (MipDevice *mip)
 Adds a Mip device.
bool RemoveMipDevice (MipDevice *mip)
 Removes a Mip device.
bool IsIdle ()
 Returns whether the bus is idle (no pending command).
MipCommandGetCurrentCommand ()
 Returns the current command (or 0 if the bus is idle).
void SendNextCommand ()
 Sends the next command in the queue (if the bus is free and the queue is not empty).
void CancelCommand ()
 Aborts the current command.
void CancelAllCommands ()
 Aborts the current command and flushes the command queue.
void CheckOnline ()
 Checks the online status and opens or closes the serial port if necessary.
void Report (const std::string &name, std::ostream &out, int ccindent=0) const
 Writes a report of this object to the given stream. This is mainly useful for debugging.

Protected Member Functions

bool GetNextCommand (int from, int to)
 Asks a set of MipDevice objects for a new command and sets it as the current command if found.
void SendPacket (unsigned char *packet, int len) const
 Sends a packet.

Protected Attributes

MipDevicemMipDevice [mMipDeviceMax]
 Mip devices on the bus.
MipCommandmCurrentMipCommand
 The current Mip command.
int mTimeout
 Timeout in milliseconds.
int mNextMipDeviceIndex
 The next mip device to ask for a mip comand.
MipLogInterfacemMipLogInterface
 The log interface.

Static Protected Attributes

const int mMipDeviceMax = 128
 Maximum number of MipDevice objects.

Detailed Description

Models a Mip bus.

A Mip bus contains several MipDevice objects with are identified by their device ID.

Due to protocol restrictions (to avoid collisions), only one command can be sent over the same serial port (MIP bus) at a time. The next command can be sent only after a reply for the current command has been received. Therefore, commands are queued in the MipDevices. If several MipDevices are attached to the same MipBus, they are served in a round robin fashion.

The queue length is currently limited to 16 commands. Further MipCommands are silently discarded.


The documentation for this class was generated from the following file:
Generated on Wed Jun 1 09:19:07 2005 for libmip by doxygen 1.3.8