UART2 Linux application mode is not working

Hi all,

i am facing an issue with UART2 in application mode , Once i enable uart 2 for application mode, ttyHSL1 is coming as disabled (checked by dmesg | grep tty). While running the app it reporting the below mentioned error

Jan 6 05:49:27 swi-mdm9x28-wp user.err Legato: =ERR= | supervisor[859]/supervisor T=main | app.c GetDevID() 670 | Could not get file info for ‘/dev/ttyHSL1’. No such file or directory.

Jan 6 05:49:27 swi-mdm9x28-wp user.err Legato: =ERR= | supervisor[859]/supervisor T=main | app.c SetCfgDevicePermissions() 775 | Failed to set permissions (rw) for app ‘rs232app_test’ on device ‘/dev/ttyHSL1’.

Jan 6 05:49:27 swi-mdm9x28-wp user.err Legato: =ERR= | supervisor[859]/supervisor T=main | app.c app_Start() 3452 | Failed to set Smack rules or set up app area.

Please suggest a solution to overcome this issue, Thanks in advance

Regards,

Arun

Can you attach your app here?
What module and fw ate you using?
Have yoh tried unsandbox the app?

BTW, have you set the AT!MAPUART=17,2 so that UART2 can be used in linux app?
once you set this, after reset, you should not see /dev/ttyHSL1

Hi,

Please find the code snipped below

void* Modbus_Reading_Thread(void* object)
{
int res = 0;

LE_INFO("MODBUS Thread Started");

while(1)
{
    res = read(Serial_Port_fd,&Rx_Buffer[Rx_count],RX_RS485_SIZE-2);
   

    if(res)
    {
        Rx_count += res;
        Byte_Recv = 1;
        byteTimeout = BYTE_TO_BYTE_TIMEOUT;
        
        if(Rx_count > (RX_RS485_SIZE-2))						/* Buffer overflow checking in case of junk receiving */
        {
            Rx_count = 0;
        }
    }
}

}

/*

  • Serial Port Initialization Program

============================================================================================
*/

void Serial_Driver_Port()
{

Serial_Port_fd = open(“/dev/ttyHSL1”, O_RDWR | O_NOCTTY | O_NDELAY);

if (Serial_Port_fd == -1)
{
/*
* Could not open the port.
*/

LE_ERROR("open_port: Unable to open /dev/ttyHSL1 - ");

}
else
{
fcntl(Serial_Port_fd, F_SETFL, 0);

le_tty_SetRaw(Serial_Port_fd, 0, 0);	//ECHO is OFF

le_tty_SetFraming(Serial_Port_fd, 'N', 8, 1);

pthread_create(&MODBUS_Read_Thread_ID, (pthread_attr_t*)(0), &Modbus_Reading_Thread, (void*)(0));

sleep(1);

LE_INFO("COM PORT HSL1 Opened");

}
}

.cdef file

// Linux filesystem device paths.
device:
{
    // Get read and write access to the UART1 port.
    [rw]    /dev/ttyHSL1   /dev/ttyHSL1
}

in .adef file

sandbox : false

I used uartMode set 2 app command for setting application mode, after system restart HSL1 disabled is coming in dmesg, while using uartMode get 2 command reports linux application

once you set AT!MAPUART=17,2 , after reset, you should not see /dev/ttyHSL1

Hi,
I performed the AT command set, and restarted , it showing as below

root@swi-mdm9x28-wp:~# dmesg | grep tty
[ 0.000000] Kernel command line: console=ttyHSL0,115200 console=ttyHSL1,115200 root=/dev/ram rootfs_ro=true user1_fs=ubifs verity=on ima_ready=0 lkversion=SWI9X07Y_02.28.03.03 androidboot.serialno=5c5d67dd androidboot.authorized_kernel=true quiet androidboot.baseband=msm rootfstype=ubifs rootflags=bulk_read
[ 0.660730] ttyHS0 is reserved for AT service.
[ 0.663953] 78b0000.uart: ttyHS0 at MMIO 0x78b0000 (irq = 49, base_baud = 460800) is a MSM HS UART
[ 0.666305] ttyHS1 could be used as generic serial port.
[ 0.669063] 78af000.uart: ttyHS1 at MMIO 0x78af000 (irq = 48, base_baud = 460800) is a MSM HS UART
[ 0.671868] ttyHSL1 is disabled.
[ 0.672155] ttyHSL0 is disabled.

i have to use ttyHS1 for my application?

Hi,

Thanks for the support its working as expected, please find the working code sample below

/*

  • Receive MODBUS Packet Program

============================================================================================
*/

void* Modbus_Reading_Thread(void* object)
{
int res = 0;

uint8_t  temp_buf[RX_RS485_SIZE] = {0};

LE_INFO("MODBUS Thread Started");

while(1)
{
    res = read(Serial_Port_fd,temp_buf,RX_RS485_SIZE-2);
    
    if(res > 0)
    {
		if((Rx_count + res) > (RX_RS485_SIZE-2))
			Rx_count = 0;

		memcpy(&Rx_Buffer[Rx_count],temp_buf,res);

		Rx_count += res;
	
        Byte_Recv = 1;
        byteTimeout = BYTE_TO_BYTE_TIMEOUT;
        
        if(Rx_count > (RX_RS485_SIZE-2))						/* Buffer overflow checking in case of junk receiving */
        {
            Rx_count = 0;
        }
    }
}

}

/*

  • Serial Port Initialization Program

============================================================================================
*/

void Serial_Driver_Port()
{

Serial_Port_fd = open(“/dev/ttyHS1”, O_RDWR | O_NOCTTY | O_NDELAY);

if (Serial_Port_fd == -1)
{
/*
* Could not open the port.
*/

LE_ERROR("open_port: Unable to open /dev/ttyHS1 - ");

}
else
{
fcntl(Serial_Port_fd, F_SETFL, 0);

le_tty_SetBaudRate(Serial_Port_fd,LE_TTY_SPEED_19200);

le_tty_SetRaw(Serial_Port_fd, 0, 0);	//ECHO is OFF

le_tty_SetFraming(Serial_Port_fd, 'N', 8, 1);

pthread_create(&MODBUS_Read_Thread_ID, (pthread_attr_t*)(0), &Modbus_Reading_Thread, (void*)(0));

sleep(1);

LE_INFO("COM PORT HSL1 Opened");

}
}

in .cdef file

// Linux filesystem device paths.
device:
{
    // Get read and write access to the UART1 port.
    [rw]    /dev/ttyHS1   /dev/ttyHS1
}