-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconvert.h
More file actions
54 lines (43 loc) · 1.86 KB
/
convert.h
File metadata and controls
54 lines (43 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
Copyright 2025 Neaera Consulting LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _CONVERT_H_
#define _CONVERT_H_
// For size_t
#include <stddef.h>
#include <stdint.h>
/**
Convert a byte array representation of a J2735 PDU from one encoding to another.
UPER format is rww bytes, not hex.
XER is 8-bit text.
@param pdu_name String with the J2735 PDU, e.g., "MessageFrame", "BasicSafetyMessage".
@param from_encoding String with the name of the encoding of the input ("XER", or "UPER").
@param to_encoding Target encoding for the output ("XER", or "UPER").
@param ibuf The input byte array in raw UPER, or XER text format.
@param ibuf_len The length of the input byte array.
@param obuf The buffer to store the output byte array.
@param max_obuf_len The maximum length of the output buffer.
@param err_buf A buffer to store any error messages, populated with the error if the return value is -1.
@param err_buf_len The size of the error buffer.
@return The length of the converted output byte array, or -1 if there was an error doing the conversion.
*/
int convert_bytes(
const char * pdu_name,
const char * from_encoding,
const char * to_encoding,
const uint8_t * ibuf,
size_t ibuf_len,
uint8_t * obuf,
size_t max_obuf_len,
char * err_buf,
size_t err_buf_len);
#endif