Main Page | Class List | File List | Class Members | File Members | Related Pages

src/lib/packet.c File Reference

Packet manipulation routines. More...

#include <linux/types.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <otto/otto.h>
#include <otto/packet.h>
#include <otto/device.h>
#include <otto/control.h>

Functions

const char _ID_[] __attribute__ ((unused))="$Id: packet.c,v 1.2 2004/07/07 22:07:12 alpha Exp $"
unsigned char crc8 (unsigned char reg, unsigned char data)
 Calculate an 8 bit CRC.

unsigned char compute_crc (unsigned char *bytes, int length)
 Calculate CRC for data buffer.

int otto_crc_calc (union otto_packet *pkt)
 Calculate CRC for a packet.

int otto_crc_valid (union otto_packet *pkt)
 Validate CRC for a packet.

int otto_findpacket (union otto_packet *pkt, int *start, int *len)
 Find a valid packet within a packet buffer.


Variables

const unsigned char CRC_INIT = 0xff
const unsigned char CRC_POLY = 0x1c
const unsigned char CRC_VALID = 0xc4


Detailed Description

Packet manipulation routines.

See SAE J1850, 7.4.1 (HS-3000, pp. 212-213) for checksum description.


Function Documentation

const char _ID_ [] __attribute__ (unused)   )  [static]
 

unsigned char compute_crc unsigned char *  bytes,
int  length
[static]
 

Calculate CRC for data buffer.

Parameters:
length  Buffer to compute CRC for Length of buffer

unsigned char crc8 unsigned char  reg,
unsigned char  data
[inline, static]
 

Calculate an 8 bit CRC.

Returns:
Result of CRC on indicated byte.
Parameters:
data  Partial product register Byte to accumulate CRC for

int otto_crc_calc union otto_packet pkt  ) 
 

Calculate CRC for a packet.

Returns:
Calculated checksum
Parameters:
pkt  Packet to compute CRC for

int otto_crc_valid union otto_packet pkt  ) 
 

Validate CRC for a packet.

Returns:
One if CRC is valid, zero if invalid, negative on error
Parameters:
pkt  Packet to validate CRC

int otto_findpacket union otto_packet pkt,
int *  start,
int *  len
 

Find a valid packet within a packet buffer.

Todo:
rework without so many memcpys
Parameters:
pkt  Partial packet buffer to search
start  [out] Start of first packet found
len  [out] Length of first packet found


Variable Documentation

const unsigned char CRC_INIT = 0xff [static]
 

const unsigned char CRC_POLY = 0x1c [static]
 

const unsigned char CRC_VALID = 0xc4 [static]
 


Generated on Thu Jul 8 19:26:07 2004 for OpenOtto by doxygen 1.3.7