# USETYPES with le\_tty

**URL:** <https://forum.legato.io/t/usetypes-with-le-tty/5735>\
**Category:** Uncategorized\
**Created:** [April 29, 2021, 7:24am UTC](https://forum.legato.io/t/usetypes-with-le-tty/5735 "2021-04-29T07:24:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![shommersom](https://avatars.discourse-cdn.com/v4/letter/s/9fc29f/32.png) [@shommersom](https://forum.legato.io/u/shommersom)\
**Post date:** [April 29, 2021, 7:24am UTC](https://forum.legato.io/t/usetypes-with-le-tty/5735/1 "2021-04-29T07:24:43Z")

</div>

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

```nohighlight
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?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [April 29, 2021, 8:21am UTC](https://forum.legato.io/t/usetypes-with-le-tty/5735/2 "2021-04-29T08:21:53Z")

</div>

Can you attach your project here

---

<div class="post-metadata">

**Author:** ![shommersom](https://avatars.discourse-cdn.com/v4/letter/s/9fc29f/32.png) [@shommersom](https://forum.legato.io/u/shommersom)\
**Post date:** [April 29, 2021, 8:57am UTC](https://forum.legato.io/t/usetypes-with-le-tty/5735/3 "2021-04-29T08:57:35Z")

</div>

I’ve recreated the problem with a simplified solution:  
[UartTestProgram.zip](https://forum.legato.io/uploads/short-url/fSLwMt68uthe4xJY7zwVmXkTxxL.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:

```auto
> 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.

```

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [April 29, 2021, 9:15am UTC](https://forum.legato.io/t/usetypes-with-le-tty/5735/4 "2021-04-29T09:15:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![shommersom](https://avatars.discourse-cdn.com/v4/letter/s/9fc29f/32.png) [@shommersom](https://forum.legato.io/u/shommersom)\
**Post date:** [April 29, 2021, 9:19am UTC](https://forum.legato.io/t/usetypes-with-le-tty/5735/5 "2021-04-29T09:19:29Z")

</div>

I’m trying to include [tty API - Legato Docs](https://docs.legato.io/20_08/c_tty.html) the tty api from Legato

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [April 29, 2021, 9:28am UTC](https://forum.legato.io/t/usetypes-with-le-tty/5735/6 "2021-04-29T09:28:12Z")

</div>

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

> **[legato-af/apps/test/atServices/atServerIntegrationTest at master ·...](https://github.com/legatoproject/legato-af/tree/master/apps/test/atServices/atServerIntegrationTest)**
>
> master/apps/test/atServices/atServerIntegrationTest

---

<div class="post-metadata">

**Author:** ![shommersom](https://avatars.discourse-cdn.com/v4/letter/s/9fc29f/32.png) [@shommersom](https://forum.legato.io/u/shommersom)\
**Post date:** [April 29, 2021, 9:48am UTC](https://forum.legato.io/t/usetypes-with-le-tty/5735/7 "2021-04-29T09:48:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [April 29, 2021, 9:55am UTC](https://forum.legato.io/t/usetypes-with-le-tty/5735/8 "2021-04-29T09:55:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![shommersom](https://avatars.discourse-cdn.com/v4/letter/s/9fc29f/32.png) [@shommersom](https://forum.legato.io/u/shommersom)\
**Post date:** [April 29, 2021, 10:00am UTC](https://forum.legato.io/t/usetypes-with-le-tty/5735/9 "2021-04-29T10:00:20Z")

</div>

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.

```auto
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!
