USETYPES with le_tty

Hello I’m trying to create a layer over the le_tty api but would like to use the Flowcontrol etc. defines. However when using

USETYPES le_tty;

I get the following error when attempting to generate the stub file:
IOError: [Errno 2] No such file or directory: u'le_tty.api'

Is this just not possible or am i doing something wrong?

Can you attach your project here

I’ve recreated the problem with a simplified solution:
UartTestProgram.zip (6.3 KB)

I’m using Visual Studio Code and am selecting the ‘Legato: Generate API stub files’, then select the ‘uart.api’ then select ‘components/uart’ as the output folder. And then the following error is generated:

> Executing task: ifgen --gen-server-stub /home/user/test/interfaces/uart.api --output-dir /home/user/test/components/uart <

Traceback (most recent call last):
  File "/home/user/test/leaf-data/SWI-WP77/wp77-legato/bin/ifgen", line 364, in <module>
    Main()
  File "/home/user/test/leaf-data/SWI-WP77/wp77-legato/bin/ifgen", line 259, in Main
    interface = interfaceParser.ParseCode(args.interfaceFile, importDirs, args.namePrefix)
  File "/home/user/.leaf/wp77-legato_19.11.2-202005290653/framework/tools/ifgen/interfaceParser.py", line 3049, in ParseCode
    iface = parser.apiDocument()
  File "/home/user/.leaf/wp77-legato_19.11.2-202005290653/framework/tools/ifgen/interfaceParser.py", line 2639, in apiDocument
    self.usetypesStmt()
  File "/home/user/.leaf/wp77-legato_19.11.2-202005290653/framework/tools/ifgen/interfaceParser.py", line 2492, in usetypesStmt
    self.iface.imports[basename] = ParseCode(fullFilename, self.searchPath)
  File "/home/user/.leaf/wp77-legato_19.11.2-202005290653/framework/tools/ifgen/interfaceParser.py", line 3036, in ParseCode
    fileStream = ANTLRFileStream(apiPath, 'utf-8')
  File "/home/user/.leaf/wp77-legato_19.11.2-202005290653/framework/tools/ifgen/antlr3/streams.py", line 544, in __init__
    fp = codecs.open(fileName, 'rb', encoding)
  File "/usr/lib/python2.7/codecs.py", line 898, in open
    file = __builtin__.open(filename, mode, buffering)
IOError: [Errno 2] No such file or directory: u'le_tty.api'
The terminal process "/bin/bash '-c', 'ifgen --gen-server-stub /home/user/test/interfaces/uart.api --output-dir /home/user/test/components/uart'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

I don’t see this “le_tty.api” in the legato source code, where do you find this file?

I’m trying to include tty API - Legato Docs the tty api from Legato

you can try this test app which will use those tty API

I think you misunderstand what it is I’m trying to do. I can use the tty api in my c code no problem. I however wish to make an api where someone can connect to one serial port from different applications/components and give them the option to change (amongst other things) the baudrate. To support this I want to make sure that the .api function uses the correct tty_Speed_t enumeration.

then you need to make your own api file as i don’t see such “le_tty.api” in the legato source code

That’s what i was afraid off, I was hoping to be able to reuse the tty_Speed_t enum in my .api file. But I’ll add this to my .api file instead and use that.

ENUM Speed
{
    SPEED_0 = 0,
    SPEED_50,
    SPEED_75,
    SPEED_110,
    SPEED_134,
    SPEED_150,
    SPEED_200,
    SPEED_300,
    SPEED_600,
    SPEED_1200,
    SPEED_1800,
    SPEED_2400,
    SPEED_4800,
    SPEED_9600,
    SPEED_19200,
    SPEED_38400,
    SPEED_57600,
    SPEED_115200,
    SPEED_230400,
    SPEED_460800,
    SPEED_500000,
    SPEED_576000,
    SPEED_921600,
    SPEED_1000000,
    SPEED_1152000,
    SPEED_1500000,
    SPEED_2000000,
    SPEED_2500000,
    SPEED_3000000,
    SPEED_3500000,
    SPEED_4000000
};

And hope that this enum doesn’t change between versions should i update my Legato version.

thanks for the information!