I try to read char on the serial port of a FX30S but I have trouble to make it work.
I use the R13.1.3.00.1 firmware :
I have set up the mapping on the serial port ttyHSL0 then reboot the modem (When I ask AT!MAPUART? after a reboot, it’s still “17,0” even if I set 17,1 before):
It looks like it worked when I interrogated the FX30S :
The ttyHSL0 port is no longer considered as disable like it was before I enter the AT command.
Then I use developer studio to write my C application. I use “le_tty.h” functions to configure the serial port :
The followed error message is displayed when I try to launch the app :
“Error opening serial device ‘dev/ttyHSL0’ : No such file or directory found”.
Is the code wrong ?
Do you have an example of programme using the serial port of a FX30S ?
Thanks for the link, it was very helpful.
The problem wasn’t running the app on sandboxed or unsandboxed mode but it was still in the .adef file.
This part was missing to allow read and write access to the serial port :
requires:
{
device:
{
// read and write access to the UART2 port.
[rw] /dev/ttyHSL1 /dev/ttyHSL1
}
}
If someone is interested, here is my code to read char on the UART port /dev/ttyHSL0 of a FX30S. It’s probably far from being well optimized but it works and you will get the idea.
.c file :
#include <legato.h>
#include <interfaces.h>
#include <le_tty.h>
#include <string.h>
#include <unistd.h>
COMPONENT_INIT
{
LE_INFO("begin app");
const char *serialPort = "/dev/ttyHSL0";
int port = le_tty_Open(serialPort, O_RDWR |O_NOCTTY);
//Paramétrage de la communication série
le_tty_SetBaudRate(port, LE_TTY_SPEED_19200);
le_tty_SetRaw(port, 1, 2);
//le_tty_SetFlowControl(port, LE_TTY_FLOW_CONTROL_NONE);
char *parity = "N";
le_tty_SetFraming(port, *parity, 8, 1);
do {
char buffer[1024];
int readSerial;
int i;
readSerial = read(port, buffer, sizeof(buffer));
if (readSerial > 0) {
LE_INFO("Read : %d ", readSerial);
for (i=0; i < readSerial;i++){
printf("%02X", buffer[i]);
}
printf("\n");
}
else {
printf("Else error, readSerial = %d", readSerial);
}
} while (1);
LE_INFO("end app");
}
.adef file :
executables:
{
serial = ( serialComponent )
}
processes:
{
envVars:
{
LE_LOG_LEVEL = DEBUG
}
run:
{
( serial )
}
maxCoreDumpFileBytes: 512K
maxFileBytes: 512K
}
requires:
{
device:
{
// read and write acess to the UART2 port.
[rw] /dev/ttyHSL0 /dev/ttyHSL0
}
}
version: 1.0.0
maxFileSystemBytes: 512K