tool/FoeCommand.cpp
author Florian Pose <fp@igh-essen.com>
Mon, 19 Jan 2009 14:46:55 +0000
branch1.4-foe
changeset 1709 63e4bc918640
parent 1708 fae3a1759126
child 1363 11c0b2caa253
permissions -rw-r--r--
Implemented going to bootstrap state BOOT.
1707
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*****************************************************************************
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 * $Id$
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 ****************************************************************************/
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
#include "FoeCommand.h"
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
#include "foe.h"
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
/*****************************************************************************/
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
FoeCommand::FoeCommand(const string &name, const string &briefDesc):
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
    Command(name, briefDesc)
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
{
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
}
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
/****************************************************************************/
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
1708
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    19
std::string FoeCommand::resultText(int result)
1707
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
{
1708
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    21
	switch (result) {
1707
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
		case FOE_BUSY:
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
			return "FOE_BUSY";
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
		case FOE_READY:
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
			return "FOE_READY";
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
		case FOE_IDLE:
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
			return "FOE_IDLE";
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
		case FOE_WC_ERROR:
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
			return "FOE_WC_ERROR";
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
		case FOE_RECEIVE_ERROR:
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
			return "FOE_RECEIVE_ERROR";
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
		case FOE_PROT_ERROR:
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
			return "FOE_PROT_ERROR";
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
		case FOE_NODATA_ERROR:
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
			return "FOE_NODATA_ERROR";
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
		case FOE_PACKETNO_ERROR:
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
			return "FOE_PACKETNO_ERROR";
1708
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    38
		case FOE_OPCODE_ERROR:
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    39
			return "FOE_OPCODE_ERROR";
1707
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
		case FOE_TIMEOUT_ERROR:
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
			return "FOE_TIMEOUT_ERROR";
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
		case FOE_SEND_RX_DATA_ERROR:
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
			return "FOE_SEND_RX_DATA_ERROR";
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
		case FOE_RX_DATA_ACK_ERROR:
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
			return "FOE_RX_DATA_ACK_ERROR";
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
		case FOE_ACK_ERROR:
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
			return "FOE_ACK_ERROR";
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
		case FOE_MBOX_FETCH_ERROR:
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
			return "FOE_MBOX_FETCH_ERROR";
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
		case FOE_READ_NODATA_ERROR:
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
			return "FOE_READ_NODATA_ERROR";
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
		case FOE_MBOX_PROT_ERROR:
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
			return "FOE_MBOX_PROT_ERROR";
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
		default:
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
			return "???";
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
	}
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
}
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
11ec009e145d Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
/****************************************************************************/
1708
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    60
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    61
std::string FoeCommand::errorText(int errorCode)
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    62
{
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    63
	switch (errorCode) {
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    64
        case 0x00008001:
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    65
            return "Not found.";
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    66
        case 0x00008002:
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    67
            return "Access denied.";
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    68
        case 0x00008003:
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    69
            return "Disk full.";
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    70
        case 0x00008004:
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    71
            return "Illegal.";
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    72
        case 0x00008005:
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    73
            return "Packet number wrong.";
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    74
        case 0x00008006:
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    75
            return "Already exists.";
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    76
        case 0x00008007:
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    77
            return "No user.";
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    78
        case 0x00008008:
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    79
            return "Bootstrap only.";
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    80
        case 0x00008009:
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    81
            return "Not Bootstrap.";
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    82
        case 0x0000800a:
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    83
            return "No rights.";
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    84
        case 0x0000800b:
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    85
            return "Program Error.";
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    86
		default:
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    87
			return "Unknown error code";
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    88
	}
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    89
}
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    90
fae3a1759126 Improved FoE.
Florian Pose <fp@igh-essen.com>
parents: 1707
diff changeset
    91
/****************************************************************************/