Send UART Break Sequence


#1

Hi,

I am using a q2687rd module with R746 (R7.46.0.201108091301.Q2687RD 2216044 080911 13:01)

I need to send a uart break sequence on uart2 to reset a chip attached to this port.

Here is my code so far

sUartSettings_t Settings;
        sUartFlowCtrl_t Fc;

        Settings.identity = "UART2";
	Settings.role = UART_ROLE_NM;
	Settings.capabilities = NULL;
	Settings.event_handlers =NULL;  //&events;
	Settings.interface = &pinterface2;
	Settings.line_coding =NULL;// &lc;
	Uart2Handle = adl_OpenDevice ( DF_UART_CLID, &Settings );

	if( Uart2Handle > OK )
	{
		debugmsg("+uart2:Port is now open\r\n");
		uart2_itf = *pinterface2;
		Fc.op   = G_IOC_OP_SET;
		Fc.type = UART_FC_RTS_CTS;
		if ( uart2_itf.io_control ( Uart2Handle, IOC_UART_FC, ( void* ) &Fc ) )
		{
			debugmsg("red:+Error:uart2 IOC_UART_FC Failed\r\n");
		}

		//code taken from 4.1.4.2.1. and modified to fit
		//switch to synchronous read
		sUartEvent_t evt_setting;
		//p_rx_buf = rx_buf;
		//amount_tb_read = sizeof( rx_buf);

		evt_setting.op = G_IOC_OP_SET;
		evt_setting.valid_cb = (eUartEvId_t)(UART_CB_ON_RX_DATA_AVAILABLE |
				                             UART_CB_ON_RX_DATA_AVAILABLE);
		evt_setting.user_data = (void*)-1L; // not used
		evt_setting.cb_list[5].evt_hdl = NULL;
		evt_setting.cb_list[2].evt_hdl = (pGEvtNotif_t)&on_rxda_handler;
		evt_setting.cb_list[2].user_data = (void*)-1L; // not used
		if( uart2_itf.io_control( Uart2Handle, IOC_UART_EH, &evt_setting ) )
		{
			debugmsg("red:+Error:Failed to switch uart2 to synchronous read\r\n");
		}

                //send uart break
                sUartSsIoc_t brk;
	        brk.op=G_IOC_OP_SET;
	        brk.sig_id=UART_SIG_BREAK;
	        brk.state=UART_SIG_BREAK;

                if ( uart2_itf.io_control ( Uart2Handle, IOC_UART_SS , ( void* ) &brk ) )
                {
 	               debugmsg("red:+Error:uart2 break failed\r\n");
                }
                debugmsg("+uart2:Break Sent\r\n");

               //send data byte
	       u8 bt[1];
	       bt[0]=0xC1;
	       uart2_itf.write(Uart2Handle,bt,1);	//write a byte
	}
	else
	{
		debugmsg("red:+Error:Failed to open uart2\r\n");
	}

Now basically, it claims the break is sent, but upon writing a byte to the port after sending the break, the device will freeze up and watchdog reset. If I disable the watchdog, it will freeze forever within the call to write.

I have already configured the port with the at+wmfm=0,0,2 command, as it did not want to open until I did this

What am I doing wrong, why does the uart break operation cause the module to lock up on further writes ?

Can anyone help ?

Thanks,

Steed.


#2

Hi Steed,

I am not sure if the code you shared is appropriate or not, but if break signal is concerned, we usually care the duration as well.
In the doc seems no info about the timing and I got below as alternative when i search the forum:
[url]https://forum.sierrawireless.com/t/break-signals-over-uart/4463/1]

Hope this help…

L