#include <MipBus.h>
Inheritance diagram for MipBus:
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. | |
MipLogInterface * | GetLogInterface () |
Returns the mip log interface. | |
int | GetMipDeviceMax () |
Returns the maximum number of MipBus objects. | |
MipDevice * | GetMipDevice (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). | |
MipCommand * | GetCurrentCommand () |
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 | |
MipDevice * | mMipDevice [mMipDeviceMax] |
Mip devices on the bus. | |
MipCommand * | mCurrentMipCommand |
The current Mip command. | |
int | mTimeout |
Timeout in milliseconds. | |
int | mNextMipDeviceIndex |
The next mip device to ask for a mip comand. | |
MipLogInterface * | mMipLogInterface |
The log interface. | |
Static Protected Attributes | |
const int | mMipDeviceMax = 128 |
Maximum number of MipDevice objects. |
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.