00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00017
00018
00019
#ifndef _OTTO_PACKET_H
00020
#define _OTTO_PACKET_H
00021
00022
00023
00024
00025
00026
00028 #define OTTO_PACKET_LENGTH_MAX 12
00029
00030
00032 struct otto_funcadr_sec_adr
00033 {
00034
00036 unsigned char id:6;
00037
00040 unsigned char c:1;
00041
00044 unsigned char q:1;
00045 };
00046
00048 struct otto_funcadr_ext_adr
00049 {
00051
enum
00052 {
00053
OTTO_EXTADR_COL_ALL = 0,
00054
OTTO_EXTADR_COL_LEFTSIDE = 1,
00055
OTTO_EXTADR_COL_DRIVER = 2,
00056
OTTO_EXTADR_COL_LEFTCENTER = 3,
00057
OTTO_EXTADR_COL_CENTER = 4,
00058
OTTO_EXTADR_COL_RIGHTCENTER = 5,
00059
OTTO_EXTADR_COL_PASSENGER = 6,
00060
OTTO_EXTADR_COL_RIGHTSIDE = 7,
00061 }
00062
col:3;
00063
00065
enum
00066 {
00067
OTTO_EXTADR_ROW_ALL = 0,
00068
OTTO_EXTADR_ROW_FRONT = 1,
00069
OTTO_EXTADR_ROW_HOOD = 2,
00070
OTTO_EXTADR_ROW_BULKHEAD = 3,
00071
OTTO_EXTADR_ROW_APILlAR = 4,
00072
OTTO_EXTADR_ROW_MID = 5,
00073
OTTO_EXTADR_ROW_TRUNK = 6,
00074
OTTO_EXTADR_ROW_REAR = 7,
00075 }
00076
row:3;
00077
00079
enum
00080 {
00081
OTTO_EXTADR_TYPE_GEOGRAPHICAL = 0,
00082
OTTO_EXTADR_TYPE_RESERVED_SAE = 1,
00083
OTTO_EXTADR_TYPE_RESERVED_MFG_2 = 2,
00084
OTTO_EXTADR_TYPE_RESERVED_MFG_3 = 3,
00085 }
00086
rr:2;
00087 };
00088
00090 union otto_funcadr_data
00091 {
00094
struct
00095
{
00096 }
00097
fmt0;
00098
00101
struct
00102
{
00103
unsigned char data[
OTTO_PACKET_LENGTH_MAX-1];
00104 }
00105
fmt1;
00106
00109
struct
00110
{
00111 struct otto_funcadr_sec_adr sec_id;
00112
unsigned char data[
OTTO_PACKET_LENGTH_MAX-2];
00113 }
00114 fmt2;
00115
00118
struct
00119
{
00120 struct otto_funcadr_sec_adr sec_id;
00121 struct otto_funcadr_ext_adr ext_id;
00122
unsigned char data[
OTTO_PACKET_LENGTH_MAX-3];
00123 }
00124 fmt3;
00125
00131
struct
00132
{
00133 unsigned char mode;
00134 unsigned char data[
OTTO_PACKET_LENGTH_MAX-2];
00135 }
00136 fmt4;
00137 };
00138
00140 union otto_phyadr_data
00141 {
00144
struct
00145
{
00146 }
00147
fmt0;
00148
00151
struct
00152
{
00153
unsigned char mode;
00154
unsigned char data[
OTTO_PACKET_LENGTH_MAX-2];
00155 }
00156
fmt1;
00157
00160
struct
00161
{
00162 unsigned char addr;
00163 unsigned char mode;
00164 unsigned char data[
OTTO_PACKET_LENGTH_MAX-3];
00165 }
00166 fmt2;
00167 };
00168
00170 union otto_packet
00171 {
00172
struct
00173
{
00174
unsigned char data[
OTTO_PACKET_LENGTH_MAX];
00175 int length;
00176 unsigned char nb;
00177 }
00178 raw;
00179
00180
struct
00181
{
00182
unsigned char id;
00183 unsigned char data[
OTTO_PACKET_LENGTH_MAX-1];
00184 }
00185 single;
00186
00187
union
00188
{
00189
struct
00190
{
00192 unsigned char id_lo:4;
00193
00195
enum
00196 {
00197
OTTO_PKTHDRCS_THREEBYTE = 0,
00198
OTTO_PKTHDRCS_ONEBYTE = 1,
00199 }
00200 h:1;
00201
00203 unsigned char id_hi:3;
00204 }
00205 hdr;
00206
00207
struct
00208
{
00209 union otto_funcadr_data data;
00210 }
00211 func;
00212
00213
struct
00214
{
00215 union otto_phyadr_data data;
00216 }
00217 phy;
00218 }
00219
consol1;
00220
00221
union
00222
{
00223
struct
00224
{
00227 unsigned char z:2;
00228
00230
enum
00231 {
00232 OTTO_PKTHDR_FUNCTIONAL = 0,
00233 OTTO_PKTHDR_PHYSICAL = 1,
00234 }
00235 y:1;
00236
00238
enum
00239 {
00240 OTTO_PKTHDR_IFRREQUIRED = 0,
00241 OTTO_PKTHDR_IFRDISALLOWED = 1,
00242 }
00243 k:1;
00244
00246
enum
00247 {
00248 OTTO_PKTHDR_THREEBYTE = 0,
00249 OTTO_PKTHDR_ONEBYTE = 1,
00250 }
00251 h:1;
00252
00255 unsigned char p:3;
00256 }
00257 first;
00258
00259
struct
00260
{
00261
struct
00262
{
00264
enum
00265 {
00266 OTTO_FUNCADR_TGTADR_COMMAND = 0,
00267 OTTO_FUNCADR_TGTADR_STATUS = 1,
00268 }
00269 w:1;
00270
00272 unsigned char id:7;
00273 }
00274 target;
00275
unsigned char source;
00276
00277 union otto_funcadr_data data;
00278 }
00279 func;
00280
00281
struct
00282
{
00283 unsigned char target;
00284 unsigned char source;
00285
00286 union otto_phyadr_data data;
00287 }
00288 phy;
00289 }
00290
consol3;
00291 };
00292
00293
00297
int
00298
otto_crc_calc(
00299
union otto_packet *pkt
00300 );
00301
00302
00306
int
00307
otto_crc_valid(
00308
union otto_packet *pkt
00309 );
00310
00311
00315
int
00316
otto_findpacket(
00317
union otto_packet *pkt,
00318
int *start,
00319
int *len
00320 );
00321
00322
00323
#endif