fixed the bug of OPCUA free buffer and uart not response

This commit is contained in:
wlyu 2022-03-30 18:49:08 +08:00
parent 057a6d6bb4
commit bb5f82d303
4 changed files with 30 additions and 13 deletions

View File

@ -17970,6 +17970,11 @@ UA_SecureChannel_close(UA_SecureChannel *channel) {
/* Set the status to closed */
channel->state = UA_SECURECHANNELSTATE_CLOSED;
if(channel->connection == 0)
{
ua_error("ua: [%s] conn null return!\n", __func__);
return;
}
/* Detach from the connection and close the connection */
if(channel->connection) {
if(channel->connection->state != UA_CONNECTIONSTATE_CLOSED)
@ -43658,6 +43663,7 @@ UA_Client_delete(UA_Client* client) {
UA_Client_clear(client);
UA_ClientConfig_clear(&client->config);
UA_free(client);
client = NULL;
ua_run_flag = 0;
}
@ -43978,7 +43984,7 @@ receiveResponse(UA_Client *client, void *response, const UA_DataType *responseTy
"Receiving the response failed with StatusCode %s",
UA_StatusCode_name(retval));
ua_print("ua: [%s] state %d ret %d %#x\n", __func__, client->channel.state, retval, retval);
closeSecureChannel(client);
// closeSecureChannel(client);
retval = UA_STATUSCODE_BADCONNECTIONCLOSED;
break;
}
@ -44246,7 +44252,7 @@ UA_Client_run_iterate(UA_Client *client, UA_UInt32 timeout) {
client->sessionState < UA_SESSIONSTATE_ACTIVATED) {
retval = connectIterate(client, timeout);
notifyClientState(client);
ua_print("lw: [%s] ret %d timeout %d state %d ch %d\n", __func__, retval, timeout,
ua_print("lw: [%s] ret %x timeout %d state %d ch %d\n", __func__, retval, timeout,
client->sessionState, client->channel.state);
return retval;
}
@ -70301,16 +70307,25 @@ UA_ServerConfig_setDefaultWithSecurityPolicies(UA_ServerConfig *conf,
UA_Client * UA_Client_new() {
UA_ClientConfig config;
UA_Client *ret = NULL;
if(ua_run_flag)
{
return NULL;
}
memset(&config, 0, sizeof(UA_ClientConfig));
config.logger.log = UA_Log_Stdout_log;
config.logger.context = NULL;
config.logger.clear = UA_Log_Stdout_clear;
ua_run_flag = 1;
return UA_Client_newWithConfig(&config);
ret = UA_Client_newWithConfig(&config);
if(ret)
{
ua_run_flag = 1;
}
return ret;
}
UA_StatusCode
@ -71603,6 +71618,12 @@ typedef struct TCPClientConnection {
static void
ClientNetworkLayerTCP_close(UA_Connection *connection) {
if(connection == NULL)
{
ua_error("connection NULL!\n");
return;
}
if(connection->state == UA_CONNECTIONSTATE_CLOSED)
return;

View File

@ -106,12 +106,12 @@ static void UaShowNodeValue(UA_Variant* val)
else if(val->type == &UA_TYPES[UA_TYPES_FLOAT])
{
UA_Float* ptr = (UA_Float*)val->data;
ua_notice("%d (Float)\n", *ptr);
printf("%f (Float)\n", *ptr);
}
else if(val->type == &UA_TYPES[UA_TYPES_DOUBLE])
{
UA_Double* ptr = (UA_Double*)val->data;
ua_notice("%d (Double)\n", *ptr);
printf("%f (Double)\n", *ptr);
}
else if(val->type == &UA_TYPES[UA_TYPES_STRING])
{

View File

@ -99,7 +99,7 @@ void ethernetif_clk_init(void)
{
const clock_enet_pll_config_t config = {.enableClkOutput = true, .enableClkOutput25M = false, .loopDivider = 1};
CLOCK_InitEnetPll(&config);
SysTick_Config(USEC_TO_COUNT(1000U, CLOCK_GetFreq(kCLOCK_CoreSysClk)));
SysTick_Config(SystemCoreClock / TICK_PER_SECOND);
}
void ethernetif_gpio_init(void)
@ -109,9 +109,7 @@ void ethernetif_gpio_init(void)
IOMUXC_EnableMode(IOMUXC_GPR, kIOMUXC_GPR_ENET1TxClkOutputDir, true);
GPIO_PinInit(GPIO1, 3, &gpio_config);
GPIO_PinInit(GPIO1, 10, &gpio_config);
/* pull up the ENET_INT before RESET. */
GPIO_WritePinOutput(GPIO1, 10, 1);
GPIO_WritePinOutput(GPIO1, 3, 0);
enet_delay();
GPIO_WritePinOutput(GPIO1, 3, 1);

View File

@ -41,11 +41,9 @@ void LPUART1_IRQHandler(int irqn, void *arg)
{
x_base lock = 0;
// KPrintf("LPUART1_IRQHandler \n");
lock = DISABLE_INTERRUPT();
lock = DisableIRQ(UART1_IRQn);
UartIsr(&serial_bus_1, &serial_driver_1, &serial_device_1);
ENABLE_INTERRUPT(lock);
EnableIRQ(UART1_IRQn);
}
DECLARE_HW_IRQ(UART1_IRQn, LPUART1_IRQHandler, NONE);
#endif