Skip to content

Commit fb5fecf

Browse files
authored
A2l macro improvements (#27)
* ApplXcpSetA2LName works with and without file extension .a2l, parameter is copied * XcpSetEPK parameter is copied, whitespace removed * xcpAppl.h removed, content moved to XCPlite.h * A2L generation optional * DaqXxxx macros moved to xcpLite.h * Warnings on Raspberry Pi fixed * OPTIMISATION_TYPE_DEFAULT * CANape projects
1 parent 76a79d9 commit fb5fecf

File tree

24 files changed

+1159
-676
lines changed

24 files changed

+1159
-676
lines changed

.vscode/settings.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
{
22
"files.associations": {
33
"stdatomic.h": "c"
4-
}
4+
},
5+
"cSpell.words": [
6+
"COMPU",
7+
"DONT",
8+
"Mainloop",
9+
"SBYTE",
10+
"SLONG",
11+
"UBYTE"
12+
]
513
}

build.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ fn main() {
3838
// DAQ
3939
.allowlist_function("XcpEvent")
4040
.allowlist_function("XcpEventExt")
41-
//.allowlist_function("XcpTriggerDaqEventAt")
42-
//.allowlist_function("XcpEventAt")
43-
//.allowlist_function("XcpEventExtAt")
4441
// Misc
4542
.allowlist_function("XcpSetLogLevel")
4643
.allowlist_function("XcpPrint")

src/xcp/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,12 +605,10 @@ impl Xcp {
605605
let name = std::ffi::CString::new(reg.get_app_name()).unwrap();
606606
// @@@@ UNSAFE - C library call
607607
xcplib::ApplXcpSetA2lName(name.as_ptr());
608-
std::mem::forget(name); // This memory is never dropped, it is moved to xcplib singleton
609608

610609
let epk = std::ffi::CString::new(reg.get_app_version()).unwrap();
611610
// @@@@ UNSAFE - C library call
612611
xcplib::XcpSetEpk(epk.as_ptr());
613-
std::mem::forget(epk); // This memory is never dropped, it is moved to xcplib singleton
614612
}
615613
}
616614
}

src/xcp/xcplib.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
/* automatically generated by rust-bindgen 0.71.1 */
22

3+
unsafe extern "C" {
4+
#[doc = " Initialize the XCP on Ethernet server instance.\n @pre User has called XcpInit.\n @param address Address to bind to.\n @param port Port to bind to.\n @param use_tcp Use TCP if true, otherwise UDP.\n @param measurement_queue Optional external memory to place the measurement queue.\n Pass NULL if server should allocate it.\n @param measurement_queue_size Measurement queue size in bytes. Includes the bytes occupied by the queue header.\n @return True on success, otherwise false."]
5+
pub fn XcpEthServerInit(address: *const u8, port: u16, use_tcp: bool, measurement_queue_size: u32) -> bool;
6+
}
7+
unsafe extern "C" {
8+
#[doc = " Shutdown the XCP on Ethernet server instance."]
9+
pub fn XcpEthServerShutdown() -> bool;
10+
}
11+
unsafe extern "C" {
12+
#[doc = " Get the XCP on Ethernet server instance status.\n @return True if the server is running, otherwise false."]
13+
pub fn XcpEthServerStatus() -> bool;
14+
}
15+
unsafe extern "C" {
16+
pub fn XcpEthTlGetInfo(isTCP: *mut bool, mac: *mut u8, addr: *mut u8, port: *mut u16);
17+
}
318
unsafe extern "C" {
419
pub fn XcpInit();
520
}
@@ -28,21 +43,6 @@ unsafe extern "C" {
2843
unsafe extern "C" {
2944
pub fn ApplXcpGetClock64() -> u64;
3045
}
31-
unsafe extern "C" {
32-
pub fn XcpEthTlGetInfo(isTCP: *mut bool, mac: *mut u8, addr: *mut u8, port: *mut u16);
33-
}
34-
unsafe extern "C" {
35-
#[doc = " Initialize the XCP on Ethernet server instance.\n @pre User has called XcpInit.\n @param address Address to bind to.\n @param port Port to bind to.\n @param use_tcp Use TCP if true, otherwise UDP.\n @param measurement_queue Optional external memory to place the measurement queue.\n Pass NULL if server should allocate it.\n @param measurement_queue_size Measurement queue size in bytes. Includes the bytes occupied by the queue header.\n @return True on success, otherwise false."]
36-
pub fn XcpEthServerInit(address: *const u8, port: u16, use_tcp: bool, measurement_queue_size: u32) -> bool;
37-
}
38-
unsafe extern "C" {
39-
#[doc = " Shutdown the XCP on Ethernet server instance."]
40-
pub fn XcpEthServerShutdown() -> bool;
41-
}
42-
unsafe extern "C" {
43-
#[doc = " Get the XCP on Ethernet server instance status.\n @return True if the server is running, otherwise false."]
44-
pub fn XcpEthServerStatus() -> bool;
45-
}
4646
unsafe extern "C" {
4747
pub fn ApplXcpRegisterCallbacks(
4848
cb_connect: ::std::option::Option<unsafe extern "C" fn() -> bool>,

tests/xcp_test_executor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ impl XcpDaqDecoder for DaqDecoder {
242242
if data.len() >= 32 {
243243
let mut o = 24;
244244
for i in 0..(data.len() - 24) / 8 {
245-
let test = (data[o + 0] as u64)
245+
let test = (data[o] as u64)
246246
| ((data[o + 1] as u64) << 8)
247247
| ((data[o + 2] as u64) << 16)
248248
| ((data[o + 3] as u64) << 24)
@@ -336,7 +336,7 @@ pub async fn test_daq(
336336
xcp_client.start_measurement().await.unwrap();
337337

338338
// Test for given time
339-
// Every 2ms check if measurment is still ok
339+
// Every 2ms check if measurement is still ok
340340
// Break on error
341341
let starttime = Instant::now();
342342
loop {

xcplib/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/build
22

3+
*.a2l.old
4+
35
/C_Demo.a2l
46
/hello_xcp.a2l
57
/struct_demo.a2l

0 commit comments

Comments
 (0)