Skip to content

Commit 95c4a16

Browse files
authored
Queue optimizations (#17)
1 parent f56fce9 commit 95c4a16

31 files changed

+1424
-1105
lines changed

README.md

Lines changed: 129 additions & 69 deletions
Large diffs are not rendered by default.

build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ fn main() {
4646
.allowlist_function("XcpPrint")
4747
.allowlist_function("XcpSetEpk")
4848
.allowlist_function("XcpSendTerminateSessionEvent")
49-
//
5049
//.allowlist_function("ApplXcpGetAddr")
5150
.allowlist_function("ApplXcpSetA2lName")
5251
.allowlist_function("ApplXcpRegisterCallbacks")

src/xcp/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ impl Xcp {
440440
// Initialize the XCP server and ETH transport layer in xcplib
441441
unsafe {
442442
// @@@@ UNSAFE - C library call
443-
if !xcplib::XcpEthServerInit(&ipv4_addr.octets() as *const u8, port, tl == XcpTransportLayer::Tcp, std::ptr::null_mut(), queue_size) {
443+
if !xcplib::XcpEthServerInit(&ipv4_addr.octets() as *const u8, port, tl == XcpTransportLayer::Tcp, queue_size) {
444444
return Err(XcpError::XcpLib("Error: XcpEthServerInit() failed"));
445445
}
446446
}

src/xcp/xcplib.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@ unsafe extern "C" {
2727
unsafe extern "C" {
2828
pub fn ApplXcpGetClock64() -> u64;
2929
}
30+
unsafe extern "C" {
31+
pub fn XcpEthTlGetInfo(isTCP: *mut bool, mac: *mut u8, addr: *mut u8, port: *mut u16);
32+
}
33+
unsafe extern "C" {
34+
#[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."]
35+
pub fn XcpEthServerInit(address: *const u8, port: u16, use_tcp: bool, measurement_queue_size: u32) -> bool;
36+
}
37+
unsafe extern "C" {
38+
#[doc = " Shutdown the XCP on Ethernet server instance."]
39+
pub fn XcpEthServerShutdown() -> bool;
40+
}
41+
unsafe extern "C" {
42+
#[doc = " Get the XCP on Ethernet server instance status.\n @return True if the server is running, otherwise false."]
43+
pub fn XcpEthServerStatus() -> bool;
44+
}
3045
unsafe extern "C" {
3146
pub fn ApplXcpRegisterCallbacks(
3247
cb_connect: ::std::option::Option<unsafe extern "C" fn() -> bool>,
@@ -46,18 +61,3 @@ unsafe extern "C" {
4661
unsafe extern "C" {
4762
pub fn ApplXcpSetA2lName(name: *const ::std::os::raw::c_char);
4863
}
49-
unsafe extern "C" {
50-
#[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."]
51-
pub fn XcpEthServerInit(address: *const u8, port: u16, use_tcp: bool, measurement_queue: *mut ::std::os::raw::c_void, measurement_queue_size: u32) -> bool;
52-
}
53-
unsafe extern "C" {
54-
#[doc = " Shutdown the XCP on Ethernet server instance."]
55-
pub fn XcpEthServerShutdown() -> bool;
56-
}
57-
unsafe extern "C" {
58-
#[doc = " Get the XCP on Ethernet server instance status.\n @return True if the server is running, otherwise false."]
59-
pub fn XcpEthServerStatus() -> bool;
60-
}
61-
unsafe extern "C" {
62-
pub fn XcpEthTlGetInfo(isTCP: *mut bool, mac: *mut u8, addr: *mut u8, port: *mut u16);
63-
}

tests/test_single_thread.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ fn task(cal_seg: CalSeg<CalPage1>) {
173173
}
174174

175175
debug!("Task terminated, loop counter = {}, {} changes observed", loop_counter, changes);
176-
xcp_println!("Task terminated, loop counter = {}, {} changes observed", loop_counter, changes);
177176
Xcp::disconnect_client(Xcp::get());
178177
}
179178

xcplib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ target_compile_options(xcplib
5454
-Wconversion
5555
-Werror
5656
-pedantic
57-
-Wshadow
57+
# -Wshadow
5858
)
5959

6060
# Example hello_xcp

0 commit comments

Comments
 (0)