2 * Copyright (c) 2004, Yannick Verschueren
\r
3 * Copyright (c) 2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
\r
4 * All rights reserved.
\r
6 * Redistribution and use in source and binary forms, with or without
\r
7 * modification, are permitted provided that the following conditions
\r
9 * 1. Redistributions of source code must retain the above copyright
\r
10 * notice, this list of conditions and the following disclaimer.
\r
11 * 2. Redistributions in binary form must reproduce the above copyright
\r
12 * notice, this list of conditions and the following disclaimer in the
\r
13 * documentation and/or other materials provided with the distribution.
\r
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
\r
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
\r
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
\r
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
\r
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
\r
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
\r
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
\r
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
\r
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\r
25 * POSSIBILITY OF SUCH DAMAGE.
\r
37 * Read the information contains in VBAS [JPP/JPT stream message header]
\r
38 * Store information (7 bits) in value
\r
41 unsigned int jpt_read_VBAS_info(unsigned int value)
\r
46 while ((elmt >> 7) == 1) {
\r
47 value = (value << 7);
\r
48 value |= (elmt & 0x7f);
\r
51 value = (value << 7);
\r
52 value |= (elmt & 0x7f);
\r
58 * Initialize the value of the message header structure
\r
61 void jpt_init_Msg_Header(jpt_msg_header_struct_t * header)
\r
63 header->Id = 0; /* In-class Identifier */
\r
64 header->last_byte = 0; /* Last byte information */
\r
65 header->Class_Id = 0; /* Class Identifier */
\r
66 header->CSn_Id = 0; /* CSn : index identifier */
\r
67 header->Msg_offset = 0; /* Message offset */
\r
68 header->Msg_length = 0; /* Message length */
\r
69 header->Layer_nb = 0; /* Auxiliary for JPP case */
\r
73 * Re-initialize the value of the message header structure
\r
75 * Only parameters always present in message header
\r
78 void jpt_reinit_Msg_Header(jpt_msg_header_struct_t * header)
\r
80 header->Id = 0; /* In-class Identifier */
\r
81 header->last_byte = 0; /* Last byte information */
\r
82 header->Msg_offset = 0; /* Message offset */
\r
83 header->Msg_length = 0; /* Message length */
\r
87 * Read the message header for a JPP/JPT - stream
\r
90 void jpt_read_Msg_Header(jpt_msg_header_struct_t * header)
\r
92 unsigned char elmt, Class = 0, CSn = 0;
\r
93 jpt_reinit_Msg_Header(header);
\r
100 /* See for Class and CSn */
\r
101 switch ((elmt >> 5) & 0x03) {
\r
103 fprintf(stderr, "Forbidden value encounter in message header !!\n");
\r
121 /* see information on bits 'c' [p 10 : A.2.1 general, ISO/IEC FCD 15444-9] */
\r
122 if (((elmt >> 4) & 0x01) == 1)
\r
123 header->last_byte = 1;
\r
125 /* In-class identifier */
\r
126 header->Id |= (elmt & 0x0f);
\r
127 if ((elmt >> 7) == 1)
\r
128 header->Id = jpt_read_VBAS_info(header->Id);
\r
134 header->Class_Id = 0;
\r
135 header->Class_Id = jpt_read_VBAS_info(header->Class_Id);
\r
142 header->CSn_Id = 0;
\r
143 header->CSn_Id = jpt_read_VBAS_info(header->CSn_Id);
\r
146 /* ----------------- */
\r
147 /* VBAS : Msg_offset */
\r
148 /* ----------------- */
\r
149 header->Msg_offset = jpt_read_VBAS_info(header->Msg_offset);
\r
151 /* ----------------- */
\r
152 /* VBAS : Msg_length */
\r
153 /* ----------------- */
\r
154 header->Msg_length = jpt_read_VBAS_info(header->Msg_length);
\r
159 if ((header->Class_Id & 0x01) == 1) {
\r
160 header->Layer_nb = 0;
\r
161 header->Layer_nb = jpt_read_VBAS_info(header->Layer_nb);
\r