- signaling the same link state multiple times fixed

- building as CMake library target added
This commit is contained in:
Wiesner András 2024-06-10 14:09:23 +02:00
parent bb7a8e1f16
commit 30f3e890ba
2 changed files with 38 additions and 16 deletions

View File

@ -1,7 +1,13 @@
target_sources( cmake_minimum_required(VERSION 3.15)
${CMAKE_PROJECT_NAME}
PUBLIC
set(ETHERLIB_TARGET etherlib)
if (ETHERLIB_TARGET_TAG)
set(ETHERLIB_TARGET "${ETHERLIB_TARGET}_${ETHERLIB_TARGET_TAG}")
message("Custom EtherLib target: ${ETHERLIB_TARGET}")
endif()
set(ETHERLIB_SRC
apps/http_server.c apps/http_server.c
apps/http_server.h apps/http_server.h
apps/ftp_server.c apps/ftp_server.c
@ -89,3 +95,18 @@ target_sources(
utils.c utils.c
utils.h utils.h
) )
add_library(${ETHERLIB_TARGET} STATIC ${ETHERLIB_SRC})
target_include_directories(${ETHERLIB_TARGET} PRIVATE ${ETHERLIB_INCLUDES})
target_compile_options(${ETHERLIB_TARGET} PRIVATE
${ETHERLIB_CPU_PARAMS}
-Wall
-Wextra
#-Wpedantic
-Wno-unused-parameter
$<$<COMPILE_LANGUAGE:ASM>:-x assembler-with-cpp -MMD -MP>
$<$<CONFIG:Debug>:-O0 -g3 -ggdb>
$<$<CONFIG:Release>:-Og -g0>
)
target_compile_definitions(${ETHERLIB_TARGET} PRIVATE ${ETHERLIB_COMPILE_DEFS})

View File

@ -97,8 +97,8 @@ static ThreadReturnType task_ethintf(ThreadParamType param) {
mq_pop(intf->rxQ); mq_pop(intf->rxQ);
// packet interception, if defined // packet interception, if defined
if (intf->interceptCb != NULL) { if (intf->interceptCb != NULL) {
intf->interceptCb(intf, &rawPckt); intf->interceptCb(intf, &rawPckt);
} }
// packet processing // packet processing
@ -112,23 +112,24 @@ static ThreadReturnType task_ethintf(ThreadParamType param) {
uint16_t speed = (event_data >> 2); uint16_t speed = (event_data >> 2);
bool prev_ls = ethinf_get_link_state(intf); // get previous link state bool prev_ls = ethinf_get_link_state(intf); // get previous link state
ethinf_set_link_state(intf, ls); // set new link state ethinf_set_link_state(intf, ls); // set new link state
if ((intf->dhcp != NULL) && (ls != prev_ls)) { // no double start! if ((intf->dhcp != NULL) && (ls != prev_ls)) { // no double start!
if (ls) { // if link is on if (ls) { // if link is on
dhcp_start(intf->dhcp); dhcp_start(intf->dhcp);
} else { // if link is off } else { // if link is off
dhcp_stop(intf->dhcp); dhcp_stop(intf->dhcp);
} }
// print generic message
MSG("ETH LINK: %s%s", (ls ? (ANSI_COLOR_BGREEN "UP ") : (ANSI_COLOR_BRED "DOWN\n")), ANSI_COLOR_RESET);
// print link properties
if (ls) {
MSG("(%u Mbps, %s duplex)\n", speed, duplex ? "FULL" : "HALF");
}
} }
// print generic message
MSG("ETH LINK: %s%s", (ls ? (ANSI_COLOR_BGREEN "UP ") : (ANSI_COLOR_BRED "DOWN\n")), ANSI_COLOR_RESET);
// print link properties
if (ls) {
MSG("(%u Mbps, %s duplex)\n", speed, duplex ? "FULL" : "HALF");
}
} break; } break;
case ETH_IIE_TRANSMIT_NOTIFY: { case ETH_IIE_TRANSMIT_NOTIFY: {
intf->ioDef->llTxTrigger(intf->ioDef, intf->txQ); intf->ioDef->llTxTrigger(intf->ioDef, intf->txQ);
@ -156,7 +157,7 @@ void ethinf_transmit(EthInterface *intf, const RawPckt *rawPckt) {
} }
// push packet onto the message queue // push packet onto the message queue
if (mq_push(intf->txQ, rawPckt)) { if (mq_push(intf->txQ, rawPckt)) {
ethinf_push_notification(intf, ETH_IIE_TRANSMIT_NOTIFY, 0); // notify processing thread of the peding transmit ethinf_push_notification(intf, ETH_IIE_TRANSMIT_NOTIFY, 0); // notify processing thread of the peding transmit
} else { } else {
ERROR("Interface TRANSMIT queue full, packet dropped!\n"); ERROR("Interface TRANSMIT queue full, packet dropped!\n");
@ -219,6 +220,6 @@ void ethinf_down(EthInterface *intf) {
intf->up = false; intf->up = false;
} }
void ethinf_set_intercept_callback(EthInterface * intf, EthIntfInterceptCb cb) { void ethinf_set_intercept_callback(EthInterface *intf, EthIntfInterceptCb cb) {
intf->interceptCb = cb; intf->interceptCb = cb;
} }