Subversion Repositories HomeAutomation

Rev

Rev 997 | Rev 1021 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 997 Rev 999
Line 31... Line 31...
31
 
31
 
32
    //PKT 00060102 1 0 00 00 c4
32
    //PKT 00060102 1 0 00 00 c4
33
 
33
 
34
    rawHex = trim(rawHex, '\n');
34
    rawHex = trim(rawHex, '\n');
35
    rawHex = trim(rawHex);
35
    rawHex = trim(rawHex);
-
 
36
 
-
 
37
    myRawHex = rawHex;
36
 
38
 
37
    vector<string> parts = explode(" ", rawHex);
39
    vector<string> parts = explode(" ", rawHex);
38
 
40
 
39
    if (parts.size() < 2 || parts[0].compare("PKT") != 0)
41
    if (parts.size() < 2 || parts[0].compare("PKT") != 0)
40
    {
42
    {
41
        //slog << "Malformed can message received from canDaemon: \"" << rawHex << "\"\n";
43
        cout << "Malformed can message received from canDaemon: \"" << rawHex << "\"\n";
42
        throw new CanMessageException("Malformed can message received from canDaemon");
44
        throw new CanMessageException("Malformed can message received from canDaemon");
43
    }
45
    }
44
 
46
 
45
    string rawHeaderBin = hex2bin(parts[1]);
47
    string rawHeaderBin = hex2bin(parts[1]);
46
   
48
   
47
    try
49
    try
48
    {
50
    {
49
        myClassName = translator.lookupClassName(bin2uint(rawHeaderBin.substr(3, 4)));
51
        myClassName = translator.lookupClassName(bin2uint(rawHeaderBin.substr(3, 4)));
50
    }
52
    }
51
    catch (std::out_of_range& e)
53
    catch (std::out_of_range& e)
52
    {
54
    {
53
        cout << "DEBUG: setRaw exception: " << e.what() << "\n";
55
        cout << "DEBUG: setRaw exception: " << e.what() << "\n";
54
        cout << "DEBUG: A rawHeaderBin=" << rawHeaderBin << endl;
56
        cout << "DEBUG: A rawHeaderBin=" << rawHeaderBin << endl;
55
    }
57
    }
56
 
58
 
57
 
59
 
58
    if (myClassName == "")
60
    if (myClassName == "")
59
    {
61
    {
60
        myIsUnknown = true;
62
        myIsUnknown = true;
61
        return;
63
        return;
62
    }
64
    }
63
    else
65
    else
64
    {
66
    {
65
        myIsUnknown = false;
67
        myIsUnknown = false;
66
    }
68
    }
67
 
69
 
68
    string rawHexData = "";
70
    string rawHexData = "";
69
    for (int n = 4; n < parts.size(); n++)
71
    for (int n = 4; n < parts.size(); n++)
Line 72... Line 74...
72
    }
74
    }
73
 
75
 
74
    if (myClassName == "nmt")
76
    if (myClassName == "nmt")
75
    {
77
    {
76
        int commandId;
78
        int commandId;
77
 
79
 
78
        try
80
        try
79
        {
81
        {
80
            commandId = bin2uint(rawHeaderBin.substr(8, 8));
82
            commandId = bin2uint(rawHeaderBin.substr(8, 8));
81
        }
83
        }
82
        catch (std::out_of_range& e)
84
        catch (std::out_of_range& e)
Line 86... Line 88...
86
        }
88
        }
87
 
89
 
88
        myCommandName = translator.lookupNMTCommandName(commandId);
90
        myCommandName = translator.lookupNMTCommandName(commandId);
89
 
91
 
90
        myData = translator.translateNMTData(commandId, rawHexData);
92
        myData = translator.translateNMTData(commandId, rawHexData);
-
 
93
 
-
 
94
        myDirectionFlag = "";
-
 
95
        myModuleName = "";
-
 
96
        myModuleId = 0;
91
    }
97
    }
92
    else
98
    else
93
    {
99
    {
94
        try
100
        try
95
        {
101
        {
Line 278... Line 284...
278
    result += "             DirectionFlag: " + myDirectionFlag + "\n";
284
    result += "             DirectionFlag: " + myDirectionFlag + "\n";
279
    result += "             ModuleName: " + myModuleName + "\n";
285
    result += "             ModuleName: " + myModuleName + "\n";
280
    result += "             ModuleId: " + itos(myModuleId) + "\n";
286
    result += "             ModuleId: " + itos(myModuleId) + "\n";
281
    result += "             CommandName: " + myCommandName + "\n";
287
    result += "             CommandName: " + myCommandName + "\n";
282
    result += "             Data: " + getJSONData() + "\n";
288
    result += "             Data: " + getJSONData() + "\n";
-
 
289
    result += "             RawHex: " + myRawHex + "\n";
283
 
290
 
284
    return result;
291
    return result;
285
}
292
}