Subversion Repositories Projects

Rev

Rev 211 | Rev 217 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
211 dhylands 1
/****************************************************************************
2
*
3
*   Copyright (c) 2009 Dave Hylands     <dhylands@gmail.com>
4
*
5
*   This program is free software; you can redistribute it and/or modify
6
*   it under the terms of the GNU General Public License version 2 as
7
*   published by the Free Software Foundation.
8
*
9
*   Alternatively, this software may be distributed under the terms of BSD
10
*   license.
11
*
12
*   See README and COPYING for more details.
13
*
14
****************************************************************************/
15
/**
16
*
17
*   @file   BioloidCommandLine.h
18
*
19
*   @brief  Implements a simulated bioloid bus which is useful for some
20
*           types of debugging.
21
*
22
*   The simulated bus prints out all of the packets that would be
23
*   sent over the bus.
24
*
25
****************************************************************************/
26
 
27
#if !defined( BIOLOIDCOMMANDLINE_H )
28
#define BIOLOIDCOMMANDLINE_H       /**< Include Guard                             */
29
 
30
// ---- Include Files -------------------------------------------------------
31
 
32
#include "bioloid-reg.h"
33
#include "BioloidBus.h"
34
#include "BioloidDevice.h"
35
#include "StrToken.h"
36
 
37
class BioloidCommandLine
38
{
39
public:
40
 
41
    //------------------------------------------------------------------------
42
    // Default constructor
43
 
44
    BioloidCommandLine();
45
 
46
    //------------------------------------------------------------------------
47
    // Destructor
48
 
49
    ~BioloidCommandLine();
50
 
51
    //------------------------------------------------------------------------
52
    // Processes one line of data
53
 
54
    bool ProcessLine( char *line );
55
 
56
    //------------------------------------------------------------------------
57
    // Registers a device type which has registers
58
 
59
    void RegisterDevices( BLD_DevType_t *devType );
60
 
61
    //------------------------------------------------------------------------
62
    // Sets the bus used to send commands.
63
 
64
    void SetBus( BioloidBus *bus )
65
    {
66
        m_bus = bus;
67
    }
68
 
69
private:
70
 
71
    //------------------------------------------------------------------------
213 dhylands 72
    // Adds an error string to the output string, if err contains the mask.
73
 
74
    void AddErrorStr( Bioloid::Error err, Bioloid::Error mask, char *str, size_t maxLen, const char *errStr );
75
 
76
    //------------------------------------------------------------------------
211 dhylands 77
    // Prints out register information
78
 
79
    void DumpRegInfo( BLD_DevType_t *devType );
80
 
81
    //------------------------------------------------------------------------
82
    // Parses an offset and some data
83
 
84
    bool ParseOffsetAndData( StrTokenizer &line, uint8_t *offset, uint8_t *numBytes, uint8_t *data, size_t maxLen );
85
 
86
    //------------------------------------------------------------------------
87
    // Parses a register name
88
 
89
    bool ParseRegisterName( StrTokenizer &line, BLD_DevType_t *devType, BLD_Reg_t **outReg );
90
 
213 dhylands 91
    //------------------------------------------------------------------------
92
    // Prints the error code and prints the results.
93
 
94
    void PrintError( Bioloid::Error err );
95
 
96
 
211 dhylands 97
    BioloidBus     *m_bus;
98
    BioloidDevice   m_device;
99
};
100
 
101
#endif  // BIOLOIDCOMMANDLINE_H