This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/CC2531: Z-STACK-LINUX-GATEWAY is restart after write error to USB error ([ERR] npi_ipc_errno 0x02030100)

Part Number: CC2531
Other Parts Discussed in Thread: Z-STACK

Tool/software: Linux

I am using Z-STACK-LINUX-GATEWAY (from Z-Stack_Linux_Gateway-1_0_1-src-linux-installer.run) on Beagle Bone Black with CC2531 USB dongle.

I have loaded (CC2531-GW-ZNP_38724.hex) into CC2531USB rev 2.4. 

The GW is working, but sometimes I receive this error:

[ERR] npi_ipc_errno 0x02030100 (=NPI_LNX_ERROR_UART_SEND_FRAME_FAILED_TO_WRITE, failed write to USB (/dev/ttyACM0)). 

This error results in Z-Stack_Linux_Gateway to be restarted (GW is not working for 20 seconds which is unacceptable for us).

Is this a HW limitation of CC2531 USB dongle?

  • Does this issue occur only in certain scenarios such has when a lot of messages are sent back to back to the ZNP, can you please provide steps to reproduce?
  • Yes, it happens when there is more messages, but not really that much.

    How to reproduce it: I have wrote a simulation of a switch for test purposes which sends ON, waits for reply, sends OFF, waits for reply, sends ON, ...

  • Hi,

    At what rate are you sending the on/off commands? I assume they are being sent to a Zigbee light device which is connected to your network? Can you post a sniffer log of your test?
  • These on/off commands are sent to the GW endpoint 6 (the idea is to bind Zigbee switch with wire light connected to beagle by relay).
    I am sending those on/off commands as fast as possible: On/Off commands is sent afer it receives the reply for Off/On command after 5 seconds the reply is not received.

    It may be neccessary to also toggle Zigbee light from the GW during the test.
    I will prepare detailed steps how to reproduce this.

    I will try to also capture a sniffer log.
  • I have found possible fix or workaround. Please let me know what do you think about this solution.

    See this patch: against sources in Z-Stack_Linux_Gateway-1_0_1-src-linux-installer.run

    diff --git a/Source/Projects/tools/LinuxHost/ipclib/server/npi_lnx_uart.c b/Source/Projects/tools/LinuxHost/ipclib/server/npi_lnx_uart.c
    index 44848ab..ac521b0 100644
    --- a/Source/Projects/tools/LinuxHost/ipclib/server/npi_lnx_uart.c
    +++ b/Source/Projects/tools/LinuxHost/ipclib/server/npi_lnx_uart.c
    @@ -846,9 +846,24 @@ static int npi_write(const void *buf, size_t count)
     	}
     #endif //__DEBUG_TIME__
     
    -	pthread_mutex_lock(&npi_write_mutex);
    -	result = write(npi_fd, buf, count);
    -	pthread_mutex_unlock(&npi_write_mutex);
    +	//Try write five times with 1 second delay for Interupted system call error
    +	for (size_t i = 0; i < 5; i++)
    +	{
    +		pthread_mutex_lock(&npi_write_mutex);
    +		result = write(npi_fd, buf, count);
    +		int writeErrno = errno;
    +		pthread_mutex_unlock(&npi_write_mutex);
    +		bool interruptedSystemCallError = (result == -1) && (writeErrno == EINTR);
    +		if (interruptedSystemCallError)
    +		{
    +			debug_printf("[UART] write try %d/5 resulted in Interrupted system call error\n", i + 1 );
    +			sleep(1);
    +		}
    +		else
    +		{
    +			break;
    +		}
    +	}
     
     #ifdef __DEBUG_TIME__
     	if (__DEBUG_TIME_ACTIVE == TRUE)