discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] gmsk error


From: address@hidden
Subject: Re: [Discuss-gnuradio] gmsk error
Date: Mon, 5 Dec 2005 13:44:08 -0500

Very nice and short.

It looks like you can recursively call it to build your crc for the entire
message+header.

// Calculate the CRC for the header and message.
crc = sysCRC16(TNC_AX25_HEADER, sizeof(TNC_AX25_HEADER), 0xffff);
crc = sysCRC16(tncBuffer, tncLength, crc ^ 0xffff);

// Save the CRC in the message.
*tncBufferPnt++ = crc & 0xff;
*tncBufferPnt = (crc >> 8) & 0xff;

Could you recursively call it as you aquire the data and build up your
message?

Original Message:
-----------------
From:  address@hidden
Date: Mon, 5 Dec 2005 09:42:40 -0700 (MST)
To: address@hidden, address@hidden
Subject: Re: [Discuss-gnuradio] gmsk error


This is the whole thing.  You don't need a lookup table.

/**
 *    Calculate the CRC-16 CCITT of <b>buffer</b> that is <b>length</b> 
bytes long.
 *    The <b>crc</b> parameter allow the calculation on the CRC on 
multiple buffers.
 *
 *    @param buffer Pointer to data buffer.
 *    @param length number of bytes in data buffer
 *    @param crc starting value
 *
 *    @return CRC-16 of buffer[0 .. length]
 */
uint16_t sysCRC16(uint8_t *buffer, uint8_t length, uint16_t crc)
{
    uint8_t i, bit, value;

    for (i = 0; i < length; ++i) 
    {
        value = buffer[i];

        for (bit = 0; bit < 8; ++bit) 
        {
            crc ^= (value & 0x01);
            crc = ( crc & 0x01 ) ? ( crc >> 1 ) ^ 0x8408 : ( crc >> 1 );
            value = value >> 1;
        } // END for
    } // END for

    return crc ^ 0xffff;
}


On Mon, 5 Dec 2005, address@hidden wrote:

> On Thu, 1 Dec 2005 16:02:59 -0700 (MST), mgray wrote:
> > The following is a link to CRC16 for the PIC controller with similiar
> > memory limitations:
> 
> > http://www.kd7lmo.net/picobeacon_code.html
> 
> I looked at the code and all I could find was the function sysCRC16 in
> lines 1899-1916 of the PicoBeacon.c.
> 
> I could not find a lookup table.  Is there any look up table or is it just
> the codes in the lines I mentioned?
> 
> Mike
> 
> 
> 
> 
> 
> --------------------------------------------------------------------
> mail2web - Check your email from the web at
> http://mail2web.com/ .
> 
> 
> 
> 
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> 

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .






reply via email to

[Prev in Thread] Current Thread [Next in Thread]