Send stuff from mangOH app to /dev/ttyUSBx


So I eventually got my FTDI USB-to-serial cable working on the command line.

Now - how do I do that from an app?

I have tried:

    int fd = open( "/dev/ttyUSB1", O_RDWR | O_NOCTTY | O_NDELAY );
    if( fd < 0 )
    	LE_INFO("open failed");

   ssize_t result = write( fd, "Opened.\r\n", 9 );
   if( result < 0 )
    	LE_INFO("1st write failed");

But the open fails.

Where am going wrong?

errno is 2 when the open fails - which, I think, is

ENOENT 2 /* No such file or directory */


If your app is sandboxed (if you don’t specify “sandboxed: false” in the .adef it will be), then /dev/ttyUSB1 won’t exist in the filesystem seen by your app.

See this section of the Legato documentation on how to put a device file into your sandbox:

Basically, you need this:

        [rw] /dev/ttyUSB1 /dev/
        // Above line is a shortcut for: [rw] /dev/ttyUSB1 /dev/ttyUSB1


Yes, that’s it.