2 * Copyright (C) 2013 Freescale Semiconductor, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23 #include "NxMessageDecoder.h"
24 #include "NxMessage.h"
25 #include "AUXMessageProtocol.h"
26 #include "NxPacketDecoder.h"
27 #include "NxPacketSet.h"
32 NxMessageDecoder::NxMessageDecoder() :
35 protocol_
= new AUXMessageProtocol();
36 packet_decoder_
= new NxPacketDecoder();
37 packet_set_
= new NxPacketSet();
40 NxMessageDecoder::~NxMessageDecoder()
43 delete packet_decoder_
;
47 void NxMessageDecoder::verbose(bool verbose
)
50 protocol_
->verbose(verbose
);
51 packet_decoder_
->verbose(verbose
);
52 packet_set_
->verbose(verbose
);
55 // input data - the MDO/MSEO for each data beat
56 // output msg - pointer will be set if NxMessage is available
57 // return true if no error
58 bool NxMessageDecoder::accept(uint32_t data
, NxMessage
* &msg
)
60 AUXMessageProtocol::Outcome outcome
;
61 bool ret
= protocol_
->evaluate((data
& 3), outcome
);
63 ret
= protocol_
->act((data
>> 2), *packet_set_
);
65 if (outcome
== AUXMessageProtocol::ADD_LAST_MESSAGE
) {
66 // decode the NxPacketSet information into a NXMessage
68 cout
<< "END OF MESSAGE - Starting Decode."
71 ret
= packet_decoder_
->decode(*packet_set_
,
This page took 0.040366 seconds and 4 git commands to generate.