Tropical_Peach
Tropical_Peach

Reputation: 1143

How do I open a ttyMFD device on the Intel-Edison [C++]?

I have a /dev/ttyUSB device and a /dev/ttyMFD device that I need to stream to logfiles. For the USB device I could use termios and configure it through that. This was pretty straight forward and there was a bit of documentation for this as well.

I can't seem to find any for the MFD though. Some places call it a MultiFuctionDevice and others call it the Medfield High Speed UART device. Which is correct in the first place?

And secondly, can I open it in the same way that I open up a regular ttyUSB device?

Here is the snippit I use to open USB devices.

int fd = open(USBDEVICE0, O_RDWR);


struct termios io;
memset(&io, 0, sizeof(io));

io.c_iflag = 0;
io.c_oflag = 0;
io.c_cflag = CS8|CREAD|CLOCAL;           // 8n1, see termios.h for more information
io.c_lflag = 0;

// TODO -- Since we are operating in non-blocking mode; confirm VMIN and VTIME settings have no effect on duration of the read() call.

io.c_cc[VMIN] = 1;
io.c_cc[VTIME] = 5;

speed_t speedSymbol = B921600;

cfsetospeed(&io, speedSymbol);
cfsetispeed(&io, speedSymbol);


int retVal;
retVal = tcsetattr(fd, TCSANOW, &io);

tcflush(fd, TCIOFLUSH);
usleep(100);

EDIT

For anyone who comes across this, there is one caveat. You must open the device in raw mode and dump everything into a log file. Parsing must be done post. Everything will come out as raw data but if you try to do any kind of configuration, the devices buffer will not be able to capture all the data, hold it, and process it in time before more data comes along.

Upvotes: 1

Views: 194

Answers (1)

0andriy
0andriy

Reputation: 4674

MFD in Linux kernel is common abbreviation to Multi-Functional Device, Legacy serial driver for Edison abuses that and uses it's own interpretation as you mentioned: Medfield. In the upstream kernel the abbreviation MID is used regarding to Mobile Internet Device. In particular the serial driver is called drivers/tty/serial/8250_mid.c. See https://en.wikipedia.org/wiki/Mobile_Internet_device.

Yes, you may do the same operations as you did on top of /dev/ttyUSBx.

Upvotes: 2

Related Questions