Map service (Customer Linux application) to uart1 by :
root@swi-mdm9x15:~# microcom -E /dev/ttyAT
AT!MAPUART?
!MAPUART: 1,16
OK
AT!MAPUART=17,1
OK
AT!MAPUART?
!MAPUART: 17,16
OK
root@swi-mdm9x15:~# reboot -n
To Built my app project with :
uartStd.c:
#include"legato.h"
//#include"interface.h"
int open_port(void)
{
int fd; /* File descriptor for the port */
fd = open("/dev/ttyHS0", O_RDWR | O_NOCTTY | O_NDELAY); /*uart1*/
//fd = open("/dev/ttyHSL1", O_RDWR | O_NOCTTY | O_NDELAY); /*uart2*/
if (fd == -1)
{
/*
* Could not open the port.
*/
perror("open_port: Unable to open /dev/ttyHSL1 - ");
}
else
fcntl(fd, F_SETFL, 0);
return (fd);
}
void ledTimer(le_timer_Ref_t t)
{
//to do
//printf("==== hello UART test =====\r");
}
//--------------------------------------------------------------------------------------------------
/**
* Main program starts here
*/
//--------------------------------------------------------------------------------------------------
COMPONENT_INIT
{
LE_INFO("=============== Hello UART . ===============");
int uart_fd = open_port();
int n = write(uart_fd, "ATZ\r", 4);
if (n < 0)
fputs("write() of 4 bytes failed!\n", stderr);
LE_INFO("Attempt to output to UART produces: %d", n);
le_timer_Ref_t ledTimerRef = le_timer_Create("LED Timer");
le_timer_SetMsInterval(ledTimerRef, 1000);
le_timer_SetRepeat(ledTimerRef, 0);
le_timer_SetHandler(ledTimerRef,ledTimer);
le_timer_Start(ledTimerRef);
}
Component.cdef :
sources:
{
uartStd.c
}
requires:
{
device:
{
// Get read and write access to the UART1 port.
[rw] /dev/ttyHS0 /dev/ttyHS0
}
}
uartStd.adef :
version: 1.0.10
executables:
{
uart1Ctrl = ( uartStdComponent )
}
processes:
{
envVars:
{
LE_LOG_LEVEL = DEBUG
}
run:
{
( uart1Ctl )
}
}
Run on the legato, output the logs:
Jan 6 00:37:42 | supervisor[464]/supervisor T=main | app.c CreateFileLink() 1504 | Created file link '/tmp/legato/serviceDirectoryClient' to '/legato/systems/current/appsWriteable/uartStd/tmp/legato/serviceDirectoryClient'.
Jan 6 00:37:42 | supervisor[464]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxCoreDumpFileBytes to value 102400.
Jan 6 00:37:42 | supervisor[464]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileBytes to value 102400.
Jan 6 00:37:42 | supervisor[464]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxLockedMemoryBytes to value 8192.
Jan 6 00:37:42 | supervisor[464]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileDescriptors to value 256.
Jan 6 00:37:42 | supervisor[464]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxMQueueBytes to value 512.
Jan 6 00:37:42 | supervisor[464]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxThreads to value 20.
Jan 6 00:37:42 | supervisor[464]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxQueuedSignals to value 100.
Jan 6 00:37:42 | supervisor[464]/supervisor T=main | proc.c proc_Start() 1190 | Starting process 'uart1Ctl' with pid 7568
Jan 6 00:37:42 | supervisor[7568]/supervisor T=main | proc.c proc_Start() 1155 | Execing 'uart1Ctl'
Jan 6 00:37:42 | supervisor[7568]/supervisor T=main | proc.c proc_Start() 1167 | Could not exec 'uart1Ctl'. No such file or directory.
Jan 6 00:37:42 | supervisor[464]/supervisor T=main | proc.c proc_SigChildHandler() 1942 | Process 'uart1Ctl' (PID: 7568) has exited with exit code 1.
Jan 6 00:37:42 | supervisor[464]/supervisor T=main | proc.c GetFaultAction() 1744 | No fault action specified for process 'uart1Ctl'. Assuming 'ignore'.
Jan 6 00:37:43 | supervisor[464]/supervisor T=main | app.c app_SigChildHandler() 3221 | Process 'uart1Ctl' in app 'uartStd' faulted: Ignored.
Jan 6 00:37:43 | _appStopClient[7569]/framework T=main | LE_FILENAME CreateSocket() 550 | Socket opened as standard i/o file descriptor 2!
Jan 6 00:37:43 | supervisor[464]/supervisor T=main | apps.c DeactivateAppContainer() 340 | Application 'uartStd' has stopped.
Any advise for my issue, thanks.
Best Regards!