FX30 - UART on IoT expansion card slot

Hello all,
How to set up UART on FX30 IoT expansion card slot in my own application ?
What I do wrong, still I have 115200bps linux console ?

I made AT command AT!MAPUART=17,1 by USB AT port.
In my Component.cdef file I added:
requires:
{
device:
{
[rw] /dev/ttyHS0 /dev/ttyHS0
}
}

UART initial code:

#define BAUDRATE B19200
struct termios newtio;
int tty_fd = -1;

bool serial_OpenPort ( void )
{
tty_fd = open("/dev/ttyHS0", O_RDWR | O_NOCTTY);
if(tty_fd < 0) {
return false;
}

bzero(&newtio, sizeof(newtio));
cfmakeraw(&newtio);
newtio.c_cflag = BAUDRATE | CS8 | ~CRTSCTS | CLOCAL | CREAD;
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;
newtio.c_lflag = 0;
newtio.c_cc[VTIME] = 0;
newtio.c_cc[VMIN] = 5;
tcflush(tty_fd, TCIFLUSH);
tcsetattr(tty_fd, TCSANOW, &newtio);

write(tty_fd, “TEST”, 4);

return true;
}

I have little progress, I find that the default on IoT expansion slot is connected with UART 2 then:

  1. I chenged UART2 mode to: AT!MAPUART=17,2
  2. In file Component.cdef changed to: [rw] /dev/ttyHSL1 /dev/ttyHSL1
  3. In function: tty_fd = open("/dev/ttyHSL1", O_RDWR | O_NOCTTY);

Now I can send chars to the UART 2 and observe on Tx my sended chars, but the speed is incorrect is about 4 000 000 bps no 19200.
Unfotunetly I find next problem with GPIO service when I change UART 2 mode, my application report the error:

Jan 6 00:02:22 | gpioService[538]/sysfsGpio T=main | gpioSysfsUtils.c ExportGpio() 106 | Failed to export GPIO 47. Error Operation not permitted
Jan 6 00:02:22 | gpioService[538]/sysfsGpio T=main | gpioSysfsUtils.c gpioSysfs_SessionOpenHandlerFunc() 1061 | Unable to export GPIO gpio47 for use - stopping session

I finds some information on forum about muxCtrlService but I dont know how to use this on FX30 gateway
Please any help.

Hello Rafa,

I don’t think there is a multiplexer inside in FX30 so i don’t think you can use Mangoh’s muxCtrlService.
I am still investigating the issue as it kind of becoming urgent for us.
See at similar other topic:
https://forum.sierrawireless.com/t/fx30-n-reset-iot-pin-mapping-in-legato/9042/1

Let us know if you have already found out new information about the FX30 IOT slot.

Regarding your speed problem:
I use both cfsetospeed() & cfsetispeed() on termios structure or you can also use this new legato API:
legato.io/legato-docs/latest/c_tty.html

Cheers,
tom

Hi tomalex,

The problem is solved when I updated firmware to FX30 R13.1.2.004,
https://source.sierrawireless.com/resources/airlink/software_downloads/fx30-firmware/fx30-firmware/

Below IoT expansion slot maping:
FX30 IoT connector Interface -> FX30 Resource
GPIO1 -> GPIO 42
GPIO2 -> GPIO 33
GPIO3 -> GPIO 13
GPIO4 -> GPIO 8
IOT_DETECT -> GPIO 25
USB Hub on HSIC WP interface, mounted on ttyUSB0
SDIO -> SDIO
UART -> UART2
SPI -> SPI1
ADC -> ADC0
PCM -> PCM
I2C -> I2C1

I made changes in port setting to:

void serial_SetPortSettings()
{
    tcgetattr(tty_fd,&oldtio); /* save current port settings */
    bzero(&newtio, sizeof(newtio));
    newtio.c_cflag = B19200 | CRTSCTS | CS8 | CLOCAL | CREAD;
    newtio.c_iflag = IGNPAR;
    newtio.c_oflag = 0;
    newtio.c_lflag = 0;
    newtio.c_cc[VTIME]    = 0;
    newtio.c_cc[VMIN]     = 1;
    tcflush(tty_fd, TCIFLUSH);
    tcsetattr(tty_fd,TCSANOW,&newtio);
}

Hello Rafa,

Thanks for the post, just one mistery left, how the nReset Pin is handled!..

tom

Hi

Try use GPIO 6 / gpioService.le_gpioPin6.

rafal