Fix so we don't crash on unrecognized frame.

git-svn-id: http://op25.osmocom.org/svn/trunk@156 65a5c917-d112-43f1-993d-58c26a4786be
This commit is contained in:
stevie 2009-08-01 23:43:50 +00:00
parent 89d1872cbc
commit 42d5e3a660
2 changed files with 10 additions and 11 deletions

View File

@ -126,7 +126,7 @@ op25_decoder_ff::correlated()
return (errs <= 4);
}
bool
data_unit_sptr
op25_decoder_ff::identified()
{
static const size_t NID[] = {
@ -145,8 +145,7 @@ op25_decoder_ff::identified()
itpp::BCH bch(63, 16, 11,"6 3 3 1 1 4 1 3 6 7 2 3 5 4 5 3", true);
yank(d_frame_hdr, NID, NID_SZ, b, 0);
b = bch.decode(b);
bool identified(b != zeroes);
if(identified) {
if(b != zeroes) {
b = bch.encode(b);
yank_back(b, 0, d_frame_hdr, NID, NID_SZ);
d_data_unit = data_unit::make_data_unit(d_frame_hdr);
@ -154,7 +153,7 @@ op25_decoder_ff::identified()
data_unit_sptr null;
d_data_unit = null;
}
return identified;
return d_data_unit;
}
void

View File

@ -94,15 +94,15 @@ private:
/**
* Tests whether d_frame_header identifies a known data unit and if
* so sets d_data_unit to point to an appropriate instance. This
* method must only be called when the frame header is larger than
* 114 bits in length (the minimum size for a frame containing a
* NID).
* so sets d_data_unit to point to an appropriate instance and
* returns a pointer to it. This method must only be called when
* the frame header is larger than 114 bits in length (the minimum
* size for a frame containing a NID).
*
* \return true if the frame header identifies a known data unit;
* otherwise false.
* \return A data_unit_sptr pointing to an appropriate data_unit
* instance or NULL if the frame header is unrecognized.
*/
bool identified();
data_unit_sptr identified();
/**
* Handle a received symbol.